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

Addrspace cast lowering pass creates invalid IR for intrinsic calls #1350

Open
bmanga opened this issue May 14, 2024 · 0 comments · May be fixed by #1363 or #1351
Open

Addrspace cast lowering pass creates invalid IR for intrinsic calls #1350

bmanga opened this issue May 14, 2024 · 0 comments · May be fixed by #1363 or #1351

Comments

@bmanga
Copy link
Contributor

bmanga commented May 14, 2024

Given the following code:

; 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.

; 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

@bmanga bmanga linked a pull request May 14, 2024 that will close this issue
@bmanga bmanga linked a pull request May 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant