Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LowerAddrSpaceCast cannot handle multiple llvm.memcpy #1355

Open
bmanga opened this issue May 17, 2024 · 0 comments
Open

LowerAddrSpaceCast cannot handle multiple llvm.memcpy #1355

bmanga opened this issue May 17, 2024 · 0 comments

Comments

@bmanga
Copy link
Contributor

bmanga commented May 17, 2024

; 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant