Skip to content

Commit 038ddb2

Browse files
authored
[SPIR-V] Update tests for opaque pointer migration (#187674)
Enable tests `linked-list.ll`, `pstruct.ll`, and `extract_insert_value.ll` where additional code changes are not required related to #60133
1 parent 1503293 commit 038ddb2

File tree

3 files changed

+102
-102
lines changed

3 files changed

+102
-102
lines changed

llvm/test/CodeGen/SPIRV/linked-list.ll

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
22

3-
; TODO(#60133): Requires updates following opaque pointer migration.
4-
; XFAIL: *
5-
63
%struct.Node = type { ptr addrspace(1) }
7-
; CHECK: %[[#]] = OpTypeOpaque "struct.Node.0"
84
%struct.Node.0 = type opaque
95

6+
; With opaque pointers, parameters are lowered to generic pointer-to-i8.
7+
; CHECK-DAG: %[[#I8:]] = OpTypeInt 8
8+
; CHECK-DAG: %[[#PTR:]] = OpTypePointer CrossWorkgroup %[[#I8]]
9+
; CHECK-DAG: %[[#I32:]] = OpTypeInt 32
10+
; CHECK-DAG: %[[#VOID:]] = OpTypeVoid
11+
; CHECK-DAG: %[[#FNTY:]] = OpTypeFunction %[[#VOID]] %[[#PTR]] %[[#PTR]] %[[#I32]]
12+
; CHECK: %[[#]] = OpFunction %[[#VOID]] None %[[#FNTY]]
13+
; CHECK: OpFunctionParameter %[[#PTR]]
14+
; CHECK: OpFunctionParameter %[[#PTR]]
15+
; CHECK: OpFunctionParameter %[[#I32]]
16+
1017
define spir_kernel void @create_linked_lists(ptr addrspace(1) nocapture %pNodes, ptr addrspace(1) nocapture %allocation_index, i32 %list_length) {
1118
entry:
1219
ret void

llvm/test/CodeGen/SPIRV/pstruct.ll

Lines changed: 77 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,118 @@
11
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
22

3-
; TODO(#60133): Requires updates following opaque pointer migration.
4-
; XFAIL: *
5-
63
%struct.ST = type { i32, i32, i32 }
74

8-
; CHECK-SPIRV: OpName %[[#struct:]] "struct.ST"
9-
; CHECK-SPIRV: %[[#int:]] = OpTypeInt 32 0
10-
; CHECK-SPIRV: %[[#intP:]] = OpTypePointer Function %[[#int]]
11-
; CHECK-SPIRV: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]]
12-
; CHECK-SPIRV: %[[#structP:]] = OpTypePointer Function %[[#struct]]
13-
; CHECK-SPIRV: %[[#structPP:]] = OpTypePointer Function %[[#structP]]
14-
; CHECK-SPIRV: %[[#zero:]] = OpConstantNull %[[#int]]
15-
; CHECK-SPIRV: %[[#one:]] = OpConstant %[[#int]] 1{{$}}
16-
; CHECK-SPIRV: %[[#two:]] = OpConstant %[[#int]] 2{{$}}
5+
; CHECK-SPIRV-DAG: OpName %[[#struct:]] "struct.ST"
6+
; CHECK-SPIRV-DAG: %[[#int:]] = OpTypeInt 32 0
7+
; CHECK-SPIRV-DAG: %[[#intP:]] = OpTypePointer Function %[[#int]]
8+
; CHECK-SPIRV-DAG: %[[#struct]] = OpTypeStruct %[[#int]] %[[#int]] %[[#int]]
9+
; CHECK-SPIRV-DAG: %[[#structP:]] = OpTypePointer Function %[[#struct]]
10+
; CHECK-SPIRV-DAG: %[[#structPP:]] = OpTypePointer Function %[[#structP]]
11+
; CHECK-SPIRV-DAG: %[[#zero:]] = OpConstantNull %[[#int]]
12+
; CHECK-SPIRV-DAG: %[[#one:]] = OpConstant %[[#int]] 1{{$}}
13+
; CHECK-SPIRV-DAG: %[[#two:]] = OpConstant %[[#int]] 2{{$}}
1714

18-
define dso_local spir_func i32 @cmp_func(i8* %p1, i8* %p2) {
15+
define dso_local spir_func i32 @cmp_func(ptr %p1, ptr %p2) {
1916
entry:
17+
; CHECK-SPIRV: %[[#retval:]] = OpVariable %[[#intP]] Function
18+
; CHECK-SPIRV: %[[#p1_addr:]] = OpVariable %[[#ptrPtrTy:]] Function
19+
; CHECK-SPIRV: %[[#p2_addr:]] = OpVariable %[[#ptrPtrTy]] Function
20+
; CHECK-SPIRV: %[[#s1:]] = OpVariable %[[#ptrPtrTy]] Function
21+
; CHECK-SPIRV: %[[#s2:]] = OpVariable %[[#ptrPtrTy]] Function
2022
%retval = alloca i32, align 4
21-
%p1.addr = alloca i8*, align 8
22-
%p2.addr = alloca i8*, align 8
23-
; CHECK-SPIRV: %[[#s1:]] = OpVariable %[[#structPP]]
24-
; CHECK-SPIRV: %[[#s2:]] = OpVariable %[[#structPP]]
25-
%s1 = alloca %struct.ST*, align 8
26-
%s2 = alloca %struct.ST*, align 8
27-
store i8* %p1, i8** %p1.addr, align 8
28-
store i8* %p2, i8** %p2.addr, align 8
29-
%0 = load i8*, i8** %p1.addr, align 8
30-
; CHECK-SPIRV: %[[#t1:]] = OpBitcast %[[#structP]]
31-
; CHECK-SPIRV: OpStore %[[#s1]] %[[#t1]]
32-
%1 = bitcast i8* %0 to %struct.ST*
33-
store %struct.ST* %1, %struct.ST** %s1, align 8
34-
%2 = load i8*, i8** %p2.addr, align 8
35-
; CHECK-SPIRV: %[[#t2:]] = OpBitcast %[[#structP]]
36-
; CHECK-SPIRV: OpStore %[[#s2]] %[[#t2]]
37-
%3 = bitcast i8* %2 to %struct.ST*
38-
store %struct.ST* %3, %struct.ST** %s2, align 8
39-
; CHECK-SPIRV: %[[#t3:]] = OpLoad %[[#structP]] %[[#s1]]
23+
%p1.addr = alloca ptr, align 8
24+
%p2.addr = alloca ptr, align 8
25+
%s1 = alloca ptr, align 8
26+
%s2 = alloca ptr, align 8
27+
; CHECK-SPIRV: OpStore %[[#p1_addr]] %[[#p1:]] Aligned 8
28+
store ptr %p1, ptr %p1.addr, align 8
29+
; CHECK-SPIRV: OpStore %[[#p2_addr]] %[[#p2:]] Aligned 8
30+
store ptr %p2, ptr %p2.addr, align 8
31+
; CHECK-SPIRV: %[[#val0:]] = OpLoad %[[#ptrTy:]] %[[#p1_addr]] Aligned 8
32+
%0 = load ptr, ptr %p1.addr, align 8
33+
; CHECK-SPIRV: OpStore %[[#s1]] %[[#val0]] Aligned 8
34+
store ptr %0, ptr %s1, align 8
35+
; CHECK-SPIRV: %[[#val1:]] = OpLoad %[[#ptrTy]] %[[#p2_addr]] Aligned 8
36+
%2 = load ptr, ptr %p2.addr, align 8
37+
; CHECK-SPIRV: OpStore %[[#s2]] %[[#val1]] Aligned 8
38+
store ptr %2, ptr %s2, align 8
39+
; CHECK-SPIRV: %[[#]] = OpBitcast %[[#structPP]]
40+
; CHECK-SPIRV: %[[#t3:]] = OpLoad %[[#structP]]
4041
; CHECK-SPIRV: %[[#a1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t3]] %[[#zero]] %[[#zero]]
4142
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a1]]
42-
%4 = load %struct.ST*, %struct.ST** %s1, align 8
43-
%a = getelementptr inbounds %struct.ST, %struct.ST* %4, i32 0, i32 0
44-
%5 = load i32, i32* %a, align 4
45-
; CHECK-SPIRV: %[[#t4:]] = OpLoad %[[#structP]] %[[#s2]]
43+
%4 = load ptr, ptr %s1, align 8
44+
%a = getelementptr inbounds %struct.ST, ptr %4, i32 0, i32 0
45+
%5 = load i32, ptr %a, align 4
46+
; CHECK-SPIRV: %[[#]] = OpBitcast %[[#structPP]]
47+
; CHECK-SPIRV: %[[#t4:]] = OpLoad %[[#structP]]
4648
; CHECK-SPIRV: %[[#a2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t4]] %[[#zero]] %[[#zero]]
4749
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a2]]
48-
%6 = load %struct.ST*, %struct.ST** %s2, align 8
49-
%a1 = getelementptr inbounds %struct.ST, %struct.ST* %6, i32 0, i32 0
50-
%7 = load i32, i32* %a1, align 4
50+
%6 = load ptr, ptr %s2, align 8
51+
%a1 = getelementptr inbounds %struct.ST, ptr %6, i32 0, i32 0
52+
%7 = load i32, ptr %a1, align 4
5153
%cmp = icmp ne i32 %5, %7
5254
br i1 %cmp, label %if.then, label %if.end
5355

5456
if.then: ; preds = %entry
55-
; CHECK-SPIRV: %[[#t5:]] = OpLoad %[[#structP]] %[[#s1]]
56-
; CHECK-SPIRV: %[[#a_1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t5]] %[[#zero]] %[[#zero]]
57-
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a_1]]
58-
%8 = load %struct.ST*, %struct.ST** %s1, align 8
59-
%a2 = getelementptr inbounds %struct.ST, %struct.ST* %8, i32 0, i32 0
60-
%9 = load i32, i32* %a2, align 4
61-
; CHECK-SPIRV: %[[#t6:]] = OpLoad %[[#structP]] %[[#s2]]
62-
; CHECK-SPIRV: %[[#a_2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t6]] %[[#zero]] %[[#zero]]
63-
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#a_2]]
64-
%10 = load %struct.ST*, %struct.ST** %s2, align 8
65-
%a3 = getelementptr inbounds %struct.ST, %struct.ST* %10, i32 0, i32 0
66-
%11 = load i32, i32* %a3, align 4
57+
%8 = load ptr, ptr %s1, align 8
58+
%a2 = getelementptr inbounds %struct.ST, ptr %8, i32 0, i32 0
59+
%9 = load i32, ptr %a2, align 4
60+
%10 = load ptr, ptr %s2, align 8
61+
%a3 = getelementptr inbounds %struct.ST, ptr %10, i32 0, i32 0
62+
%11 = load i32, ptr %a3, align 4
6763
%sub = sub nsw i32 %9, %11
68-
store i32 %sub, i32* %retval, align 4
64+
store i32 %sub, ptr %retval, align 4
6965
br label %return
7066

7167
if.end: ; preds = %entry
72-
; CHECK-SPIRV: %[[#t7:]] = OpLoad %[[#structP]] %[[#s1]]
68+
; CHECK-SPIRV: %[[#]] = OpBitcast %[[#structPP]]
69+
; CHECK-SPIRV: %[[#t7:]] = OpLoad %[[#structP]]
7370
; CHECK-SPIRV: %[[#b1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t7]] %[[#zero]] %[[#one]]
7471
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b1]]
75-
%12 = load %struct.ST*, %struct.ST** %s1, align 8
76-
%b = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 1
77-
%13 = load i32, i32* %b, align 4
78-
; CHECK-SPIRV: %[[#t8:]] = OpLoad %[[#structP]] %[[#s2]]
72+
%12 = load ptr, ptr %s1, align 8
73+
%b = getelementptr inbounds %struct.ST, ptr %12, i32 0, i32 1
74+
%13 = load i32, ptr %b, align 4
75+
; CHECK-SPIRV: %[[#]] = OpBitcast %[[#structPP]]
76+
; CHECK-SPIRV: %[[#t8:]] = OpLoad %[[#structP]]
7977
; CHECK-SPIRV: %[[#b2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t8]] %[[#zero]] %[[#one]]
8078
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b2]]
81-
%14 = load %struct.ST*, %struct.ST** %s2, align 8
82-
%b4 = getelementptr inbounds %struct.ST, %struct.ST* %14, i32 0, i32 1
83-
%15 = load i32, i32* %b4, align 4
79+
%14 = load ptr, ptr %s2, align 8
80+
%b4 = getelementptr inbounds %struct.ST, ptr %14, i32 0, i32 1
81+
%15 = load i32, ptr %b4, align 4
8482
%cmp5 = icmp ne i32 %13, %15
8583
br i1 %cmp5, label %if.then6, label %if.end10
8684

8785
if.then6: ; preds = %if.end
88-
; CHECK-SPIRV: %[[#t9:]] = OpLoad %[[#structP]] %[[#s1]]
89-
; CHECK-SPIRV: %[[#b_1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t9]] %[[#zero]] %[[#one]]
90-
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b_1]]
91-
%16 = load %struct.ST*, %struct.ST** %s1, align 8
92-
%b7 = getelementptr inbounds %struct.ST, %struct.ST* %16, i32 0, i32 1
93-
%17 = load i32, i32* %b7, align 4
94-
; CHECK-SPIRV: %[[#t10:]] = OpLoad %[[#structP]] %[[#s2]]
95-
; CHECK-SPIRV: %[[#b_2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t10]] %[[#zero]] %[[#one]]
96-
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#b_2]]
97-
%18 = load %struct.ST*, %struct.ST** %s2, align 8
98-
%b8 = getelementptr inbounds %struct.ST, %struct.ST* %18, i32 0, i32 1
99-
%19 = load i32, i32* %b8, align 4
86+
%16 = load ptr, ptr %s1, align 8
87+
%b7 = getelementptr inbounds %struct.ST, ptr %16, i32 0, i32 1
88+
%17 = load i32, ptr %b7, align 4
89+
%18 = load ptr, ptr %s2, align 8
90+
%b8 = getelementptr inbounds %struct.ST, ptr %18, i32 0, i32 1
91+
%19 = load i32, ptr %b8, align 4
10092
%sub9 = sub nsw i32 %17, %19
101-
store i32 %sub9, i32* %retval, align 4
93+
store i32 %sub9, ptr %retval, align 4
10294
br label %return
10395

10496
if.end10: ; preds = %if.end
105-
; CHECK-SPIRV: %[[#t11:]] = OpLoad %[[#structP]] %[[#s1]]
97+
; CHECK-SPIRV: %[[#]] = OpBitcast %[[#structPP]]
98+
; CHECK-SPIRV: %[[#t11:]] = OpLoad %[[#structP]]
10699
; CHECK-SPIRV: %[[#c1:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t11]] %[[#zero]] %[[#two]]
107100
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#c1]]
108-
%20 = load %struct.ST*, %struct.ST** %s1, align 8
109-
%c = getelementptr inbounds %struct.ST, %struct.ST* %20, i32 0, i32 2
110-
%21 = load i32, i32* %c, align 4
111-
; CHECK-SPIRV: %[[#t12:]] = OpLoad %[[#structP]] %[[#s2]]
101+
%20 = load ptr, ptr %s1, align 8
102+
%c = getelementptr inbounds %struct.ST, ptr %20, i32 0, i32 2
103+
%21 = load i32, ptr %c, align 4
104+
; CHECK-SPIRV: %[[#]] = OpBitcast %[[#structPP]]
105+
; CHECK-SPIRV: %[[#t12:]] = OpLoad %[[#structP]]
112106
; CHECK-SPIRV: %[[#c2:]] = OpInBoundsPtrAccessChain %[[#intP]] %[[#t12]] %[[#zero]] %[[#two]]
113107
; CHECK-SPIRV: %[[#]] = OpLoad %[[#int]] %[[#c2]]
114-
%22 = load %struct.ST*, %struct.ST** %s2, align 8
115-
%c11 = getelementptr inbounds %struct.ST, %struct.ST* %22, i32 0, i32 2
116-
%23 = load i32, i32* %c11, align 4
108+
%22 = load ptr, ptr %s2, align 8
109+
%c11 = getelementptr inbounds %struct.ST, ptr %22, i32 0, i32 2
110+
%23 = load i32, ptr %c11, align 4
117111
%sub12 = sub nsw i32 %21, %23
118-
store i32 %sub12, i32* %retval, align 4
112+
store i32 %sub12, ptr %retval, align 4
119113
br label %return
120114

121115
return: ; preds = %if.end10, %if.then6, %if.then
122-
%24 = load i32, i32* %retval, align 4
116+
%24 = load i32, ptr %retval, align 4
123117
ret i32 %24
124118
}

llvm/test/CodeGen/SPIRV/transcoding/extract_insert_value.ll

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
22
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
33

4-
; TODO(#60133): Requires updates following opaque pointer migration.
5-
; XFAIL: *
6-
74
;; Check 'LLVM ==> SPIR-V' conversion of extractvalue/insertvalue.
85

96
%struct.arr = type { [7 x float] }
107
%struct.st = type { %struct.inner }
118
%struct.inner = type { float }
129

13-
; CHECK-SPIRV: %[[#float_ty:]] = OpTypeFloat 32
14-
; CHECK-SPIRV: %[[#int_ty:]] = OpTypeInt 32
15-
; CHECK-SPIRV: %[[#arr_size:]] = OpConstant %[[#int_ty]] 7
16-
; CHECK-SPIRV: %[[#array_ty:]] = OpTypeArray %[[#float_ty]] %[[#arr_size]]
17-
; CHECK-SPIRV: %[[#struct_ty:]] = OpTypeStruct %[[#array_ty]]
18-
; CHECK-SPIRV: %[[#struct_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct_ty]]
19-
; CHECK-SPIRV: %[[#array_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#array_ty]]
20-
; CHECK-SPIRV: %[[#struct1_in_ty:]] = OpTypeStruct %[[#float_ty]]
21-
; CHECK-SPIRV: %[[#struct1_ty:]] = OpTypeStruct %[[#struct1_in_ty]]
22-
; CHECK-SPIRV: %[[#struct1_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct1_ty]]
23-
; CHECK-SPIRV: %[[#struct1_in_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct1_in_ty]]
10+
; CHECK-SPIRV-DAG: %[[#int_ty:]] = OpTypeInt 32
11+
; CHECK-SPIRV-DAG: %[[#float_ty:]] = OpTypeFloat 32
12+
; CHECK-SPIRV-DAG: %[[#arr_size:]] = OpConstant %[[#int_ty]] 7
13+
; CHECK-SPIRV-DAG: %[[#array_ty:]] = OpTypeArray %[[#float_ty]] %[[#arr_size]]
14+
; CHECK-SPIRV-DAG: %[[#struct_ty:]] = OpTypeStruct %[[#array_ty]]
15+
; CHECK-SPIRV-DAG: %[[#struct_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct_ty]]
16+
; CHECK-SPIRV-DAG: %[[#array_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#array_ty]]
17+
; CHECK-SPIRV-DAG: %[[#struct1_in_ty:]] = OpTypeStruct %[[#float_ty]]
18+
; CHECK-SPIRV-DAG: %[[#struct1_ty:]] = OpTypeStruct %[[#struct1_in_ty]]
19+
; CHECK-SPIRV-DAG: %[[#struct1_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct1_ty]]
20+
; CHECK-SPIRV-DAG: %[[#struct1_in_ptr_ty:]] = OpTypePointer CrossWorkgroup %[[#struct1_in_ty]]
2421
; CHECK-SPIRV-NOT: OpConstant %{{.*}} 2
2522
; CHECK-SPIRV-NOT: OpConstant %{{.*}} 4
2623
; CHECK-SPIRV-NOT: OpConstant %{{.*}} 5
@@ -55,7 +52,9 @@ entry:
5552
; CHECK-SPIRV: %[[#elem:]] = OpCompositeExtract %[[#float_ty]] %[[#extracted_struct]] 0
5653
; CHECK-SPIRV: %[[#add:]] = OpFAdd %[[#float_ty]] %[[#elem]] %[[#]]
5754
; CHECK-SPIRV: %[[#inserted_struct:]] = OpCompositeInsert %[[#struct1_in_ty]] %[[#add]] %[[#extracted_struct]] 0
58-
; CHECK-SPIRV: OpStore %[[#store1_ptr]] %[[#inserted_struct]]
55+
; CHECK-SPIRV: %[[#bitcast1:]] = OpBitcast %[[#]] %[[#store1_ptr]]
56+
; CHECK-SPIRV: %[[#store1_dst:]] = OpBitcast %[[#struct1_in_ptr_ty]] %[[#bitcast1]]
57+
; CHECK-SPIRV: OpStore %[[#store1_dst]] %[[#inserted_struct]] Aligned 4
5958
; CHECK-SPIRV-LABEL: OpFunctionEnd
6059

6160
define spir_func void @struct_test(ptr addrspace(1) %object) {

0 commit comments

Comments
 (0)