CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
228 stars 34 forks source link

[hipCUB] test_hipcub_block_histogram crashes at build (InferAddressSpaces) #397

Open pjaaskel opened 1 year ago

pjaaskel commented 1 year ago

Steps to repro:

diff --git a/test/hipcub/CMakeLists.txt b/test/hipcub/CMakeLists.txt
index 44ffdb7..52382cb 100644
--- a/test/hipcub/CMakeLists.txt
+++ b/test/hipcub/CMakeLists.txt
@@ -195,7 +195,7 @@ add_hipcub_test("hipcub.CachingDeviceAllocator" test_hipcub_caching_device_alloc
 add_hipcub_test("hipcub.BlockAdjacentDifference" test_hipcub_block_adjacent_difference.cpp)
 add_hipcub_test("hipcub.BlockDiscontinuity" test_hipcub_block_discontinuity.cpp)
 add_hipcub_test("hipcub.BlockExchange" test_hipcub_block_exchange.cpp)
-#add_hipcub_test("hipcub.BlockHistogram" test_hipcub_block_histogram.cpp)
+add_hipcub_test("hipcub.BlockHistogram" test_hipcub_block_histogram.cpp)

Should crash with the backtrace:

[ 11%] Building CXX object test/hipcub/CMakeFiles/test_hipcub_block_histogram.dir/test_hipcub_block_histogram.cpp.o
clang-15: warning: -Wl,-rpath,/usr/lib/x86_64-linux-gnu: 'linker' input unused [-Wunused-command-line-argument]
opt: /home/pjaaskel/src/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::Constant; From = llvm::Value]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /home/pjaaskel/local/stow/llvm-15-cspv-patched-relwdebuginfo/bin/opt /tmp/test_hipcub_block_histogram-generic-link-ffe29c.bc -load-pass-plugin /home/pjaaskel/local/stow/chip-spv/lib/llvm/libLLVMHipSpvPasses.so -passes=hip-post-link-passes -o /tmp/test_hipcub_block_histogram-generic-lower-a64063.bc
 #0 0x00007f510dc99d76 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/pjaaskel/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:3
 #1 0x00007f510dc97df4 llvm::sys::RunSignalHandlers() /home/pjaaskel/src/llvm-project/llvm/lib/Support/Signals.cpp:103:20
 #2 0x00007f510dc97f96 SignalHandler(int) /home/pjaaskel/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #3 0x00007f510cc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f510cc96a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f510cc96a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f510cc96a7c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f510cc42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f510cc287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f510cc2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f510cc39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007f510eec4262 llvm::CallBase::setOperand(unsigned int, llvm::Value*) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/InstrTypes.h:2364:1
