Skip to content

Commit b5b02e2

Browse files
jcranmer-intelPavel V Chupin
authored andcommitted
Fix sret attribute to be valid LLVM IR.
The sret attribute is supposed to indicate what would be the pointee type of the parameter (to support the transition to opaque pointers). Somehow, the original change to this code concluded it was supposed to be a pointer type instead, however, for the sret attribute, while the byval attribute was correctly handled. Original commit: KhronosGroup/SPIRV-LLVM-Translator@a6cbade
1 parent 51d3372 commit b5b02e2

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2815,7 +2815,7 @@ Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF) {
28152815
AttrTy = cast<PointerType>(I->getType())->getPointerElementType();
28162816
break;
28172817
case Attribute::AttrKind::StructRet:
2818-
AttrTy = I->getType();
2818+
AttrTy = cast<PointerType>(I->getType())->getPointerElementType();
28192819
break;
28202820
default:
28212821
break; // do nothing

llvm-spirv/test/DebugInfo/Generic/2010-10-01-crash.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
88
target triple = "spir64-unknown-unknown"
99

10-
define void @CGRectStandardize(i32* sret(i32*) %agg.result, i32* byval(i32) %rect) nounwind ssp !dbg !0 {
10+
define void @CGRectStandardize(i32* sret(i32) %agg.result, i32* byval(i32) %rect) nounwind ssp !dbg !0 {
1111
entry:
1212
call void @llvm.dbg.declare(metadata i32* %rect, metadata !23, metadata !DIExpression()), !dbg !24
1313
ret void

llvm-spirv/test/EnqueueEmptyKernel.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ define spir_kernel void @test_enqueue_empty() #0 !kernel_arg_addr_space !0 !kern
3838
entry:
3939
%tmp = alloca %struct.ndrange_t, align 8
4040
%call = call spir_func %opencl.queue_t* @_Z17get_default_queuev() #4
41-
call spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp, i64 1) #4
41+
call spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t) %tmp, i64 1) #4
4242
%0 = call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* %call, i32 1, %struct.ndrange_t* %tmp, i32 0, %opencl.clk_event_t* addrspace(4)* null, %opencl.clk_event_t* addrspace(4)* null, i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* @__test_enqueue_empty_block_invoke_kernel to i8*) to i8 addrspace(4)*), i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32 } addrspace(1)* @__block_literal_global to i8 addrspace(1)*) to i8 addrspace(4)*))
4343
ret void
4444
; CHECK-SPIRV: Bitcast [[Int8Ptr]] [[Int8PtrBlock:[0-9]+]] [[Block]]
@@ -50,7 +50,7 @@ entry:
5050
declare spir_func %opencl.queue_t* @_Z17get_default_queuev() #1
5151

5252
; Function Attrs: convergent
53-
declare spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t*), i64) #1
53+
declare spir_func void @_Z10ndrange_1Dm(%struct.ndrange_t* sret(%struct.ndrange_t), i64) #1
5454

5555
; Function Attrs: convergent nounwind
5656
define internal spir_func void @__test_enqueue_empty_block_invoke(i8 addrspace(4)* %.block_descriptor) #2 {

llvm-spirv/test/llvm-intrinsics/memcpy.align.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target triple = "spir"
4242
@__const.bar.a = private unnamed_addr addrspace(2) constant %struct.A { i64 0, %struct.B { [2 x i32] [i32 1, i32 2] } }, align 8
4343

4444
; Function Attrs: convergent nounwind
45-
define spir_func void @foo(%struct.A* noalias sret(%struct.A*) %agg.result) #0 {
45+
define spir_func void @foo(%struct.A* noalias sret(%struct.A) %agg.result) #0 {
4646
entry:
4747
%b = alloca %struct.B, align 4
4848
%0 = bitcast %struct.B* %b to i8*
@@ -74,7 +74,7 @@ declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture r
7474
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
7575

7676
; Function Attrs: convergent nounwind
77-
define spir_func void @bar(%struct.B* noalias sret(%struct.B*) %agg.result) #0 {
77+
define spir_func void @bar(%struct.B* noalias sret(%struct.B) %agg.result) #0 {
7878
entry:
7979
%a = alloca %struct.A, align 8
8080
%0 = bitcast %struct.A* %a to i8*

llvm-spirv/test/transcoding/BuildNDRange.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ target triple = "spir"
3030
; Function Attrs: nounwind
3131
define spir_kernel void @test() #0 !kernel_arg_addr_space !0 !kernel_arg_access_qual !0 !kernel_arg_type !0 !kernel_arg_base_type !0 !kernel_arg_type_qual !0 {
3232
%ndrange = alloca %struct.ndrange_t, align 4
33-
call spir_func void @_Z10ndrange_1Djj(%struct.ndrange_t* sret(%struct.ndrange_t*) %ndrange, i32 123, i32 456)
33+
call spir_func void @_Z10ndrange_1Djj(%struct.ndrange_t* sret(%struct.ndrange_t) %ndrange, i32 123, i32 456)
3434
ret void
3535
}
3636

37-
declare spir_func void @_Z10ndrange_1Djj(%struct.ndrange_t* sret(%struct.ndrange_t*), i32, i32) #1
37+
declare spir_func void @_Z10ndrange_1Djj(%struct.ndrange_t* sret(%struct.ndrange_t), i32, i32) #1
3838

3939
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
4040
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }

llvm-spirv/test/transcoding/BuildNDRange_2.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,28 @@ entry:
8787
%0 = bitcast [2 x i64]* %lsize2 to i8*
8888
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %0, i8* align 8 bitcast ([2 x i64]* @test_ndrange_2D3D.lsize2 to i8*), i64 16, i1 false)
8989
%arraydecay = getelementptr inbounds [2 x i64], [2 x i64]* %lsize2, i64 0, i64 0
90-
call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp, i64* %arraydecay) #2
90+
call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t) %tmp, i64* %arraydecay) #2
9191
%1 = bitcast [3 x i64]* %lsize3 to i8*
9292
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %1, i8* align 8 bitcast ([3 x i64]* @test_ndrange_2D3D.lsize3 to i8*), i64 24, i1 false)
9393
%arraydecay2 = getelementptr inbounds [3 x i64], [3 x i64]* %lsize3, i64 0, i64 0
94-
call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp3, i64* %arraydecay2) #2
94+
call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t) %tmp3, i64* %arraydecay2) #2
9595
ret void
9696
}
9797

9898
; Function Attrs: nounwind
9999
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) #2
100100

101-
declare spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*), i64*) #1
101+
declare spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t), i64*) #1
102102

103-
declare spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*), i64*) #1
103+
declare spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t), i64*) #1
104104

105105
; Function Attrs: nounwind
106106
define spir_func void @test_ndrange_const_2D3D() #0 {
107107
entry:
108108
%tmp = alloca %struct.ndrange_t, align 8
109109
%tmp1 = alloca %struct.ndrange_t, align 8
110-
call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @test_ndrange_2D3D.lsize2, i64 0, i64 0)) #2
111-
call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t*) %tmp1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @test_ndrange_2D3D.lsize3, i64 0, i64 0)) #2
110+
call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret(%struct.ndrange_t) %tmp, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @test_ndrange_2D3D.lsize2, i64 0, i64 0)) #2
111+
call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret(%struct.ndrange_t) %tmp1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @test_ndrange_2D3D.lsize3, i64 0, i64 0)) #2
112112
ret void
113113
}
114114

0 commit comments

Comments
 (0)