Skip to content

Commit e9c4404

Browse files
authored
Merge pull request #562 from JuliaGPU/tb/nightly
Adapt to upcoming Julia changes
2 parents 3c1bc65 + 4fca872 commit e9c4404

File tree

5 files changed

+44
-30
lines changed

5 files changed

+44
-30
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
version: ['1.8', '1.9', '1.10', '^1.11.0-alpha1'] # 'nightly'
21+
version: ['1.8', '1.9', '1.10', '^1.11.0-alpha2'] # 'nightly'
2222
os: [ubuntu-latest, macOS-latest, windows-latest]
2323
arch: [x64]
2424
llvm_args: ['']
@@ -36,15 +36,15 @@ jobs:
3636
os: 'windows-latest'
3737
arch: 'x64'
3838
llvm_args: '--opaque-pointers'
39-
- version: '^1.11.0-alpha1'
39+
- version: '^1.11.0-alpha2'
4040
os: 'ubuntu-latest'
4141
arch: 'x64'
4242
llvm_args: '--opaque-pointers'
43-
- version: '^1.11.0-alpha1'
43+
- version: '^1.11.0-alpha2'
4444
os: 'macOS-latest'
4545
arch: 'x64'
4646
llvm_args: '--opaque-pointers'
47-
- version: '^1.11.0-alpha1'
47+
- version: '^1.11.0-alpha2'
4848
os: 'windows-latest'
4949
arch: 'x64'
5050
llvm_args: '--opaque-pointers'

src/interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ end
229229
ci_cache_token(@nospecialize(job::CompilerJob)) =
230230
GPUCompilerCacheToken(typeof(job.config.target), job.config.always_inline, method_table(job))
231231

232-
# the codeinfo cache to use -- should only be used for the constructor
232+
# the codeinstance cache to use -- should only be used for the constructor
233233
if VERSION >= v"1.11.0-DEV.1552"
234234
# Soft deprecated user should use `CC.code_cache(get_interpreter(job))`
235235
ci_cache(@nospecialize(job::CompilerJob)) = CC.code_cache(get_interpreter(job))

src/irgen.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function irgen(@nospecialize(job::CompilerJob))
77
else
88
entry_fn = compiled[job.source].func
99
end
10+
@assert entry_fn !== nothing
1011
entry = functions(mod)[entry_fn]
1112

1213
# clean up incompatibilities

src/jlgen.jl

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,6 @@ function CC.getindex(wvc::WorldView{CodeCache}, mi::MethodInstance)
495495
end
496496

497497
function CC.setindex!(wvc::WorldView{CodeCache}, ci::CodeInstance, mi::MethodInstance)
498-
src = if ci.inferred isa Vector{UInt8}
499-
ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any),
500-
mi.def, C_NULL, ci.inferred)
501-
else
502-
ci.inferred
503-
end
504498
CC.setindex!(wvc.cache, ci, mi)
505499
end
506500

@@ -509,25 +503,42 @@ end # HAS_INTEGRATED_CACHE
509503
## codegen/inference integration
510504

511505
function ci_cache_populate(interp, cache, mi, min_world, max_world)
512-
src = CC.typeinf_ext_toplevel(interp, mi)
513-
514-
# inference populates the cache, so we don't need to jl_get_method_inferred
515-
wvc = WorldView(cache, min_world, max_world)
516-
@assert CC.haskey(wvc, mi)
517-
518-
# if src is rettyp_const, the codeinfo won't cache ci.inferred
519-
# (because it is normally not supposed to be used ever again).
520-
# to avoid the need to re-infer, set that field here.
521-
ci = CC.getindex(wvc, mi)
522-
if ci !== nothing && ci.inferred === nothing
523-
@static if VERSION >= v"1.9.0-DEV.1115"
524-
@atomic ci.inferred = src
525-
else
526-
ci.inferred = src
506+
if VERSION >= v"1.12.0-DEV.15"
507+
inferred_ci = CC.typeinf_ext_toplevel(interp, mi, CC.SOURCE_MODE_FORCE_SOURCE) # or SOURCE_MODE_FORCE_SOURCE_UNCACHED?
508+
509+
# inference should have populated our cache
510+
wvc = WorldView(cache, min_world, max_world)
511+
@assert CC.haskey(wvc, mi)
512+
ci = CC.getindex(wvc, mi)
513+
514+
# if ci is rettype_const, the inference result won't have been cached
515+
# (because it is normally not supposed to be used ever again).
516+
# to avoid the need to re-infer, set that field here.
517+
if ci.inferred === nothing
518+
CC.setindex!(wvc, inferred_ci, mi)
519+
ci = CC.getindex(wvc, mi)
520+
end
521+
else
522+
src = CC.typeinf_ext_toplevel(interp, mi)
523+
524+
# inference should have populated our cache
525+
wvc = WorldView(cache, min_world, max_world)
526+
@assert CC.haskey(wvc, mi)
527+
ci = CC.getindex(wvc, mi)
528+
529+
# if ci is rettype_const, the inference result won't have been cached
530+
# (because it is normally not supposed to be used ever again).
531+
# to avoid the need to re-infer, set that field here.
532+
if ci.inferred === nothing
533+
@static if VERSION >= v"1.9.0-DEV.1115"
534+
@atomic ci.inferred = src
535+
else
536+
ci.inferred = src
537+
end
527538
end
528539
end
529540

530-
return ci
541+
return ci::CodeInstance
531542
end
532543

533544
function ci_cache_lookup(cache, mi, min_world, max_world)
@@ -581,6 +592,7 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
581592
cache = CC.code_cache(interp)
582593
if ci_cache_lookup(cache, job.source, job.world, job.world) === nothing
583594
ci_cache_populate(interp, cache, job.source, job.world, job.world)
595+
@assert ci_cache_lookup(cache, job.source, job.world, job.world) !== nothing
584596
end
585597

586598
# create a callback to look-up function in our cache,
@@ -698,9 +710,10 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
698710
ccall(:jl_get_function_id, Nothing,
699711
(Ptr{Cvoid}, Any, Ptr{Int32}, Ptr{Int32}),
700712
native_code, ci, llvm_func_idx, llvm_specfunc_idx)
713+
@assert llvm_func_idx[] != -1 || llvm_specfunc_idx[] != -1 "Static compilation failed"
701714

702715
# get the function
703-
llvm_func = if llvm_func_idx[] >= 1
716+
llvm_func = if llvm_func_idx[] >= 1
704717
llvm_func_ref = ccall(:jl_get_llvm_function, LLVM.API.LLVMValueRef,
705718
(Ptr{Cvoid}, UInt32), native_code, llvm_func_idx[]-1)
706719
@assert llvm_func_ref != C_NULL
@@ -709,7 +722,7 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
709722
nothing
710723
end
711724

712-
llvm_specfunc = if llvm_specfunc_idx[] >= 1
725+
llvm_specfunc = if llvm_specfunc_idx[] >= 1
713726
llvm_specfunc_ref = ccall(:jl_get_llvm_function, LLVM.API.LLVMValueRef,
714727
(Ptr{Cvoid}, UInt32), native_code, llvm_specfunc_idx[]-1)
715728
@assert llvm_specfunc_ref != C_NULL

test/ptx_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ end
114114
@test occursin(r"@\w*kernel\w*\(\[1 x i64\] %state", ir)
115115

116116
# child1 doesn't use the state
117-
@test occursin(r"@\w*child1\w*\(i64", ir)
117+
@test occursin(r"@\w*child1\w*\((i64|i8\*)", ir)
118118

119119
# child2 does
120120
@test occursin(r"@\w*child2\w*\(\[1 x i64\] %state", ir)

0 commit comments

Comments
 (0)