#12 0x00007f510eec4262 llvm::CallBase::setOperand(unsigned int, llvm::Value*) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/InstrTypes.h:2364:1
#13 0x00007f510eec4262 llvm::CallBase::setArgOperand(unsigned int, llvm::Value*) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/InstrTypes.h:1348:15
#14 0x00007f510eec4262 rewriteIntrinsicOperands /home/pjaaskel/src/llvm-project/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:369:22
#15 0x00007f510eec4262 (anonymous namespace)::InferAddressSpacesImpl::rewriteWithNewAddressSpaces(llvm::ArrayRef<llvm::WeakTrackingVH>, llvm::DenseMap<llvm::Value const*, unsigned int, llvm::DenseMapInfo<llvm::Value const*, void>, llvm::detail::DenseMapPair<llvm::Value const*, unsigned int>> const&, llvm::DenseMap<std::pair<llvm::Value const*, llvm::Value const*>, unsigned int, llvm::DenseMapInfo<std::pair<llvm::Value const*, llvm::Value const*>, void>, llvm::detail::DenseMapPair<std::pair<llvm::Value const*, llvm::Value const*>, unsigned int>> const&, llvm::Function*) const (.constprop.0) /home/pjaaskel/src/llvm-project/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:1200:37
#16 0x00007f510eec514b llvm::DenseMap<std::pair<llvm::Value const*, llvm::Value const*>, unsigned int, llvm::DenseMapInfo<std::pair<llvm::Value const*, llvm::Value const*>, void>, llvm::detail::DenseMapPair<std::pair<llvm::Value const*, llvm::Value const*>, unsigned int>>::~DenseMap() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/DenseMap.h:757:22
#17 0x00007f510eec514b (anonymous namespace)::InferAddressSpacesImpl::run(llvm::Function&) (.constprop.0) /home/pjaaskel/src/llvm-project/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:827:1
#18 0x00007f510eec6507 llvm::InferAddressSpacesPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/pjaaskel/src/llvm-project/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:1323:3
#19 0x00007f51104bb796 llvm::detail::PassModel<llvm::Function, llvm::InferAddressSpacesPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:3
#20 0x00007f510de6e5ce llvm::SmallPtrSet<void*, 2u>::operator=(llvm::SmallPtrSet<void*, 2u>&&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:489:21
#21 0x00007f510de6e5ce llvm::PreservedAnalyses::operator=(llvm::PreservedAnalyses&&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/PassManager.h:152:7
#22 0x00007f510de6e5ce llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/pjaaskel/src/llvm-project/llvm/lib/IR/PassManager.cpp:127:32
#23 0x00007f51104bdbd6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:89:3
#24 0x00007f510de6c181 llvm::SmallPtrSet<void*, 2u>::operator=(llvm::SmallPtrSet<void*, 2u>&&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:489:21
#25 0x00007f510de6c181 llvm::PreservedAnalyses::operator=(llvm::PreservedAnalyses&&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/PassManager.h:152:7
#26 0x00007f510de6c181 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/PassManager.h:522:16
#27 0x0000558007adb830 llvm::SmallPtrSetImplBase::isSmall() const /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:195:33
#28 0x0000558007adb830 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:83:17
#29 0x0000558007adb830 llvm::SmallPtrSetImpl<llvm::AnalysisKey*>::~SmallPtrSetImpl() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:344:7
#30 0x0000558007adb830 llvm::SmallPtrSet<llvm::AnalysisKey*, 2u>::~SmallPtrSet() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:450:7
#31 0x0000558007adb830 llvm::PreservedAnalyses::~PreservedAnalyses() /home/pjaaskel/src/llvm-project/llvm/include/llvm/IR/PassManager.h:152:7
#32 0x0000558007adb830 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) /home/pjaaskel/src/llvm-project/llvm/tools/opt/NewPMDriver.cpp:525:10
#33 0x0000558007ace6fb llvm::SmallVectorTemplateCommon<llvm::StringRef, void>::begin() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:249:45
#34 0x0000558007ace6fb llvm::SmallVectorTemplateCommon<llvm::StringRef, void>::end() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:251:32
#35 0x0000558007ace6fb llvm::SmallVector<llvm::StringRef, 4u>::~SmallVector() /home/pjaaskel/src/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1192:24
#36 0x0000558007ace6fb main /home/pjaaskel/src/llvm-project/llvm/tools/opt/opt.cpp:790:3
#37 0x00007f510cc29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#38 0x00007f510cc29e40 call_init ./csu/../csu/libc-start.c:128:20
#39 0x00007f510cc29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#40 0x0000558007acedb5 _start (/home/pjaaskel/local/stow/llvm-15-cspv-patched-relwdebuginfo/bin/opt+0x1ddb5)
clang-15: error: unable to execute command: Aborted (core dumped)
clang-15: error: hipspv-link command failed due to signal (use -v to see invocation)
clang version 15.0.6 (git@github.com:CHIP-SPV/llvm-project.git 31233417513505db770574f3857f090cdcea3828)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/pjaaskel/local/stow/llvm-15-cspv-patched-relwdebuginfo/bin
clang-15: note: diagnostic msg: Error generating preprocessed source(s).

failed to execute:/home/pjaaskel/local/stow/llvm-15-cspv-patched-relwdebuginfo/bin/clang++ -D__HIP_PLATFORM_SPIRV__= -D__HIP_PLATFORM_SPIRV__= -Xclang -no-opaque-pointers --offload=spirv64 -nohipwrapperinc --hip-path=/home/pjaaskel/local/stow/chip-spv --target=x86_64-unknown-linux-gnu -include /home/pjaaskel/local/stow/chip-spv/include/hip/spirv_fixups.h -isystem "/home/pjaaskel/local/stow/chip-spv/include" -x hip --target=x86_64-linux-gnu -I//home/pjaaskel/local/stow/chip-spv/include -DGTEST_LINKED_AS_SHARED_LIBRARY=1 -I/home/pjaaskel/src/hipCUB/build/hipcub/cub/include -I/home/pjaaskel/src/hipCUB/build/hipcub/cub/include/hipcub -I/home/pjaaskel/src/hipCUB/hipcub/include -isystem /home/pjaaskel/src/hipCUB/build/gtest/include -isystem /home/pjaaskel/src/hipCUB/build/deps/rocprim/include -isystem /home/pjaaskel/local/stow/chip-spv/include/cuspv -O3 -DNDEBUG -x hip -Xclang -no-opaque-pointers -nohipwrapperinc --hip-path=/home/pjaaskel/local/stow/chip-spv -include /home/pjaaskel/local/stow/chip-spv/include/hip/spirv_fixups.h -Wl,-rpath,/usr/lib/x86_64-linux-gnu -std=c++14 -MD -MT test/hipcub/CMakeFiles/test_hipcub_block_histogram.dir/test_hipcub_block_histogram.cpp.o -MF CMakeFiles/test_hipcub_block_histogram.dir/test_hipcub_block_histogram.cpp.o.d -o CMakeFiles/test_hipcub_block_histogram.dir/test_hipcub_block_histogram.cpp.o -c /home/pjaaskel/src/hipCUB/test/hipcub/test_hipcub_block_histogram.cpp

rocPRIM's test_block_histogram reproduces this issue (hipCUB likely just delegates to it).

pvelesko commented 2 weeks ago

Fails during llvm -> SPIR-V step now https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2823