LowerAddrSpaceCast cannot handle multiple llvm.memcpy
- Dominant language
- LLVM
- Stars
- 729
- Forks
- 110
- Avg merge
- 17h 51m
- Merged PRs (30d)
- 23
Description
```llvm
; ModuleID = '../testing/test.ll'
source_filename = "../out.ll"
define dso_local spir_kernel void @kern(ptr addrspace(1) align 4 %in) {
entry:
%cpy = alloca [4 x float], align 4
%0 = addrspacecast ptr addrspace(1) %in to ptr addrspace(4)
call void @llvm.memcpy.p0.p4.i32(ptr align 4 %cpy, ptr addrspace(4) align 4 %0, i32 16, i1 false)
%cpy2 = alloca [4 x float], align 4
%1 = addrspacecast ptr %cpy to ptr addrspace(4)
call void @llvm.memcpy.p0.p4.i32(ptr align 4 %cpy2, ptr addrspace(4) align 4 %1, i32 16, i1 false)
ret void
}
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p4.i32(ptr noalias nocapture writeonly, ptr addrspace(4) noalias nocapture readonly, i32, i1 immarg) #0
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
```
Compiling with `clspv-opt --passes lower-addrspacecast` results in an error (after #1351 ) because the pass determines that the first memcpy has a src pointer in addrspace(1), then caches the function.
When it sees the second memcpy, it fetches the cached replacement. But now the src pointer is resolved to addrspace(0), so creating a call instruction complains about mismatching types
Contributor guide
Assessment
This issue has not been assessed yet.