clspv
clspv copied to clipboard
clspv crashes when code contains function declaration
The following OpenCL C code results in a crash because foo is not defined.
void foo(void);
kernel void bar() {
foo();
}
I'm not sure whether this should be supported by clspv or not.
Here is the error:
; Function Attrs: convergent
declare spir_func void @foo() local_unnamed_addr #1
Unsupported Constant???
UNREACHABLE executed at /work/checkouts/downstreams/clspv/clspv/lib/SPIRVProducerPass.cpp:2190!
and the backtrace:
(gdb) bt
#0 0x00007ffff705ffb7 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff7061921 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007fffe809eb56 in llvm::llvm_unreachable_internal (msg=0x7ffff79817e7 "Unsupported Constant???", file=0x7ffff7981220 "clspv/lib/SPIRVProducerPass.cpp", line=2190)
at clspv/third_party/llvm/llvm/lib/Support/ErrorHandling.cpp:213
#3 0x00007ffff77b759b in (anonymous namespace)::SPIRVProducerPass::getSPIRVConstant (this=0x5555557aeca0, Cst=0x55555586b128) at clspv/lib/SPIRVProducerPass.cpp:2190
#4 0x00007ffff77b77a8 in (anonymous namespace)::SPIRVProducerPass::getSPIRVValue (this=0x5555557aeca0, V=0x55555586b128) at clspv/lib/SPIRVProducerPass.cpp:2214
#5 0x00007ffff77c0ac0 in (anonymous namespace)::SPIRVProducerPass::HandleDeferredInstruction (this=0x5555557aeca0) at clspv/lib/SPIRVProducerPass.cpp:4782
#6 0x00007ffff77b13b7 in (anonymous namespace)::SPIRVProducerPass::runOnModule (this=0x5555557aeca0, M=...) at clspv/lib/SPIRVProducerPass.cpp:788
#7 0x00007ffff150a4e7 in (anonymous namespace)::MPPassManager::runOnModule (this=0x555555d49290, M=...) at clspv/third_party/llvm/llvm/lib/IR/LegacyPassManager.cpp:1549
#8 0x00007ffff15056cf in llvm::legacy::PassManagerImpl::run (this=0x555555930ae0, M=...) at clspv/third_party/llvm/llvm/lib/IR/LegacyPassManager.cpp:540
#9 0x00007ffff150ad71 in llvm::legacy::PassManager::run (this=0x7fffffffb040, M=...) at clspv/third_party/llvm/llvm/lib/IR/LegacyPassManager.cpp:1676
#10 0x00007ffff7859a58 in clspv::Compile (argc=2, argv=0x7fffffffddc8) at clspv/lib/Compiler.cpp:941
#11 0x00005555555547ca in main (argc=2, argv=0x7fffffffddc8) at clspv/tools/driver/main.cpp:18
I initially spotted this issue by looking at reduced cases from bugpoint:
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"
declare dso_local spir_func void @foo()
define dso_local spir_kernel void @bar() {
entry:
call spir_func void @foo()
unreachable
}