llvm-project
llvm-project copied to clipboard
Clang segfaults in NVPTXTargetLowering::LowerCall
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /p/project/cjinb33/kitayama1/dev/clang/bin/clang-16 -cc1 -triple nvptx64-nvidia-cuda -aux-triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name modelsmodule.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -ffp-contract=on -fno-rounding-math -fno-verbose-asm -no-integrated-as -mlink-builtin-bitcode /p/software/jurecadc/stages/2022/software/CUDA/11.5/nvvm/libdevice/libdevice.10.bc -target-sdk-version=11.5 -mlink-builtin-bitcode /p/project/cjinb33/kitayama1/dev/clang/lib/libomptarget-nvptx-sm_35.bc -target-cpu sm_35 -target-feature +ptx75 -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=line-directives-only -dwarf-version=2 -debugger-tuning=gdb -fno-dwarf-directory-asm -resource-dir /p/project/cjinb33/kitayama1/dev/clang/lib/clang/16.0.0 -dependency-file CMakeFiles/models.dir/modelsmodule.cpp.o.d -MT models/CMakeFiles/models.dir/modelsmodule.cpp.o -sys-header-deps -internal-isystem /p/project/cjinb33/kitayama1/dev/clang/lib/clang/16.0.0/include/openmp_wrappers -include __clang_openmp_device_functions.h -D models_EXPORTS -I /p/software/jurecadc/stages/2022/software/libreadline/8.1-GCCcore-11.2.0/include -I /p/scratch/cjinb33/kitayama1/projects/nest-simulator/thirdparty -I /p/scratch/cjinb33/kitayama1/projects/nest-simulator/libnestutil -I /p/scratch/cjinb33/kitayama1/build/nest-clang-offload/libnestutil -I /p/scratch/cjinb33/kitayama1/projects/nest-simulator/sli -I /p/scratch/cjinb33/kitayama1/projects/nest-simulator/nestkernel -I/p/software/jurecadc/stages/2022/software/DB/18.1.40-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/libreadline/8.1-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/gettext/0.21-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/libxml2/2.9.10-GCCcore-11.2.0/include/libxml2 -I/p/software/jurecadc/stages/2022/software/libxml2/2.9.10-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/expat/2.4.1-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/Boost/1.78.0-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/ICU/70.1-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/CUDA/11.5/nvvm/include -I/p/software/jurecadc/stages/2022/software/CUDA/11.5/extras/CUPTI/include -I/p/software/jurecadc/stages/2022/software/CUDA/11.5/include -I/p/software/jurecadc/stages/2022/software/libarchive/3.5.1-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/XZ/5.2.5-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/cURL/7.78.0-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/OpenSSL/1.1/include -I/p/software/jurecadc/stages/2022/software/bzip2/1.0.8-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/ncurses/6.2-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/binutils/2.37-GCCcore-11.2.0/include -I/p/software/jurecadc/stages/2022/software/zlib/1.2.11-GCCcore-11.2.0/include -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0 -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/x86_64-pc-linux-gnu -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/backward -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0 -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/x86_64-pc-linux-gnu -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../include/c++/11.2.0/backward -internal-isystem /p/project/cjinb33/kitayama1/dev/clang/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /p/software/jurecadc/stages/2022/software/CUDA/11.5/include -internal-isystem /p/project/cjinb33/kitayama1/dev/clang/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /p/software/jurecadc/stages/2022/software/GCCcore/11.2.0/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unknown-cuda-version -Wall -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/p/scratch/cjinb33/kitayama1/build/nest-clang-offload/models -ferror-limit 19 -fvisibility protected -fopenmp -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -fopenmp-is-device -fopenmp-host-ir-file-path /tmp/modelsmodule-6e1002.bc -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/modelsmodule-937850.s -x c++ /p/scratch/cjinb33/kitayama1/projects/nest-simulator/models/modelsmodule.cpp
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '/p/scratch/cjinb33/kitayama1/projects/nest-simulator/models/modelsmodule.cpp'.
4. Running pass 'NVPTX DAG->DAG Pattern Instruction Selection' on function '@_ZNK4nest9ConnectorINS_11GapJunctionINS_24TargetIdentifierPtrRportEEEE19get_target_node_idsEimRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorImNSt3pmr21polymorphic_allocatorImEEE'
#0 0x0000000002feeb71 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x0000000002fec494 SignalHandler(int) Signals.cpp:0:0
#2 0x00001526a4979c20 __restore_rt sigaction.c:0:0
#3 0x0000000000962dee llvm::NVPTXTargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const (.cold) NVPTXISelLowering.cpp:0:0
#4 0x0000000003f45a4a llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3f45a4a)
#5 0x0000000003f4992f llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3f4992f)
#6 0x0000000003f588ab llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3f588ab)
#7 0x0000000003f83410 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3f83410)
#8 0x0000000003f83a3f llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3f83a3f)
#9 0x0000000003fef766 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, bool&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3fef766)
#10 0x0000000003ff0c08 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3ff0c08)
#11 0x0000000003ff31a2 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#12 0x00000000023563b4 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#13 0x00000000027e1360 llvm::FPPassManager::runOnFunction(llvm::Function&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x27e1360)
#14 0x00000000027e14cc llvm::FPPassManager::runOnModule(llvm::Module&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x27e14cc)
#15 0x00000000027e1e4f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x27e1e4f)
#16 0x000000000335c585 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>>) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x335c585)
#17 0x0000000004122ff1 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) crtstuff.c:0:0
#18 0x0000000004c41189 clang::ParseAST(clang::Sema&, bool, bool) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x4c41189)
#19 0x0000000003a9ff59 clang::FrontendAction::Execute() (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3a9ff59)
#20 0x0000000003a2ed3b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3a2ed3b)
#21 0x0000000003b555a0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0x3b555a0)
#22 0x0000000000a70ea4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0xa70ea4)
#23 0x0000000000a6a615 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#24 0x0000000000a6c9a6 clang_main(int, char**) (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0xa6c9a6)
#25 0x00001526a3c0b493 __libc_start_main (/usr/lib64/libc.so.6+0x23493)
#26 0x0000000000a69dbe _start (/p/project/cjinb33/kitayama1/dev/clang/bin/clang-16+0xa69dbe)
clang-16: error: unable to execute command: Segmentation fault
clang-16: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 16.0.0 (https://github.com/llvm/llvm-project 3bba12a81e242359580fa322cf1a9a0a43b461e6)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /p/project/cjinb33/kitayama1/dev/clang/bin
clang-16: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16: note: diagnostic msg: /tmp/modelsmodule-320c90.cpp
clang-16: note: diagnostic msg: /tmp/modelsmodule-20e30e.cpp
clang-16: note: diagnostic msg: /tmp/modelsmodule-320c90.sh
clang-16: note: diagnostic msg:
********************
modelsmodule-320c90.sh.gz [modelsmodule-320c90.cpp.gz](https://github.com/llvm/llv modelsmodule-20e30e.cpp.gz m-project/files/9313440/modelsmodule-320c90.cpp.gz)
May I ask you @jdoerfert to take a look at this issue if possible, as this is a show stopper? Thanks!
Can you provide the original source input? It'll probably be easier to work with than 300,000 lines of post-preprocessed C++. LLVM-IR would also be very helpful. If you run with -save-temps
you should be able to find the LLVM-IR that causes the problem in the back-end. Then we should be able to reduce and reproduce it using llc
.
If you can reproduce the issue on godbolt.org, that would be very helpful.
@jhuber6 here it is:
https://github.com/ikitayama/nest-simulator/blob/spike_counter_debug/models/modelsmodule.cpp
Was there anything else printed out by the compiler before the stack trace? E.g. any assertion failures?
The easier it is to reproduce the issue the higher the chance that someone will look at it sooner.
https://github.com/ikitayama/nest-simulator/blob/spike_counter_debug/models/modelsmodule.cpp
That's still a lot of code which can't be compiled w/o figuring out how to build that project. The smaller the reproducer the higher your chances that someone will be willing and able to deal with the bug. If you can reproduce it on something that can be compiled all by itself, without the whole source tree, that would help a lot. There are tools that can help automating the process: https://gcc.gnu.org/wiki/A_guide_to_testcase_reduction
I’ll try to come up with a rminimal reproducer.
I've found in my codebase a problematic pragma, but still don't understand why this causes the crash.
I no longer see the segfaults with the latest Clang, closing this Issue.