@@ -4,12 +4,15 @@ if :AMDGPU in LLVM.backends()
4
4
@testset " kernel calling convention" begin
5
5
kernel () = return
6
6
7
- ir = sprint (io-> GCN. code_llvm (io, kernel, Tuple{}; dump_module= true ))
8
- @test ! occursin (" amdgpu_kernel" , ir)
7
+ @test @filecheck begin
8
+ check " CHECK-NOT: amdgpu_kernel"
9
+ GCN. code_llvm (kernel, Tuple{}; dump_module= true )
10
+ end
9
11
10
- ir = sprint (io-> GCN. code_llvm (io, kernel, Tuple{};
11
- dump_module= true , kernel= true ))
12
- @test occursin (" amdgpu_kernel" , ir)
12
+ @test @filecheck begin
13
+ check " CHECK: amdgpu_kernel"
14
+ GCN. code_llvm (kernel, Tuple{}; dump_module= true , kernel= true )
15
+ end
13
16
end
14
17
15
18
end
27
30
return
28
31
end
29
32
30
- asm = sprint (io-> GCN. code_native (io, kernel, Tuple{}))
31
- @test occursin (" s_trap 2" , asm)
33
+ @test @filecheck begin
34
+ check " CHECK: s_trap 2"
35
+ GCN. code_native (kernel, Tuple{})
36
+ end
32
37
@test_skip occursin (" s_cbranch_execz" , asm)
33
38
if Base. libllvm_version < v " 9"
34
39
@test_broken occursin (" v_readfirstlane" , asm)
44
49
return
45
50
end
46
51
47
- asm = sprint (io-> GCN. code_native (io, parent, Tuple{Int64}; dump_module= true ))
48
- @test occursin (r" s_add_u32.*(julia|j)_child_.*@rel32@" , asm)
49
- @test occursin (r" s_addc_u32.*(julia|j)_child_.*@rel32@" , asm)
52
+ @test @filecheck begin
53
+ check " CHECK: s_add_u32{{.*(julia|j)_child_.*}}@rel32@"
54
+ check " CHECK: s_addc_u32{{.*(julia|j)_child_.*}}@rel32@"
55
+ GCN. code_native (parent, Tuple{Int64}; dump_module= true )
56
+ end
50
57
end
51
58
52
59
@testset " kernel functions" begin
56
63
return
57
64
end
58
65
59
- asm = sprint (io-> GCN. code_native (io, entry, Tuple{Int64}; dump_module= true , kernel= true ))
60
- @test occursin (r" \. amdhsa_kernel \w *entry" , asm)
61
- @test ! occursin (r" \. amdhsa_kernel \w *nonentry" , asm)
62
- @test occursin (r" \. type.*\w *nonentry\w *,@function" , asm)
66
+ @test @filecheck begin
67
+ check " CHECK-NOT: .amdhsa_kernel {{.*}}nonentry"
68
+ check " CHECK: .type {{.*nonentry.*}},@function"
69
+ check " CHECK: .amdhsa_kernel {{.*entry.*}}"
70
+ GCN. code_native (entry, Tuple{Int64}; dump_module= true , kernel= true )
71
+ end
63
72
end
64
73
65
74
@testset " child function reuse" begin
80
89
end
81
90
end
82
91
83
- asm = sprint (io-> GCN. code_native (io, mod. parent1, Tuple{Int}; dump_module= true ))
84
- @test occursin (r" \. type.*(julia|j)_[[:alnum:]_.]*child_\d *,@function" , asm)
92
+ @test @filecheck begin
93
+ check " CHECK: .type {{.*child.*}},@function"
94
+ GCN. code_native (mod. parent1, Tuple{Int}; dump_module= true )
95
+ end
85
96
86
- asm = sprint (io-> GCN. code_native (io, mod. parent2, Tuple{Int}; dump_module= true ))
87
- @test occursin (r" \. type.*(julia|j)_[[:alnum:]_.]*child_\d *,@function" , asm)
97
+ @test @filecheck begin
98
+ check " CHECK: .type {{.*child.*}},@function"
99
+ GCN. code_native (mod. parent2, Tuple{Int}; dump_module= true )
100
+ end
88
101
end
89
102
90
103
@testset " child function reuse bis" begin
@@ -106,13 +119,17 @@ end
106
119
end
107
120
end
108
121
109
- asm = sprint (io-> GCN. code_native (io, mod. parent1, Tuple{Int}; dump_module= true ))
110
- @test occursin (r" \. type.*(julia|j)_[[:alnum:]_.]*child1_\d *,@function" , asm)
111
- @test occursin (r" \. type.*(julia|j)_[[:alnum:]_.]*child2_\d *,@function" , asm)
122
+ @test @filecheck begin
123
+ check " CHECK-DAG: .type {{.*child1.*}},@function"
124
+ check " CHECK-DAG: .type {{.*child2.*}},@function"
125
+ GCN. code_native (mod. parent1, Tuple{Int}; dump_module= true )
126
+ end
112
127
113
- asm = sprint (io-> GCN. code_native (io, mod. parent2, Tuple{Int}; dump_module= true ))
114
- @test occursin (r" \. type.*(julia|j)_[[:alnum:]_.]*child1_\d *,@function" , asm)
115
- @test occursin (r" \. type.*(julia|j)_[[:alnum:]_.]*child2_\d *,@function" , asm)
128
+ @test @filecheck begin
129
+ check " CHECK-DAG: .type {{.*child1.*}},@function"
130
+ check " CHECK-DAG: .type {{.*child2.*}},@function"
131
+ GCN. code_native (mod. parent2, Tuple{Int}; dump_module= true )
132
+ end
116
133
end
117
134
118
135
@testset " indirect sysimg function use" begin
127
144
return
128
145
end
129
146
130
- asm = sprint (io-> GCN. code_native (io, kernel, Tuple{Ptr{Int32}}))
131
- @test ! occursin (" jl_throw" , asm)
132
- @test ! occursin (" jl_invoke" , asm) # forced recompilation should still not invoke
147
+ @test @filecheck begin
148
+ check " CHECK-NOT: jl_throw"
149
+ check " CHECK-NOT: jl_invoke"
150
+ GCN. code_native (kernel, Tuple{Ptr{Int32}})
151
+ end
133
152
end
134
153
135
154
@testset " LLVM intrinsics" begin
@@ -171,12 +190,14 @@ false && @testset "GC and TLS lowering" begin
171
190
end
172
191
end
173
192
174
- asm = sprint (io-> GCN. code_native (io, mod. kernel, Tuple{Int}))
175
- @test occursin (" gpu_gc_pool_alloc" , asm)
176
- @test ! occursin (" julia.push_gc_frame" , asm)
177
- @test ! occursin (" julia.pop_gc_frame" , asm)
178
- @test ! occursin (" julia.get_gc_frame_slot" , asm)
179
- @test ! occursin (" julia.new_gc_frame" , asm)
193
+ @test @filecheck begin
194
+ check " CHECK-NOT: jl_push_gc_frame"
195
+ check " CHECK-NOT: jl_pop_gc_frame"
196
+ check " CHECK-NOT: jl_get_gc_frame_slot"
197
+ check " CHECK-NOT: jl_new_gc_frame"
198
+ check " CHECK: gpu_gc_pool_alloc"
199
+ GCN. code_native (mod. kernel, Tuple{Int})
200
+ end
180
201
181
202
# make sure that we can still ellide allocations
182
203
function ref_kernel (ptr, i)
@@ -191,10 +212,10 @@ false && @testset "GC and TLS lowering" begin
191
212
return nothing
192
213
end
193
214
194
- asm = sprint (io -> GCN . code_native (io, ref_kernel, Tuple{Ptr{Int64}, Int}))
195
-
196
-
197
- @test ! occursin ( " gpu_gc_pool_alloc " , asm)
215
+ @test @filecheck begin
216
+ check " CHECK-NOT: gpu_gc_pool_alloc "
217
+ GCN . code_native (ref_kernel, Tuple{Ptr{Int64}, Int})
218
+ end
198
219
end
199
220
200
221
@testset " float boxes" begin
208
229
return
209
230
end
210
231
211
- ir = sprint (io-> GCN. code_llvm (io, kernel, Tuple{Float32,Ptr{Float32}}))
212
- @test occursin (" jl_box_float32" , ir)
232
+ @test @filecheck begin
233
+ check " CHECK: jl_box_float32"
234
+ GCN. code_llvm (kernel, Tuple{Float32,Ptr{Float32}})
235
+ end
213
236
GCN. code_native (devnull , kernel, Tuple{Float32,Ptr{Float32}})
214
237
end
215
238
0 commit comments