OpenCilk / opencilk-project

Monorepo for the OpenCilk compiler. Forked from llvm/llvm-project and based on Tapir/LLVM.
Other
93 stars 29 forks source link

Compiler Crash "SelectionDAGBuilder shouldn't visit detached_rethrow instructions!" #161

Closed wheatman closed 9 months ago

wheatman commented 1 year ago

Describe the bug

The compiler crashes with the following message

SelectionDAGBuilder shouldn't visit detached_rethrow instructions!
UNREACHABLE executed at /home/wheatman/opencilkdev14.x/opencilk-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2947!

OpenCilk version

../opencilkdev14.x/build/bin/clang++ --version
clang version 14.0.6 (https://github.com/OpenCilk/opencilk-project 88438b46b3dc460920e783437590fd79983fd27d)
Target: x86_64-unknown-linux-gnu
Thread model: posix

System information

Steps to reproduce (include relevant output)

The associated reproducer files are attached

run-7daeeb.sh.txt run-7daeeb.cpp.txt

Additional comments

The full backtrace is

SelectionDAGBuilder shouldn't visit detached_rethrow instructions!
UNREACHABLE executed at /home/wheatman/opencilkdev14.x/opencilk-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:2947!
PLEASE submit a bug report to https://github.com/OpenCilk/opencilk-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /home/wheatman/opencilkdev14.x/build/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name run.cpp -mrelocation-model static -mframe-pointer=none -menable-no-infs -menable-no-nans -fmath-errno -fno-signed-zeros -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffp-exception-behavior=ignore -ffinite-math-only -mconstructor-aliases -funwind-tables=2 -target-cpu skylake -target-feature -avx512pf -target-feature -tsxldtrk -target-feature +cx16 -target-feature +sahf -target-feature -tbm -target-feature -avx512ifma -target-feature -sha -target-feature +crc32 -target-feature -fma4 -target-feature -vpclmulqdq -target-feature +prfchw -target-feature +bmi2 -target-feature -cldemote -target-feature +fsgsbase -target-feature -ptwrite -target-feature -amx-tile -target-feature -uintr -target-feature -gfni -target-feature +popcnt -target-feature -widekl -target-feature +aes -target-feature -avx512bitalg -target-feature -movdiri -target-feature +xsaves -target-feature -avx512er -target-feature -avxvnni -target-feature -avx512fp16 -target-feature -avx512vnni -target-feature -amx-bf16 -target-feature -avx512vpopcntdq -target-feature -pconfig -target-feature -clwb -target-feature -avx512f -target-feature +xsavec -target-feature -clzero -target-feature -pku -target-feature +mmx -target-feature -lwp -target-feature -rdpid -target-feature -xop -target-feature +rdseed -target-feature -waitpkg -target-feature -kl -target-feature -movdir64b -target-feature -sse4a -target-feature -avx512bw -target-feature +clflushopt -target-feature +xsave -target-feature -avx512vbmi2 -target-feature +64bit -target-feature -avx512vl -target-feature -serialize -target-feature -hreset -target-feature +invpcid -target-feature -avx512cd -target-feature +avx -target-feature -vaes -target-feature -avx512bf16 -target-feature +cx8 -target-feature +fma -target-feature -rtm -target-feature +bmi -target-feature -enqcmd -target-feature +rdrnd -target-feature -mwaitx -target-feature +sse4.1 -target-feature +sse4.2 -target-feature +avx2 -target-feature +fxsr -target-feature -wbnoinvd -target-feature +sse -target-feature +lzcnt -target-feature +pclmul -target-feature -prefetchwt1 -target-feature +f16c -target-feature +ssse3 -target-feature -sgx -target-feature -shstk -target-feature +cmov -target-feature -avx512vbmi -target-feature -amx-int8 -target-feature +movbe -target-feature -avx512vp2intersect -target-feature +xsaveopt -target-feature -avx512dq -target-feature +sse2 -target-feature +adx -target-feature +sse3 -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/home/wheatman/SSTGraph_as_Library -resource-dir /home/wheatman/opencilkdev14.x/build/lib/clang/14.0.6 -I ParallelTools/ -I StructOfArrays/include/ -I parlaylib/include/ -I cxxopts/include/ -I EdgeMapVertexMap/include/ -I -fopencilk -D PARLAY_CILK -D OPENMP=0 -D CILK=1 -D TINYSET_32=0 -D NO_INLINE_TINYSET=0 -D PARLAY=0 -D NDEBUG -c-isystem /usr/include/openmpi/ -c-isystem /home/wheatman/local/include/ -c-isystem /usr/include/openmpi/ -c-isystem /home/wheatman/local/include/ -c-isystem . -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward -internal-isystem /home/wheatman/opencilkdev14.x/build/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wall -Wno-address-of-packed-member -Wextra -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/wheatman/SSTGraph_as_Library -ferror-limit 1 -ftemplate-backtrace-limit 0 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -stripmine-loops -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/run-9eafc6.o -x c++ run.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'run.cpp'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z23get_edges_from_file_binIbEPNSt11conditionalIXsr3std7is_sameIT_bEE5valueESt5tupleIJjjEES2_IJjjS1_EEE4typeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPmPjb'
 #0 0x0000000001f86193 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x1f86193)
 #1 0x0000000001f83f7e llvm::sys::RunSignalHandlers() (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x1f83f7e)
 #2 0x0000000001f8665f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f48435ca420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f4842c3500b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f4842c14859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
 #6 0x0000000001f07bd1 (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x1f07bd1)
 #7 0x0000000002e1ee13 llvm::SelectionDAGBuilder::visitInvoke(llvm::InvokeInst const&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2e1ee13)
 #8 0x0000000002e19811 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2e19811)
 #9 0x0000000002eb9ef0 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2eb9ef0)
#10 0x0000000002eb9363 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2eb9363)
#11 0x0000000002eb5a24 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2eb5a24)
#12 0x0000000000c7f429 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#13 0x00000000012d110e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x12d110e)
#14 0x00000000017be5f8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x17be5f8)
#15 0x00000000017c6d81 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x17c6d81)
#16 0x00000000017bf26c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x17bf26c)
#17 0x00000000022dde51 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x22dde51)
#18 0x0000000002fc6849 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2fc6849)
#19 0x0000000003c3e484 clang::ParseAST(clang::Sema&, bool, bool) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x3c3e484)
#20 0x00000000029b2180 clang::FrontendAction::Execute() (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x29b2180)
#21 0x000000000292a48f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x292a48f)
#22 0x0000000002a7e1b3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x2a7e1b3)
#23 0x00000000009931fd cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x9931fd)
#24 0x0000000000991130 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#25 0x0000000000990ec7 main (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x990ec7)
#26 0x00007f4842c16083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#27 0x000000000098e01e _start (/home/wheatman/opencilkdev14.x/build/bin/clang-14+0x98e01e)
clang-14: error: unable to execute command: Aborted
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.6 (https://github.com/OpenCilk/opencilk-project 88438b46b3dc460920e783437590fd79983fd27d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wheatman/SSTGraph_as_Library/../opencilkdev14.x/build/bin
clang-14: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/run-7daeeb.cpp
clang-14: note: diagnostic msg: /tmp/run-7daeeb.sh
clang-14: note: diagnostic msg: 

********************
neboat commented 1 year ago

From looking at the reproducer files, I think there's a mistake in the flags you're passing to clang. It looks like your original command had the flags -I -fopencilk. (In other words, there's a -I flag, but no include directory after it.) The -I flag treats the string after it as a directory path, which in this case is the string -fopencilk. As a result, this command does not actually pass -fopencilk to clang, and the compiler ends up not properly targeting OpenCilk.

We should make some user-facing improvements to make this case fail in a cleaner way that's easier to understand. But in this particular case, I think fixing the flags should resolve your problem.

wheatman commented 1 year ago

Ah my bad, I had an issue with my Makefile, but yeah an error message instead of a crash there would be helpful.

neboat commented 9 months ago

I'm going to go ahead and close this issue, since I no longer see this compiler crash with the latest release.