Crash with "Unsupported opaque pointer" when conditionally assigning into a global pointer
- Dominant language
- LLVM
- Stars
- 729
- Forks
- 110
- Avg merge
- 17h 51m
- Merged PRs (30d)
- 23
Description
I am experiencing a crash when compiling some OpenCL C code to SPIR-V, reporting "Unsupported opaque pointer" in debug builds. The issue appears to be around writing to a pointer with `global` memory space inside an `if` statement. The following miminal reproducible example crashes on my system:
```c
kernel void test(global uchar * buf) {
if (buf != NULL) *buf = 0;
}
```
Removing the condition or the write compiles successfully.
The issue appears to be related to the `cleanuppad` instruction - it crashes while getting the type of the operand for the instruction:
```
#0 0x00007ffff76adfbb in pthread_kill () from /usr/lib/libc.so.6
#1 0x00007ffff7644c88 in raise () from /usr/lib/libc.so.6
#2 0x00007ffff7625795 in abort () from /usr/lib/libc.so.6
#3 0x00005555627b8365 in llvm::llvm_unreachable_internal (msg=0x5555582e6ea1 "Unsupported opaque pointer", file=0x5555582e6788 ".../clspv/lib/SPIRVProducerPass.cpp", line=1977)
at .../clspv/third_party/llvm/llvm/lib/Support/ErrorHandling.cpp:244
#4 0x000055555b7433bc in (anonymous namespace)::SPIRVProducerPassImpl::getSPIRVType (this=0x7fffffff8380, Ty=0x555562cfacf0, needs_layout=true) at .../clspv/lib/SPIRVProducerPass.cpp:1977
#5 0x000055555b743357 in (anonymous namespace)::SPIRVProducerPassImpl::getSPIRVType (this=0x7fffffff8380, Ty=0x555562cfacf0) at .../clspv/lib/SPIRVProducerPass.cpp:1972
#6 0x000055555b73dd00 in (anonymous namespace)::operator<< (list=..., t=0x555562cfacf0) at .../clspv/lib/SPIRVProducerPass.cpp:846
#7 0x000055555b7534cb in (anonymous namespace)::SPIRVProducerPassImpl::GenerateInstruction (this=0x7fffffff8380, I=...) at .../clspv/lib/SPIRVProducerPass.cpp:5546
#8 0x000055555b74a749 in (anonymous namespace)::SPIRVProducerPassImpl::GenerateFuncBody (this=0x7fffffff8380, F=...) at .../clspv/lib/SPIRVProducerPass.cpp:3715
#9 0x000055555b73e888 in (anonymous namespace)::SPIRVProducerPassImpl::runOnModule (this=0x7fffffff8380, M=...) at .../clspv/lib/SPIRVProducerPass.cpp:940
#10 0x000055555b73e325 in clspv::SPIRVProducerPass::run (this=0x555562d118a8, M=..., MAM=...) at .../clspv/lib/SPIRVProducerPass.cpp:873
#11 0x000055555b521bcd in llvm::detail::PassModel >::run (this=0x555562d118a0, IR=..., AM=...)
at .../clspv/third_party/llvm/llvm/include/llvm/IR/PassManagerInternal.h:93
#12 0x00005555625c4815 in llvm::PassManager >::run (this=0x7fffffff8d70, IR=..., AM=...) at .../clspv/third_party/llvm/llvm/include/llvm/IR/PassManagerImpl.h:76
#13 0x000055555b4de90c in (anonymous namespace)::RunPassPipeline (M=..., binaryStream=0x7fffffffa230) at .../clspv/lib/Compiler.cpp:835
#14 0x000055555b4e0b37 in (anonymous namespace)::CompileModule (input_filename=..., module=std::unique_ptr = {...}, output_buffer=0x0, output_log=0x0) at .../clspv/lib/Compiler.cpp:1236
#15 0x000055555b4e10b8 in (anonymous namespace)::CompileProgram (input_filename=..., program="kernel void test(global uchar * buf) {if (buf != NULL) *buf = 0;}\n", output_buffer=0x0, output_log=0x0)
at .../clspv/lib/Compiler.cpp:1285
#16 0x000055555b4e14c0 in clspv::Compile (argc=1, argv=0x7fffffffce88) at .../clspv/lib/Compiler.cpp:1347
#17 0x000055555b4da819 in main (argc=1, argv=0x7fffffffce88) at .../clspv/tools/driver/main.cpp:18
```
I'm using the latest commit (25c988a) on Arch Linux.
Contributor guide
Assessment
This issue has not been assessed yet.