llvm-project
llvm-project copied to clipboard
[AMDGPU] Segmentation fault in `CGNVCUDARuntime::finalizeModule()` during IR generation
Compiling the attached HIP program causes a segmentation fault in the Clang frontend.
Test File: HIPProg.hip
How to reproduce:
clang++ -x hip HIPProg.hip --offload-arch=native
Stack dump:
0. Program arguments: ... clang-23 -cc1 -triple x86_64-unknown-linux-gnu -aux-triple amdgcn-amd-amdhsa -O3 ...
1. <eof> parser at end of file
2. Per-file LLVM IR generation
#0 0x0000742d80c5e41b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
...
#4 0x0000742d80ce15a8 llvm::SymbolTableListTraits<llvm::Instruction, llvm::ilist_iterator_bits<true>, llvm::ilist_parent<llvm::BasicBlock>>::addNodeToList(llvm::Instruction*)
#5 0x0000742d80e04f32 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::User::AllocInfo, llvm::InsertPosition)
#6 0x0000742d80e10021 llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*, llvm::Twine const&, bool, llvm::Align, llvm::InsertPosition)
#7 0x0000742d89af882b (anonymous namespace)::CGNVCUDARuntime::finalizeModule() CGCUDANV.cpp:0:0
#8 0x0000742d89f00166 clang::CodeGen::CodeGenModule::Release()
#9 0x0000742d89f8dcfd (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#10 0x0000742d89e89495 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
...
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed with exit code -2 (use -v to see invocation)
tagging @mgcarrasco who is working on it
@llvm/issue-subscribers-backend-amdgpu
Author: ElliotBLabs
Compiling the attached HIP program causes a segmentation fault in the Clang frontend.
Test File: HIPProg.hip
How to reproduce:
clang++ -x hip HIPProg.hip --offload-arch=native
Stack dump:
0. Program arguments: ... clang-23 -cc1 -triple x86_64-unknown-linux-gnu -aux-triple amdgcn-amd-amdhsa -O3 ...
1. <eof> parser at end of file
2. Per-file LLVM IR generation
#<!-- -->0 0x0000742d80c5e41b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
...
#<!-- -->4 0x0000742d80ce15a8 llvm::SymbolTableListTraits<llvm::Instruction, llvm::ilist_iterator_bits<true>, llvm::ilist_parent<llvm::BasicBlock>>::addNodeToList(llvm::Instruction*)
#<!-- -->5 0x0000742d80e04f32 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::User::AllocInfo, llvm::InsertPosition)
#<!-- -->6 0x0000742d80e10021 llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*, llvm::Twine const&, bool, llvm::Align, llvm::InsertPosition)
#<!-- -->7 0x0000742d89af882b (anonymous namespace)::CGNVCUDARuntime::finalizeModule() CGCUDANV.cpp:0:0
#<!-- -->8 0x0000742d89f00166 clang::CodeGen::CodeGenModule::Release()
#<!-- -->9 0x0000742d89f8dcfd (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#<!-- -->10 0x0000742d89e89495 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
...
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed with exit code -2 (use -v to see invocation)
</details>
I can confirm the issue and crash with commit 3e20d3d3964a3a6ac5f882842c7716e2682d622f.
Just to add on this. The following version doesn't crash:
void hipsmith_kernel() {
//S0 c_1938{&hip_managed_2};
S0 c_1938;
c_1938.g_1690 = &hip_managed_2;
}
@llvm/issue-subscribers-clang-frontend
Author: ElliotBLabs
Compiling the attached HIP program causes a segmentation fault in the Clang frontend.
Test File: HIPProg.hip
How to reproduce:
clang++ -x hip HIPProg.hip --offload-arch=native
Stack dump:
0. Program arguments: ... clang-23 -cc1 -triple x86_64-unknown-linux-gnu -aux-triple amdgcn-amd-amdhsa -O3 ...
1. <eof> parser at end of file
2. Per-file LLVM IR generation
#<!-- -->0 0x0000742d80c5e41b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
...
#<!-- -->4 0x0000742d80ce15a8 llvm::SymbolTableListTraits<llvm::Instruction, llvm::ilist_iterator_bits<true>, llvm::ilist_parent<llvm::BasicBlock>>::addNodeToList(llvm::Instruction*)
#<!-- -->5 0x0000742d80e04f32 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::User::AllocInfo, llvm::InsertPosition)
#<!-- -->6 0x0000742d80e10021 llvm::LoadInst::LoadInst(llvm::Type*, llvm::Value*, llvm::Twine const&, bool, llvm::Align, llvm::InsertPosition)
#<!-- -->7 0x0000742d89af882b (anonymous namespace)::CGNVCUDARuntime::finalizeModule() CGCUDANV.cpp:0:0
#<!-- -->8 0x0000742d89f00166 clang::CodeGen::CodeGenModule::Release()
#<!-- -->9 0x0000742d89f8dcfd (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#<!-- -->10 0x0000742d89e89495 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
...
clang++: error: unable to execute command: Segmentation fault (core dumped)
clang++: error: clang frontend command failed with exit code -2 (use -v to see invocation)
</details>