1212 end
1313
1414 @test @filecheck begin
15- check " CHECK: {{.*identity.* }}"
15+ check " CHECK: @{{(julia|j)_identity_[0-9]+ }}"
1616 GPUCompiler. code_llvm (job)
1717 end
1818
1919 @test @filecheck begin
20- check " CHECK: {{.*identity.* }}"
20+ check " CHECK: @{{(julia|j)_identity_[0-9]+ }}"
2121 GPUCompiler. code_native (job)
2222 end
2323end
8181 end
8282
8383 @testset " cached compilation" begin
84- @gensym child kernel unrelated
85- @eval @noinline $ child (i) = i
86- @eval $ kernel (i) = $ child (i)+ 1
84+ mod = @eval module $ (gensym ())
85+ @noinline child (i) = i
86+ kernel (i) = child (i)+ 1
87+ end
8788
8889 # smoke test
89- job, _ = Native. create_job (eval ( kernel) , (Int64,))
90+ job, _ = Native. create_job (mod . kernel, (Int64,))
9091 @test @filecheck begin
91- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
92+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
9293 check " CHECK: add i64 %{{[0-9]+}}, 1"
9394 GPUCompiler. code_llvm (job)
9495 end
9596
9697 # basic redefinition
97- @eval $ kernel (i) = $ child (i)+ 2
98- job, _ = Native. create_job (eval ( kernel) , (Int64,))
98+ @eval mod kernel (i) = child (i)+ 2
99+ job, _ = Native. create_job (mod . kernel, (Int64,))
99100 @test @filecheck begin
100- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
101+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
101102 check " CHECK: add i64 %{{[0-9]+}}, 2"
102103 GPUCompiler. code_llvm (job)
103104 end
@@ -113,51 +114,51 @@ end
113114 end
114115 linker (job, compiled) = compiled
115116 cache = Dict ()
116- ft = typeof (eval ( kernel) )
117+ ft = typeof (mod . kernel)
117118 tt = Tuple{Int64}
118119
119120 # initial compilation
120121 source = methodinstance (ft, tt, Base. get_world_counter ())
121122 @test @filecheck begin
122- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
123+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
123124 check " CHECK: add i64 %{{[0-9]+}}, 2"
124125 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
125126 end
126127 @test invocations[] == 1
127128
128129 # cached compilation
129130 @test @filecheck begin
130- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
131+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
131132 check " CHECK: add i64 %{{[0-9]+}}, 2"
132133 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
133134 end
134135 @test invocations[] == 1
135136
136137 # redefinition
137- @eval $ kernel (i) = $ child (i)+ 3
138+ @eval mod kernel (i) = child (i)+ 3
138139 source = methodinstance (ft, tt, Base. get_world_counter ())
139140 @test @filecheck begin
140- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
141+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
141142 check " CHECK: add i64 %{{[0-9]+}}, 3"
142143 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
143144 end
144145 @test invocations[] == 2
145146
146147 # cached compilation
147148 @test @filecheck begin
148- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
149+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
149150 check " CHECK: add i64 %{{[0-9]+}}, 3"
150151 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
151152 end
152153 @test invocations[] == 2
153154
154155 # redefinition of an unrelated function
155- @eval $ unrelated (i) = 42
156+ @eval mod unrelated (i) = 42
156157 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
157158 @test invocations[] == 2
158159
159160 # redefining child functions
160- @eval @noinline $ child (i) = i+ 1
161+ @eval mod @noinline child (i) = i+ 1
161162 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
162163 @test invocations[] == 3
163164
168169 # change in configuration
169170 config = CompilerConfig (job. config; name= " foobar" )
170171 @test @filecheck begin
171- check " CHECK: define {{.*}} @foobar"
172+ check " CHECK: define i64 @foobar"
172173 Base. invokelatest (GPUCompiler. cached_compilation, cache, source, config, compiler, linker)
173174 end
174175 @test invocations[] == 4
@@ -183,13 +184,13 @@ end
183184 end
184185 t = @async Base. invokelatest (background, job)
185186 wait (c1) # make sure the task has started
186- @eval $ kernel (i) = $ child (i)+ 4
187+ @eval mod kernel (i) = child (i)+ 4
187188 source = methodinstance (ft, tt, Base. get_world_counter ())
188189 ir = Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
189190 @test contains (ir, r" add i64 %\d +, 4" )
190191 notify (c2) # wake up the task
191192 @test @filecheck begin
192- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
193+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
193194 check " CHECK: add i64 %{{[0-9]+}}, 3"
194195 fetch (t)
195196 end
220221
221222 @test @filecheck begin
222223 # module should contain our function + a generic call wrapper
223- check " CHECK: {{.*valid_kernel.* }}"
224+ check " CHECK: @{{(julia|j)_valid_kernel_[0-9]+ }}"
224225 Native. code_llvm (mod. valid_kernel, Tuple{}; optimize= false , dump_module= true )
225226 end
226227
244245 end
245246
246247 @test @filecheck begin
247- check " CHECK-LABEL: define {{.*}} @{{.*parent.* }}"
248- check " CHECK: call {{.+ }} @{{.*child.* }}"
248+ check " CHECK-LABEL: define i64 @{{(julia|j)_parent_[0-9]+ }}"
249+ check " CHECK: call{{.* }} i64 @{{(julia|j)_child_[0-9]+ }}"
249250 Native. code_llvm (mod. parent, Tuple{Int})
250251 end
251252end
@@ -312,17 +313,17 @@ end
312313 f = () -> x+ 1
313314 end
314315 @test @filecheck begin
315- check " CHECK: define internal fastcc {{.+}} @julia"
316+ check " CHECK: define {{.+}} @julia"
316317 check " TYPED: define nonnull {}* @jfptr"
317318 check " OPAQUE: define nonnull ptr @jfptr"
318- check " CHECK: call fastcc {{.+}} @julia"
319+ check " CHECK: call {{.+}} @julia"
319320 Native. code_llvm (mod. f, Tuple{}; entry_abi= :func , dump_module= true )
320321 end
321322end
322323
323324@testset " function entry safepoint emission" begin
324325 @test @filecheck begin
325- check " CHECK-LABEL: define {{.*}} @{{.*identity.*}}( "
326+ check " CHECK-LABEL: define void @{{(julia|j)_identity_[0-9]+}} "
326327 check " CHECK-NOT: %safepoint"
327328 Native. code_llvm (identity, Tuple{Nothing}; entry_safepoint= false , optimize= false , dump_module= true )
328329 end
331332 # see https://github.com/JuliaLang/julia/pull/57010/files#r2079576894
332333 if VERSION < v " 1.13.0-DEV.533"
333334 @test @filecheck begin
334- check " CHECK-LABEL: define {{.*}} @{{.*identity.*}}( "
335+ check " CHECK-LABEL: define void @{{(julia|j)_identity_[0-9]+}} "
335336 check " CHECK: %safepoint"
336337 Native. code_llvm (identity, Tuple{Nothing}; entry_safepoint= true , optimize= false , dump_module= true )
337338 end
@@ -342,34 +343,34 @@ end
342343 # XXX : broken by JuliaLang/julia#51599, see JuliaGPU/GPUCompiler.jl#527
343344 mod = @eval module $ (gensym ())
344345 import .. sink
345- f_expensive (x) = $ (foldl ((e, _) -> :($ sink ($ e) + $ sink (x)), 1 : 100 ; init= :x ))
346+ expensive (x) = $ (foldl ((e, _) -> :($ sink ($ e) + $ sink (x)), 1 : 100 ; init= :x ))
346347 function g (x)
347- f_expensive (x)
348+ expensive (x)
348349 return
349350 end
350351 function h (x)
351- f_expensive (x)
352+ expensive (x)
352353 return
353354 end
354355 end
355356
356357 @test @filecheck begin
357- check " CHECK: define {{.*f_expensive.* }}"
358+ check " CHECK: @{{(julia|j)_expensive_[0-9]+ }}"
358359 Native. code_llvm (mod. g, Tuple{Int64}; dump_module= true , kernel= true )
359360 end
360361
361362 @test @filecheck begin
362- check " CHECK-NOT: define {{.*f_expensive.* }}"
363+ check " CHECK-NOT: @{{(julia|j)_expensive_[0-9]+ }}"
363364 Native. code_llvm (mod. g, Tuple{Int64}; dump_module= true , kernel= true , always_inline= true )
364365 end
365366
366367 @test @filecheck begin
367- check " CHECK: define {{.*f_expensive.* }}"
368+ check " CHECK: @{{(julia|j)_expensive_[0-9]+ }}"
368369 Native. code_llvm (mod. h, Tuple{Int64}; dump_module= true , kernel= true )
369370 end
370371
371372 @test @filecheck begin
372- check " CHECK-NOT: define {{.*f_expensive.* }}"
373+ check " CHECK-NOT: @{{(julia|j)_expensive_[0-9]+ }}"
373374 Native. code_llvm (mod. h, Tuple{Int64}; dump_module= true , kernel= true , always_inline= true )
374375 end
375376end
0 commit comments