| Issue |
75896
|
| Summary |
[Clang][OpenMP] Clang crashes because of no captured stmt info
|
| Labels |
clang:openmp
|
| Assignees |
|
| Reporter |
shiltian
|
https://godbolt.org/z/EYYhEz453
The small reproducer is:
```
#include <omp.h>
void test_omp_aligned_alloc_on_device() {
omp_alloctrait_t traits[2];
omp_allocator_handle_t alloc;
#pragma omp target uses_allocators(alloc(traits))
{
omp_allocator_handle_t new_alloc = alloc;
}
}
```
The key point is `uses_allocators(alloc(traits))`. Removing it can get rid of the crash.
```
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: /opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18 -cc1 -triple nvptx64-nvidia-cuda -aux-triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -ffp-contract=on -fno-rounding-math -no-integrated-as -target-cpu sm_75 -target-feature +ptx42 -debug-info-kind=constructor -dwarf-version=2 -debugger-tuning=gdb -fno-dwarf-directory-asm -fdebug-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20231218/lib/clang/18 -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20231218/lib/clang/18/include/llvm_libc_wrappers -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20231218/lib/clang/18/include/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0/backward -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../include/c++/14.0.0/backward -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20231218/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20231218/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/14.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fvisibility=protected -fopenmp -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -fopenmp-is-target-device -fopenmp-host-ir-file-path /tmp/example-1bdfd4.bc -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-sm_75-f4dcc0.s -x c++ <source>
1. <eof> parser at end of file
2. <source>:3:6: LLVM IR generation of declaration 'test_omp_aligned_alloc_on_device'
3. <source>:8:3: LLVM IR generation of compound statement ('{}')
#0 0x00000000037cc328 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x37cc328)
#1 0x00000000037c9a7c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f0600c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x0000000003a495a0 clang::Decl::getDeclContext() (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3a495a0)
#4 0x0000000003ecb908 clang::CodeGen::CodeGenFunction::EmitLValueForLambdaField(clang::FieldDecl const*, llvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3ecb908)
#5 0x0000000003ed910f clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3ed910f)
#6 0x0000000003ed57a1 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3ed57a1)
#7 0x0000000003edfe92 clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3edfe92)
#8 0x0000000003f28ca0 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) CGExprScalar.cpp:0:0
#9 0x0000000003f24355 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#10 0x0000000003f245ab (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#11 0x0000000003f295fb (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#12 0x0000000003f22b72 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#13 0x0000000003f2869c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3f2869c)
#14 0x0000000003e8d05f clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3e8d05f)
#15 0x0000000003e8e6f8 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3e8e6f8)
#16 0x0000000003e996e3 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3e996e3)
#17 0x0000000003e9af46 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#18 0x0000000003e9b1e0 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3e9b1e0)
#19 0x0000000003adcf17 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3adcf17)
#20 0x0000000003af0f87 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3af0f87)
#21 0x0000000003aea365 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3aea365)
#22 0x0000000003af08bc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3af08bc)
#23 0x0000000003af0ca4 clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3af0ca4)
#24 0x0000000003af0eae clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3af0eae)
#25 0x0000000003aea365 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3aea365)
#26 0x0000000003b22d0b emitTargetRegion(clang::CodeGen::CodeGenFunction&, clang::OMPTargetDirective const&, clang::CodeGen::PrePostActionTy&) CGStmtOpenMP.cpp:0:0
#27 0x0000000003fc014a clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3fc014a)
#28 0x0000000003fc0484 (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) CGOpenMPRuntime.cpp:0:0
#29 0x0000000003b3d033 clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt const&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3b3d033)
#30 0x0000000003ff6e72 std::_Function_handler<llvm::Function* (llvm::StringRef), clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&)::'lambda'(llvm::StringRef)>::_M_invoke(std::_Any_data const&, llvm::StringRef&&) CGOpenMPRuntime.cpp:0:0
#31 0x00000000076bf109 llvm::OpenMPIRBuilder::emitTargetRegionFunction(llvm::TargetRegionEntryInfo&, std::function<llvm::Function* (llvm::StringRef)>&, bool, llvm::Function*&, llvm::Constant*&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x76bf109)
#32 0x0000000003fbb870 clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3fbb870)
#33 0x000000000402693e clang::CodeGen::CGOpenMPRuntimeGPU::emitNonSPMDKernel(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x402693e)
#34 0x0000000004026dab clang::CodeGen::CGOpenMPRuntimeGPU::emitTargetOutlinedFunction(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x4026dab)
#35 0x0000000003afa995 clang::CodeGen::CodeGenFunction::EmitOMPTargetDeviceFunction(clang::CodeGen::CodeGenModule&, llvm::StringRef, clang::OMPTargetDirective const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3afa995)
#36 0x0000000003fd5efb clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt const*, llvm::StringRef) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3fd5efb)
#37 0x0000000003fd5db2 clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt const*, llvm::StringRef) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3fd5db2)
#38 0x0000000003fd62f5 clang::CodeGen::CGOpenMPRuntime::emitTargetFunctions(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3fd62f5)
#39 0x0000000003bbf989 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x3bbf989)
#40 0x0000000003bc9a23 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#41 0x00000000040491b6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#42 0x000000000403a2c8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x403a2c8)
#43 0x0000000005fc0714 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x5fc0714)
#44 0x0000000004046dd8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x4046dd8)
#45 0x00000000042b2a09 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x42b2a09)
#46 0x0000000004231a9e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x4231a9e)
#47 0x0000000004391fbe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0x4391fbe)
#48 0x0000000000c04756 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0xc04756)
#49 0x0000000000bfc01a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#50 0x0000000000c013b4 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0xc013b4)
#51 0x0000000000afac21 main (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0xafac21)
#52 0x00007f0600c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#53 0x00007f0600c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#54 0x0000000000bfbafe _start (/opt/compiler-explorer/clang-assertions-trunk-20231218/bin/clang-18+0xbfbafe)
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 254
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs