Skip to content

Commit 77700d0

Browse files
authored
Merge pull request #651 from JuliaGPU/tb/nightly
Fixes for nightly
2 parents f9f8606 + 394bb66 commit 77700d0

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

src/jlgen.jl

+27-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ end
7373

7474
# on 1.11 (JuliaLang/julia#52572, merged as part of JuliaLang/julia#52233) we can use
7575
# Julia's cached method lookup to simply look up method instances at run time.
76-
if VERSION >= v"1.11.0-DEV.1552"
76+
@static if VERSION >= v"1.11.0-DEV.1552"
7777

7878
# XXX: version of Base.method_instance that uses a function type
7979
@inline function methodinstance(@nospecialize(ft::Type), @nospecialize(tt::Type),
@@ -395,7 +395,7 @@ CC.InferenceParams(interp::GPUInterpreter) = interp.inf_params
395395
CC.OptimizationParams(interp::GPUInterpreter) = interp.opt_params
396396
#=CC.=#get_inference_world(interp::GPUInterpreter) = interp.world
397397
CC.get_inference_cache(interp::GPUInterpreter) = interp.inf_cache
398-
if HAS_INTEGRATED_CACHE
398+
@static if HAS_INTEGRATED_CACHE
399399
CC.cache_owner(interp::GPUInterpreter) = interp.token
400400
else
401401
CC.code_cache(interp::GPUInterpreter) = WorldView(interp.code_cache, interp.world)
@@ -412,7 +412,9 @@ end
412412
CC.may_optimize(interp::GPUInterpreter) = true
413413
CC.may_compress(interp::GPUInterpreter) = true
414414
CC.may_discard_trees(interp::GPUInterpreter) = true
415+
@static if VERSION <= v"1.12.0-DEV.1531"
415416
CC.verbose_stmt_info(interp::GPUInterpreter) = false
417+
end
416418
CC.method_table(interp::GPUInterpreter) = interp.method_table
417419

418420
# semi-concrete interepretation is broken with overlays (JuliaLang/julia#47349)
@@ -615,9 +617,11 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
615617
prefer_specsig = true,
616618
gnu_pubnames = false,
617619
debug_info_kind = Cint(debug_info_kind),
618-
lookup = Base.unsafe_convert(Ptr{Nothing}, lookup_cb),
619620
safepoint_on_entry = can_safepoint(job),
620621
gcstack_arg = false)
622+
if VERSION < v"1.12.0-DEV.1667"
623+
cgparams = (; lookup = Base.unsafe_convert(Ptr{Nothing}, lookup_cb), cgparams... )
624+
end
621625
params = Base.CodegenParams(; cgparams...)
622626

623627
# generate IR
@@ -635,9 +639,15 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
635639
Metadata(ConstantInt(DEBUG_METADATA_VERSION()))
636640
end
637641

638-
native_code = ccall(:jl_create_native, Ptr{Cvoid},
642+
native_code = if VERSION >= v"1.12.0-DEV.1667"
643+
ccall(:jl_create_native, Ptr{Cvoid},
644+
(Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint, Cint, Cint, Csize_t, Ptr{Cvoid}),
645+
[job.source], ts_mod, Ref(params), CompilationPolicyExtern, #=imaging mode=# 0, #=external linkage=# 0, job.world, Base.unsafe_convert(Ptr{Nothing}, lookup_cb))
646+
else
647+
ccall(:jl_create_native, Ptr{Cvoid},
639648
(Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint, Cint, Cint, Csize_t),
640649
[job.source], ts_mod, Ref(params), CompilationPolicyExtern, #=imaging mode=# 0, #=external linkage=# 0, job.world)
650+
end
641651
@assert native_code != C_NULL
642652

643653
llvm_mod_ref =
@@ -658,6 +668,19 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
658668
cache_gbl = nothing
659669
end
660670

671+
if VERSION >= v"1.12.0-DEV.1703"
672+
# on sufficiently recent versions of Julia, we can query the MIs compiled.
673+
# this is required after the move to `invokce(::CodeInstance)`, because our
674+
# lookup function (used to populate method_instances) isn't always called then.
675+
676+
num_mis = Ref{Csize_t}(0)
677+
@ccall jl_get_llvm_mis(native_code::Ptr{Cvoid}, num_mis::Ptr{Csize_t},
678+
C_NULL::Ptr{Cvoid})::Nothing
679+
resize!(method_instances, num_mis[])
680+
@ccall jl_get_llvm_mis(native_code::Ptr{Cvoid}, num_mis::Ptr{Csize_t},
681+
method_instances::Ptr{Cvoid})::Nothing
682+
end
683+
661684
# process all compiled method instances
662685
compiled = Dict()
663686
for mi in method_instances

test/native_tests.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ end
471471
Native.code_execution(mod.func, Tuple{})) do msg
472472
occursin("invalid LLVM IR", msg) &&
473473
occursin(GPUCompiler.DYNAMIC_CALL, msg) &&
474-
occursin("call to println", msg) &&
474+
occursin("call to print", msg) &&
475475
occursin("[2] func", msg)
476476
end
477477
end
@@ -604,7 +604,7 @@ precompile_test_harness("Inference caching") do load_path
604604
@test check_presence(kernel_mi, token)
605605

606606
# check that identity survived
607-
@test check_presence(identity_mi, token)
607+
@test check_presence(identity_mi, token) broken=VERSION>=v"1.12.0-DEV.1268"
608608

609609
GPUCompiler.clear_disk_cache!()
610610
@test GPUCompiler.disk_cache_enabled() == false

test/ptx_tests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ precompile_test_harness("Inference caching") do load_path
403403
@test check_presence(kernel_mi, token)
404404

405405
# check that identity survived
406-
@test check_presence(identity_mi, token)
406+
@test check_presence(identity_mi, token) broken=VERSION>=v"1.12.0-DEV.1268"
407407
end
408408
end
409409

0 commit comments

Comments
 (0)