| Issue |
63302
|
| Summary |
OpenCL: why the LLVM IR i get is difference with the IR command line generate?
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
xusw-cs
|
i haved called some API to compile the OpenCL kernel,it succeeds and i get the readable LLVM IR like this:
define spir_kernel void @add_kernel(i32 addrspace(1)* nocapture readonly %a, i32 addrspace(1)* nocapture readonly %b, i32 addrspace(1)* nocapture %c) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !5 !kernel_arg_type_qual !6 {
entry:
%call = tail call spir_func i32 @_Z13get_global_idj(i32 0) #2
%arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %a, i32 %call
%0 = load i32, i32 addrspace(1)* %arrayidx, align 4, !tbaa !7
%arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %b, i32 %call
%1 = load i32, i32 addrspace(1)* %arrayidx1, align 4, !tbaa !7
%add = add nsw i32 %1, %0
%arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %c, i32 %call
store i32 %add, i32 addrspace(1)* %arrayidx2, align 4, !tbaa !7
ret void
}
but when i derectly use the command line to compile the same OpenCL kernel, the command is:
clang -c -target spir-Unknown-Unknown -x cl -emit-llvm -S -cl-std=CL2.0 -Xclang -finclude-default-header add.cl
and i get the read LLVM IR like this, it is somewhat different with the IR I got using the API call way:
define dso_local spir_kernel void @add_kernel(i32 addrspace(1)* nocapture readonly, i32 addrspace(1)* nocapture readonly, i32 addrspace(1)* nocapture) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !5 !kernel_arg_type_qual !6 {
%4 = tail call spir_func i32 @_Z13get_global_idj(i32 0) #2
%5 = getelementptr inbounds i32, i32 addrspace(1)* %0, i32 %4
%6 = load i32, i32 addrspace(1)* %5, align 4, !tbaa !7
%7 = getelementptr inbounds i32, i32 addrspace(1)* %1, i32 %4
%8 = load i32, i32 addrspace(1)* %7, align 4, !tbaa !7
%9 = add nsw i32 %8, %6
%10 = getelementptr inbounds i32, i32 addrspace(1)* %2, i32 %4
store i32 %9, i32 addrspace(1)* %10, align 4, !tbaa !7
ret void
}
my question is:
1、how can i set the dso_local attribute when i call the API to compile the OpenCL kernel?
2、do i miss some flags or options which result in that the command line use the ssa number %4, %5...., but the IR i got use the name like %arrayidx?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs