12
12
end
13
13
14
14
@test @filecheck begin
15
- check " CHECK: {{.*identity.* }}"
15
+ check " CHECK: @{{(julia|j)_identity_[0-9]+ }}"
16
16
GPUCompiler. code_llvm (job)
17
17
end
18
18
19
19
@test @filecheck begin
20
- check " CHECK: {{.*identity.* }}"
20
+ check " CHECK: @{{(julia|j)_identity_[0-9]+ }}"
21
21
GPUCompiler. code_native (job)
22
22
end
23
23
end
81
81
end
82
82
83
83
@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
87
88
88
89
# smoke test
89
- job, _ = Native. create_job (eval ( kernel) , (Int64,))
90
+ job, _ = Native. create_job (mod . kernel, (Int64,))
90
91
@test @filecheck begin
91
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
92
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
92
93
check " CHECK: add i64 %{{[0-9]+}}, 1"
93
94
GPUCompiler. code_llvm (job)
94
95
end
95
96
96
97
# 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,))
99
100
@test @filecheck begin
100
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
101
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
101
102
check " CHECK: add i64 %{{[0-9]+}}, 2"
102
103
GPUCompiler. code_llvm (job)
103
104
end
@@ -113,51 +114,51 @@ end
113
114
end
114
115
linker (job, compiled) = compiled
115
116
cache = Dict ()
116
- ft = typeof (eval ( kernel) )
117
+ ft = typeof (mod . kernel)
117
118
tt = Tuple{Int64}
118
119
119
120
# initial compilation
120
121
source = methodinstance (ft, tt, Base. get_world_counter ())
121
122
@test @filecheck begin
122
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
123
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
123
124
check " CHECK: add i64 %{{[0-9]+}}, 2"
124
125
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
125
126
end
126
127
@test invocations[] == 1
127
128
128
129
# cached compilation
129
130
@test @filecheck begin
130
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
131
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
131
132
check " CHECK: add i64 %{{[0-9]+}}, 2"
132
133
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
133
134
end
134
135
@test invocations[] == 1
135
136
136
137
# redefinition
137
- @eval $ kernel (i) = $ child (i)+ 3
138
+ @eval mod kernel (i) = child (i)+ 3
138
139
source = methodinstance (ft, tt, Base. get_world_counter ())
139
140
@test @filecheck begin
140
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
141
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
141
142
check " CHECK: add i64 %{{[0-9]+}}, 3"
142
143
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
143
144
end
144
145
@test invocations[] == 2
145
146
146
147
# cached compilation
147
148
@test @filecheck begin
148
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
149
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
149
150
check " CHECK: add i64 %{{[0-9]+}}, 3"
150
151
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
151
152
end
152
153
@test invocations[] == 2
153
154
154
155
# redefinition of an unrelated function
155
- @eval $ unrelated (i) = 42
156
+ @eval mod unrelated (i) = 42
156
157
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
157
158
@test invocations[] == 2
158
159
159
160
# redefining child functions
160
- @eval @noinline $ child (i) = i+ 1
161
+ @eval mod @noinline child (i) = i+ 1
161
162
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
162
163
@test invocations[] == 3
163
164
168
169
# change in configuration
169
170
config = CompilerConfig (job. config; name= " foobar" )
170
171
@test @filecheck begin
171
- check " CHECK: define {{.*}} @foobar"
172
+ check " CHECK: define i64 @foobar"
172
173
Base. invokelatest (GPUCompiler. cached_compilation, cache, source, config, compiler, linker)
173
174
end
174
175
@test invocations[] == 4
@@ -183,13 +184,13 @@ end
183
184
end
184
185
t = @async Base. invokelatest (background, job)
185
186
wait (c1) # make sure the task has started
186
- @eval $ kernel (i) = $ child (i)+ 4
187
+ @eval mod kernel (i) = child (i)+ 4
187
188
source = methodinstance (ft, tt, Base. get_world_counter ())
188
189
ir = Base. invokelatest (GPUCompiler. cached_compilation, cache, source, job. config, compiler, linker)
189
190
@test contains (ir, r" add i64 %\d +, 4" )
190
191
notify (c2) # wake up the task
191
192
@test @filecheck begin
192
- check " CHECK-LABEL: define {{.*}} @{{.*kernel.*}}( "
193
+ check " CHECK-LABEL: define i64 @{{(julia|j)_kernel_[0-9]+}} "
193
194
check " CHECK: add i64 %{{[0-9]+}}, 3"
194
195
fetch (t)
195
196
end
220
221
221
222
@test @filecheck begin
222
223
# module should contain our function + a generic call wrapper
223
- check " CHECK: {{.*valid_kernel.* }}"
224
+ check " CHECK: @{{(julia|j)_valid_kernel_[0-9]+ }}"
224
225
Native. code_llvm (mod. valid_kernel, Tuple{}; optimize= false , dump_module= true )
225
226
end
226
227
244
245
end
245
246
246
247
@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]+ }}"
249
250
Native. code_llvm (mod. parent, Tuple{Int})
250
251
end
251
252
end
@@ -312,17 +313,17 @@ end
312
313
f = () -> x+ 1
313
314
end
314
315
@test @filecheck begin
315
- check " CHECK: define internal fastcc {{.+}} @julia"
316
+ check " CHECK: define {{.+}} @julia"
316
317
check " TYPED: define nonnull {}* @jfptr"
317
318
check " OPAQUE: define nonnull ptr @jfptr"
318
- check " CHECK: call fastcc {{.+}} @julia"
319
+ check " CHECK: call {{.+}} @julia"
319
320
Native. code_llvm (mod. f, Tuple{}; entry_abi= :func , dump_module= true )
320
321
end
321
322
end
322
323
323
324
@testset " function entry safepoint emission" begin
324
325
@test @filecheck begin
325
- check " CHECK-LABEL: define {{.*}} @{{.*identity.*}}( "
326
+ check " CHECK-LABEL: define void @{{(julia|j)_identity_[0-9]+}} "
326
327
check " CHECK-NOT: %safepoint"
327
328
Native. code_llvm (identity, Tuple{Nothing}; entry_safepoint= false , optimize= false , dump_module= true )
328
329
end
331
332
# see https://github.com/JuliaLang/julia/pull/57010/files#r2079576894
332
333
if VERSION < v " 1.13.0-DEV.533"
333
334
@test @filecheck begin
334
- check " CHECK-LABEL: define {{.*}} @{{.*identity.*}}( "
335
+ check " CHECK-LABEL: define void @{{(julia|j)_identity_[0-9]+}} "
335
336
check " CHECK: %safepoint"
336
337
Native. code_llvm (identity, Tuple{Nothing}; entry_safepoint= true , optimize= false , dump_module= true )
337
338
end
@@ -342,34 +343,34 @@ end
342
343
# XXX : broken by JuliaLang/julia#51599, see JuliaGPU/GPUCompiler.jl#527
343
344
mod = @eval module $ (gensym ())
344
345
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 ))
346
347
function g (x)
347
- f_expensive (x)
348
+ expensive (x)
348
349
return
349
350
end
350
351
function h (x)
351
- f_expensive (x)
352
+ expensive (x)
352
353
return
353
354
end
354
355
end
355
356
356
357
@test @filecheck begin
357
- check " CHECK: define {{.*f_expensive.* }}"
358
+ check " CHECK: @{{(julia|j)_expensive_[0-9]+ }}"
358
359
Native. code_llvm (mod. g, Tuple{Int64}; dump_module= true , kernel= true )
359
360
end
360
361
361
362
@test @filecheck begin
362
- check " CHECK-NOT: define {{.*f_expensive.* }}"
363
+ check " CHECK-NOT: @{{(julia|j)_expensive_[0-9]+ }}"
363
364
Native. code_llvm (mod. g, Tuple{Int64}; dump_module= true , kernel= true , always_inline= true )
364
365
end
365
366
366
367
@test @filecheck begin
367
- check " CHECK: define {{.*f_expensive.* }}"
368
+ check " CHECK: @{{(julia|j)_expensive_[0-9]+ }}"
368
369
Native. code_llvm (mod. h, Tuple{Int64}; dump_module= true , kernel= true )
369
370
end
370
371
371
372
@test @filecheck begin
372
- check " CHECK-NOT: define {{.*f_expensive.* }}"
373
+ check " CHECK-NOT: @{{(julia|j)_expensive_[0-9]+ }}"
373
374
Native. code_llvm (mod. h, Tuple{Int64}; dump_module= true , kernel= true , always_inline= true )
374
375
end
375
376
end
0 commit comments