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

An issue with llvm.memset intrinsic #2128

Open
linehill opened this issue Aug 17, 2023 · 1 comment
Open

An issue with llvm.memset intrinsic #2128

linehill opened this issue Aug 17, 2023 · 1 comment

Comments

@linehill
Copy link
Contributor

The following LLVM 16 bitcode:

; ModuleID = 'from-llvm-16.cl'
source_filename = "from-llvm-16.cl"
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spirv64"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: write)
define spir_kernel void @k(ptr addrspace(1) nocapture noundef writeonly align 1 %0, i8 noundef signext %1) local_unnamed_addr #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 {
  tail call void @llvm.memset.p1.i64(ptr addrspace(1) noundef align 1 dereferenceable(123) %0, i8 %1, i64 123, i1 false), !tbaa !8
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p1.i64(ptr addrspace(1) nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: write) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!llvm.module.flags = !{!0, !1}
!opencl.ocl.version = !{!2}
!llvm.ident = !{!3}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"frame-pointer", i32 2}
!2 = !{i32 1, i32 2}
!3 = !{!"Ubuntu clang version 16.0.6 (++20230710042027+7cbf1a259152-1~exp1~20230710162048.105)"}
!4 = !{i32 1, i32 0}
!5 = !{!"none", !"none"}
!6 = !{!"char*", !"char"}
!7 = !{!"", !""}
!8 = !{!9, !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}

... translates to SPIR-V (with locally built llvm-spirv for LLVM 16) but reverse translation fails at least with llvm-spirv for LLVM 15 (provided by APT in Ubuntu 22.04):

$ llvm-as-16 from-llvm-16.ll -o - | llvm-spirv-16 -o from-llvm-16.spv
$ llvm-spirv-15 -r from-llvm-16.spv -o to-llvm-15.bc
Fails to verify module: Intrinsic name not mangled correctly for type arguments! Should be: llvm.memset.p1i8.i64
void (i8 addrspace(1)*, i8, i64, i1)* @llvm.memset.p1.i64
@MrSidims
Copy link
Contributor

MrSidims commented Sep 29, 2023

The issue is caused by opaque pointers switch that happened on earlier versions of the translator. I remember hearing about such issue from @asudarsa and the conclusion was that we probably need to restore correct mangling in the SPIR-V consumers from older branches. Arvind, may I assign it to you or it will go to another developer?

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

2 participants