ICE when compiling simple swap<T> function
- Dominant language
- LLVM
- Stars
- 729
- Forks
- 110
- Avg merge
- 17h 51m
- Merged PRs (30d)
- 23
Description
The following:
```C++
template
inline void myswap(T& a, T& b)
{
auto tmp = a;
a = b;
b = tmp;
}
void foo() {
int *foo1 = nullptr;
int *foo2 = nullptr;
myswap(foo1, foo2);
}
```
results in a segmentation fault in:
```
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
* frame #0: 0x00000001000d4918 clspv`clspv::InferType(llvm::Value*, llvm::LLVMContext&, llvm::DenseMap, llvm::detail::DenseMapPair>*) + 2068
frame #1: 0x000000010001183c clspv`BitcastUtils::IsImplicitCasts(llvm::Module&, llvm::DenseMap, llvm::detail::DenseMapPair>&, llvm::Instruction&, llvm::Value*&, llvm::Type*&, llvm::Type*&, bool, bool) + 332
frame #2: 0x00000001000cb010 clspv`clspv::SimplifyPointerBitcastPass::runOnImplicitGEP(llvm::Module&) const + 400
frame #3: 0x00000001000ca904 clspv`clspv::SimplifyPointerBitcastPass::run(llvm::Module&, llvm::AnalysisManager&) + 152
frame #4: 0x0000000102d88c90 clspv`llvm::PassManager>::run(llvm::Module&, llvm::AnalysisManager&) + 412
frame #5: 0x00000001000e3d60 clspv`(anonymous namespace)::CompileModule(llvm::StringRef const&, std::__1::unique_ptr>&, std::__1::vector>*, std::__1::basic_string, std::__1::allocator>*) + 4948
frame #6: 0x00000001000de120 clspv`clspv::Compile(int, char const* const*) + 2156
frame #7: 0x000000018a82eb98 dyld`start + 6076
```
when compiled with:
```bash
clspv reproducer-swap.cl -cl-std=CLC++2021 -inline-entry-points -w -o foo.spirv
```
Contributor guide
Assessment
This issue has not been assessed yet.