clspv
clspv copied to clipboard
ReplacePointerBitcastPass crashes on "Invalid cast!" assertion
The following LLVM IR results in a crash when running clspv or clspv-opt.
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir-unknown-unknown"
%TYPE = type { <4 x float> }
define dso_local spir_kernel void @test() {
%x = bitcast %TYPE* undef to <4 x float>*
%y = load <4 x float>, <4 x float>* %x, align 16
unreachable
}
Commands:
clspv -x ir invalid-cast.ll -o /dev/null
clspv-opt invalid-cast.ll -o /dev/null -ReplacePointerBitcast
Crash reported by clspv-opt:
clspv-opt: /clspv/third_party/llvm/llvm/lib/IR/Instructions.cpp:2947: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: clspv-opt bugreports/invalid-cast.ll -o /dev/null -ReplacePointerBitcast
1. Running pass 'Replace Pointer Bitcast Pass' on module 'bugreports/invalid-cast.ll'.
#0 0x00007fc4791fe744 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /clspv/third_party/llvm/llvm/lib/Support/Unix/Signals.inc:565:0
#1 0x00007fc4791fe7fb PrintStackTraceSignalHandler(void*) /clspv/third_party/llvm/llvm/lib/Support/Unix/Signals.inc:632:0
#2 0x00007fc4791fc4af llvm::sys::RunSignalHandlers() /clspv/third_party/llvm/llvm/lib/Support/Signals.cpp:71:0
#3 0x00007fc4791fe0c5 SignalHandler(int) /clspv/third_party/llvm/llvm/lib/Support/Unix/Signals.inc:407:0
#4 0x00007fc47833b040 (/lib/x86_64-linux-gnu/libc.so.6+0x3f040)
#5 0x00007fc47833afb7 raise /build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#6 0x00007fc47833c921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
#7 0x00007fc47832c48a __assert_fail_base /build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
#8 0x00007fc47832c502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
#9 0x00007fc479a40b7a llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*) /clspv/third_party/llvm/llvm/lib/IR/Instructions.cpp:2947:0
#10 0x000055833d78f51b llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&) /clspv/third_party/llvm/llvm/include/llvm/IR/IRBuilder.h:2109:0
#11 0x000055833d78f448 llvm::IRBuilderBase::CreateBitCast(llvm::Value*, llvm::Type*, llvm::Twine const&) /clspv/third_party/llvm/llvm/include/llvm/IR/IRBuilder.h:2069:0
#12 0x000055833d861bbb (anonymous namespace)::ReplacePointerBitcastPass::runOnModule(llvm::Module&) /clspv/lib/ReplacePointerBitcastPass.cpp:955:0
#13 0x00007fc479a87cbd (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /clspv/third_party/llvm/llvm/lib/IR/LegacyPassManager.cpp:1554:0
#14 0x00007fc479a82d89 llvm::legacy::PassManagerImpl::run(llvm::Module&) /clspv/third_party/llvm/llvm/lib/IR/LegacyPassManager.cpp:542:0
#15 0x00007fc479a88547 llvm::legacy::PassManager::run(llvm::Module&) /clspv/third_party/llvm/llvm/lib/IR/LegacyPassManager.cpp:1682:0
#16 0x000055833d890a31 main /clspv/tools/clspv-opt/main.cpp:126:0
#17 0x00007fc47831dbf7 __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#18 0x000055833d758c6a _start (/build_shared_debug/bin/clspv-opt+0x4dc6a)
fish: Process 42160, “clspv-opt” “clspv-opt bugreports/invalid-ca…” terminated by signal SIGABRT (Abort)
This is fixed with https://github.com/google/clspv/pull/846 (might already be fixed in main)