Addrspace cast lowering pass creates invalid IR for intrinsic calls
- Dominant language
- LLVM
- Stars
- 729
- Forks
- 110
- Avg merge
- 17h 51m
- Merged PRs (30d)
- 23
Description
Given the following code:
```llvm
; ModuleID = '../testing/testing.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)
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) }
```
`LowerAddrSpaceCast::visitCallInst` will generate a copy of the function for the memcpy call, copying all the attributes from the intrinsic.
```llvm
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @_Z21llvm.memcpy.p0.p4.i32Pmemcpy.p0.p4.i32(ptr noalias nocapture writeonly %0, ptr noalias nocapture readonly %1, i32 %2, i1 immarg %3) #0
```
However, the verifier pass will complain that `immarg attribute only applies to intrinsics`
Contributor guide
Assessment
This issue has not been assessed yet.