lowRISC / riscv-llvm

RISC-V support for LLVM projects (LLVM, Clang, ...)
http://www.lowrisc.org/llvm/status/
249 stars 52 forks source link

__builtin_flt_rounds() crashes on riscv64 #52

Open EdSchouten opened 6 years ago

EdSchouten commented 6 years ago

I thought you might be interested in this bug report. I've observed that the following code:

int main() {
  return __builtin_flt_rounds();
}

Causes Clang r318692 to crash as follows:

08:50:29 ed@x ~ $ riscv64-unknown-cloudabi-cc -o bla bla.c    
#0 0x0000000001a82748 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/riscv-llvm/bin/clang-6.0+0x1a82748)
#1 0x0000000001a82cf6 SignalHandler(int) (/usr/local/riscv-llvm/bin/clang-6.0+0x1a82cf6)
#2 0x00000008047288f6 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
#3 0x0000000804727e9f thr_sighandler /usr/src/lib/libthr/thread/thr_sig.c:190:1
Stack dump:
0.      Program arguments: /usr/local/riscv-llvm/bin/clang-6.0 -cc1 -triple riscv64-unknown-cloudabi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name bla.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-abi lp64 -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -resource-dir /usr/local/riscv-llvm/lib/clang/6.0.0 -fdebug-compilation-dir /home/ed -ferror-limit 19 -fmessage-length 177 -fsanitize=safe-stack -fno-signed-char -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/bla-8c659e.o -x c bla.c 
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'bla.c'.
4.      Running pass 'RISCV DAG->DAG Pattern Instruction Selection' on function '@main'
clang-6.0: error: unable to execute command: Segmentation fault (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 6.0.0 (trunk 318692)
Target: riscv64-unknown-cloudabi
Thread model: posix
InstalledDir: /usr/local/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-6.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/bla-f7f5ca.c
clang-6.0: note: diagnostic msg: /tmp/bla-f7f5ca.sh
clang-6.0: note: diagnostic msg: 

********************