@@ -4,12 +4,15 @@ if :AMDGPU in LLVM.backends()
44@testset " kernel calling convention" begin
55 kernel () = return
66
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
911
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
1316end
1417
1518end
2730 return
2831 end
2932
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
3237 @test_skip occursin (" s_cbranch_execz" , asm)
3338 if Base. libllvm_version < v " 9"
3439 @test_broken occursin (" v_readfirstlane" , asm)
4449 return
4550 end
4651
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
5057end
5158
5259@testset " kernel functions" begin
5663 return
5764 end
5865
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
6372end
6473
6574@testset " child function reuse" begin
8089 end
8190 end
8291
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
8596
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
88101end
89102
90103@testset " child function reuse bis" begin
@@ -106,13 +119,17 @@ end
106119 end
107120 end
108121
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
112127
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
116133end
117134
118135@testset " indirect sysimg function use" begin
127144 return
128145 end
129146
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
133152end
134153
135154@testset " LLVM intrinsics" begin
@@ -171,12 +190,14 @@ false && @testset "GC and TLS lowering" begin
171190 end
172191 end
173192
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
180201
181202 # make sure that we can still ellide allocations
182203 function ref_kernel (ptr, i)
@@ -191,10 +212,10 @@ false && @testset "GC and TLS lowering" begin
191212 return nothing
192213 end
193214
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
198219end
199220
200221@testset " float boxes" begin
208229 return
209230 end
210231
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
213236 GCN. code_native (devnull , kernel, Tuple{Float32,Ptr{Float32}})
214237end
215238
0 commit comments