Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenMP offloading crashes when using AMDGPU #53559

Closed
jhuber6 opened this issue Feb 2, 2022 · 8 comments
Closed

OpenMP offloading crashes when using AMDGPU #53559

jhuber6 opened this issue Feb 2, 2022 · 8 comments

Comments

@jhuber6
Copy link
Contributor

jhuber6 commented Feb 2, 2022

Compiling XSBench with LLVM 14 crashes during optimizations. Flags were -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -O3

clang-14: /ccs/home/jhuber/llvm/llvm-project/llvm/include/llvm/ADT/APInt.h:990: bool llvm::APInt::operator==(const llvm::APInt&) const: Assertion `BitWidth == RHS.BitWidth && "Comparison requires equal bit widths"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /autofs/nccs-svm1_home1/jhuber/clang/bin/clang-14 -cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists -disable-free -clear-ast-before-backend -main-file-name Simulation.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu gfx908 -fcuda-is-device -mlink-builtin-bitcode /autofs/nccs-svm1_home1/jhuber/clang/lib/libomptarget-new-amdgpu-gfx908.bc -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -resource-dir /autofs/nccs-svm1_home1/jhuber/clang/lib/clang/14.0.0 -internal-isystem /autofs/nccs-svm1_home1/jhuber/clang/lib/clang/14.0.0/include/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem /autofs/nccs-svm1_home1/jhuber/clang/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /autofs/nccs-svm1_home1/jhuber/clang/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Rpass=openmp-opt -Wall -std=gnu99 -fdebug-compilation-dir=/ccs/home/jhuber/XSBench/openmp-offload -ferror-limit 19 -fvisibility protected -fopenmp -fopenmp-target-new-runtime -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -fopenmp-is-device -fopenmp-host-ir-file-path /tmp/Simulation-88ab3e.bc -faddrsig -o /tmp/Simulation-7b18af.bc -x c Simulation.c
1.	<eof> parser at end of file
2.	Optimizer
 #0 0x00007f5d7f294b5f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00007f5d7f292409 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f5d8942b2d0 __restore_rt (/lib64/libpthread.so.0+0x132d0)
 #3 0x00007f5d7e40e420 raise (/lib64/libc.so.6+0x39420)
 #4 0x00007f5d7e40fa01 abort (/lib64/libc.so.6+0x3aa01)
 #5 0x00007f5d7e406a1a __assert_fail_base (/lib64/libc.so.6+0x31a1a)
 #6 0x00007f5d7e406a92 (/lib64/libc.so.6+0x31a92)
 #7 0x00007f5d80e6b3d0 llvm::ObjectSizeOffsetVisitor::visitGlobalAlias(llvm::GlobalAlias&) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x2fe3d0)
 #8 0x00007f5d80e6ac65 llvm::InstVisitor<llvm::ObjectSizeOffsetVisitor, std::pair<llvm::APInt, llvm::APInt> >::visit(llvm::Instruction&) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x2fdc65)
 #9 0x00007f5d80e6ae60 llvm::ObjectSizeOffsetVisitor::compute(llvm::Value*) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x2fde60)
#10 0x00007f5d80e6b750 llvm::getObjectSize(llvm::Value const*, unsigned long&, llvm::DataLayout const&, llvm::TargetLibraryInfo const*, llvm::ObjectSizeOpts) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x2fe750)
#11 0x00007f5d820622a4 (anonymous namespace)::DSEState::isOverwrite(llvm::Instruction const*, llvm::Instruction const*, llvm::MemoryLocation const&, llvm::MemoryLocation const&, long&, long&) DeadStoreElimination.cpp:0:0
#12 0x00007f5d82067a3a (anonymous namespace)::DSEState::getDomMemoryDef(llvm::MemoryDef*, llvm::MemoryAccess*, llvm::MemoryLocation const&, llvm::Value const*, unsigned int&, unsigned int&, bool, unsigned int&) DeadStoreElimination.cpp:0:0
#13 0x00007f5d8206961a (anonymous namespace)::eliminateDeadStores(llvm::Function&, llvm::AAResults&, llvm::MemorySSA&, llvm::DominatorTree&, llvm::PostDominatorTree&, llvm::TargetLibraryInfo const&, llvm::LoopInfo const&) DeadStoreElimination.cpp:0:0
#14 0x00007f5d8206bec5 llvm::DSEPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/ccs/home/jhuber/clang/lib/libLLVMScalarOpts.so.14git+0xd3ec5)
#15 0x00007f5d7cd7a75d llvm::detail::PassModel<llvm::Function, llvm::DSEPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/ccs/home/jhuber/clang/lib/libLLVMPasses.so.14git+0x5d75d)
#16 0x00007f5d8010796c llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/ccs/home/jhuber/clang/lib/libLLVMCore.so.14git+0x27096c)
#17 0x00007f5d94eca1dd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/ccs/home/jhuber/clang/lib/libLLVMAMDGPUCodeGen.so.14git+0x25a1dd)
#18 0x00007f5d80cc5736 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x158736)
#19 0x00007f5d94ecacdd llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/ccs/home/jhuber/clang/lib/libLLVMAMDGPUCodeGen.so.14git+0x25acdd)
#20 0x00007f5d80cbe775 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x151775)
#21 0x00007f5d83fd109d llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/ccs/home/jhuber/clang/lib/libLLVMipo.so.14git+0x1a309d)
#22 0x00007f5d80cc1a50 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x154a50)
#23 0x00007f5d83fd107d llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/ccs/home/jhuber/clang/lib/libLLVMipo.so.14git+0x1a307d)
#24 0x00007f5d80cc00bf llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/ccs/home/jhuber/clang/lib/libLLVMAnalysis.so.14git+0x1530bf)
#25 0x00007f5d83fd10bd llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/ccs/home/jhuber/clang/lib/libLLVMipo.so.14git+0x1a30bd)
#26 0x00007f5d80105c12 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/ccs/home/jhuber/clang/lib/libLLVMCore.so.14git+0x26ec12)
#27 0x00007f5d83fd6008 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/ccs/home/jhuber/clang/lib/libLLVMipo.so.14git+0x1a8008)
#28 0x00007f5d7cd7b1ed llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/ccs/home/jhuber/clang/lib/libLLVMPasses.so.14git+0x5e1ed)
#29 0x00007f5d80105c12 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/ccs/home/jhuber/clang/lib/libLLVMCore.so.14git+0x26ec12)
#30 0x00007f5d852e5192 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile> >&) (.constprop.836) BackendUtil.cpp:0:0
#31 0x00007f5d852e80d4 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> >) (/ccs/home/jhuber/clang/lib/libclangCodeGen.so.14git+0xf30d4)
#32 0x00007f5d85660dc0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/ccs/home/jhuber/clang/lib/libclangCodeGen.so.14git+0x46bdc0)
#33 0x00007f5d7881bfa9 clang::ParseAST(clang::Sema&, bool, bool) (/ccs/home/jhuber/clang/lib/libclangParse.so.14git+0x35fa9)
#34 0x00007f5d8565f900 clang::CodeGenAction::ExecuteAction() (/ccs/home/jhuber/clang/lib/libclangCodeGen.so.14git+0x46a900)
#35 0x00007f5d83367371 clang::FrontendAction::Execute() (/ccs/home/jhuber/clang/lib/libclangFrontend.so.14git+0x144371)
#36 0x00007f5d832d7f22 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/ccs/home/jhuber/clang/lib/libclangFrontend.so.14git+0xb4f22)
#37 0x00007f5d8921556b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/ccs/home/jhuber/clang/lib/libclangFrontendTool.so.14git+0x456b)
#38 0x00000000004171d9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/autofs/nccs-svm1_home1/jhuber/clang/bin/clang-14+0x4171d9)
#39 0x0000000000413139 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#40 0x000000000040feb9 main (/autofs/nccs-svm1_home1/jhuber/clang/bin/clang-14+0x40feb9)
#41 0x00007f5d7e3f934a __libc_start_main (/lib64/libc.so.6+0x2434a)
#42 0x0000000000412d0a _start /home/abuild/rpmbuild/BUILD/glibc-2.26/csu/../sysdeps/x86_64/start.S:122:0
@jhuber6 jhuber6 added the openmp label Feb 2, 2022
@llvmbot
Copy link
Member

llvmbot commented Feb 2, 2022

@llvm/issue-subscribers-openmp

@jdoerfert
Copy link
Member

@jhuber6 This is still a problem in 14, right? We never merged the fix.

@jhuber6
Copy link
Contributor Author

jhuber6 commented Feb 15, 2022

Yes, it was fixed by 29c8eba so we should be able to cherry pick that right.

@jdoerfert
Copy link
Member

/cherry-pick 29c8eba

@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2022

/branch llvmbot/llvm-project/issue53559

llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Feb 15, 2022
Use existing functionality to strip constant offsets that works well
with AS casts and avoids the code duplication.

Since we strip AS casts during the computation of the offset we also
need to adjust the APInt properly to avoid mismatches in the bit width.
This code ensures the caller of `compute` sees APInts that match the
index type size of the value passed to `compute`, not the value result
of the strip pointer cast.

Fixes llvm#53559.

Differential Revision: https://reviews.llvm.org/D118727

(cherry picked from commit 29c8eba)
@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2022

/pull-request llvmbot#66

@tstellar
Copy link
Collaborator

@arsenm What do you think about backporting this? 29c8eba

@arsenm
Copy link
Contributor

arsenm commented Feb 16, 2022

I think it's fine to backport

tstellar pushed a commit to llvmbot/llvm-project that referenced this issue Feb 21, 2022
Use existing functionality to strip constant offsets that works well
with AS casts and avoids the code duplication.

Since we strip AS casts during the computation of the offset we also
need to adjust the APInt properly to avoid mismatches in the bit width.
This code ensures the caller of `compute` sees APInts that match the
index type size of the value passed to `compute`, not the value result
of the strip pointer cast.

Fixes llvm#53559.

Differential Revision: https://reviews.llvm.org/D118727

(cherry picked from commit 29c8eba)
jdoerfert added a commit to jdoerfert/llvm-project that referenced this issue Mar 25, 2022
Use existing functionality to strip constant offsets that works well
with AS casts and avoids the code duplication.

Since we strip AS casts during the computation of the offset we also
need to adjust the APInt properly to avoid mismatches in the bit width.
This code ensures the caller of `compute` sees APInts that match the
index type size of the value passed to `compute`, not the value result
of the strip pointer cast.

Fixes llvm#53559.

Differential Revision: https://reviews.llvm.org/D118727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants