73
73
74
74
# on 1.11 (JuliaLang/julia#52572, merged as part of JuliaLang/julia#52233) we can use
75
75
# 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"
77
77
78
78
# XXX : version of Base.method_instance that uses a function type
79
79
@inline function methodinstance (@nospecialize (ft:: Type ), @nospecialize (tt:: Type ),
@@ -395,7 +395,7 @@ CC.InferenceParams(interp::GPUInterpreter) = interp.inf_params
395
395
CC. OptimizationParams (interp:: GPUInterpreter ) = interp. opt_params
396
396
#= CC.=# get_inference_world (interp:: GPUInterpreter ) = interp. world
397
397
CC. get_inference_cache (interp:: GPUInterpreter ) = interp. inf_cache
398
- if HAS_INTEGRATED_CACHE
398
+ @static if HAS_INTEGRATED_CACHE
399
399
CC. cache_owner (interp:: GPUInterpreter ) = interp. token
400
400
else
401
401
CC. code_cache (interp:: GPUInterpreter ) = WorldView (interp. code_cache, interp. world)
412
412
CC. may_optimize (interp:: GPUInterpreter ) = true
413
413
CC. may_compress (interp:: GPUInterpreter ) = true
414
414
CC. may_discard_trees (interp:: GPUInterpreter ) = true
415
+ @static if VERSION <= v " 1.12.0-DEV.1531"
415
416
CC. verbose_stmt_info (interp:: GPUInterpreter ) = false
417
+ end
416
418
CC. method_table (interp:: GPUInterpreter ) = interp. method_table
417
419
418
420
# semi-concrete interepretation is broken with overlays (JuliaLang/julia#47349)
@@ -615,9 +617,11 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
615
617
prefer_specsig = true ,
616
618
gnu_pubnames = false ,
617
619
debug_info_kind = Cint (debug_info_kind),
618
- lookup = Base. unsafe_convert (Ptr{Nothing}, lookup_cb),
619
620
safepoint_on_entry = can_safepoint (job),
620
621
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
621
625
params = Base. CodegenParams (; cgparams... )
622
626
623
627
# generate IR
@@ -635,9 +639,15 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
635
639
Metadata (ConstantInt (DEBUG_METADATA_VERSION ()))
636
640
end
637
641
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},
639
648
(Vector{MethodInstance}, LLVM. API. LLVMOrcThreadSafeModuleRef, Ptr{Base. CodegenParams}, Cint, Cint, Cint, Csize_t),
640
649
[job. source], ts_mod, Ref (params), CompilationPolicyExtern, #= imaging mode=# 0 , #= external linkage=# 0 , job. world)
650
+ end
641
651
@assert native_code != C_NULL
642
652
643
653
llvm_mod_ref =
@@ -658,6 +668,19 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
658
668
cache_gbl = nothing
659
669
end
660
670
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
+
661
684
# process all compiled method instances
662
685
compiled = Dict ()
663
686
for mi in method_instances
0 commit comments