Skip to content

Commit 2b280ae

Browse files
authored
Backports release 1.12 (#57955)
2 parents e892948 + a3b193c commit 2b280ae

39 files changed

+1827
-718
lines changed

Compiler/extras/CompilerDevTools/src/CompilerDevTools.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ struct SplitCacheInterp <: Compiler.AbstractInterpreter
99
inf_params::Compiler.InferenceParams
1010
opt_params::Compiler.OptimizationParams
1111
inf_cache::Vector{Compiler.InferenceResult}
12+
codegen_cache::IdDict{CodeInstance,CodeInfo}
1213
function SplitCacheInterp(;
1314
world::UInt = Base.get_world_counter(),
1415
inf_params::Compiler.InferenceParams = Compiler.InferenceParams(),
1516
opt_params::Compiler.OptimizationParams = Compiler.OptimizationParams(),
1617
inf_cache::Vector{Compiler.InferenceResult} = Compiler.InferenceResult[])
17-
new(world, inf_params, opt_params, inf_cache)
18+
new(world, inf_params, opt_params, inf_cache, IdDict{CodeInstance,CodeInfo}())
1819
end
1920
end
2021

@@ -23,10 +24,11 @@ Compiler.OptimizationParams(interp::SplitCacheInterp) = interp.opt_params
2324
Compiler.get_inference_world(interp::SplitCacheInterp) = interp.world
2425
Compiler.get_inference_cache(interp::SplitCacheInterp) = interp.inf_cache
2526
Compiler.cache_owner(::SplitCacheInterp) = SplitCacheOwner()
27+
Compiler.codegen_cache(interp::SplitCacheInterp) = interp.codegen_cache
2628

2729
import Core.OptimizedGenerics.CompilerPlugins: typeinf, typeinf_edge
2830
@eval @noinline typeinf(::SplitCacheOwner, mi::MethodInstance, source_mode::UInt8) =
29-
Base.invoke_in_world(which(typeinf, Tuple{SplitCacheOwner, MethodInstance, UInt8}).primary_world, Compiler.typeinf_ext, SplitCacheInterp(; world=Base.tls_world_age()), mi, source_mode)
31+
Base.invoke_in_world(which(typeinf, Tuple{SplitCacheOwner, MethodInstance, UInt8}).primary_world, Compiler.typeinf_ext_toplevel, SplitCacheInterp(; world=Base.tls_world_age()), mi, source_mode)
3032

3133
@eval @noinline function typeinf_edge(::SplitCacheOwner, mi::MethodInstance, parent_frame::Compiler.InferenceState, world::UInt, source_mode::UInt8)
3234
# TODO: This isn't quite right, we're just sketching things for now

Compiler/src/abstractinterpretation.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,7 +2561,6 @@ function abstract_eval_setglobalonce!(interp::AbstractInterpreter, sv::AbsIntSta
25612561
end
25622562
end
25632563

2564-
25652564
function abstract_eval_replaceglobal!(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
25662565
if length(argtypes) in (5, 6, 7)
25672566
(M, s, x, v) = argtypes[2], argtypes[3], argtypes[4], argtypes[5]
@@ -3624,7 +3623,7 @@ end
36243623

36253624
function global_assignment_rt_exct(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, g::GlobalRef, @nospecialize(newty))
36263625
if saw_latestworld
3627-
return Pair{Any,Any}(newty, Union{ErrorException, TypeError})
3626+
return Pair{Any,Any}(newty, ErrorException)
36283627
end
36293628
(valid_worlds, ret) = scan_partitions((interp, _, partition)->global_assignment_binding_rt_exct(interp, partition, newty), interp, g, sv.world)
36303629
update_valid_age!(sv, valid_worlds)
@@ -3641,10 +3640,10 @@ function global_assignment_binding_rt_exct(interp::AbstractInterpreter, partitio
36413640
ty = kind == PARTITION_KIND_DECLARED ? Any : partition_restriction(partition)
36423641
wnewty = widenconst(newty)
36433642
if !hasintersect(wnewty, ty)
3644-
return Pair{Any,Any}(Bottom, TypeError)
3643+
return Pair{Any,Any}(Bottom, ErrorException)
36453644
elseif !(wnewty <: ty)
36463645
retty = tmeet(typeinf_lattice(interp), newty, ty)
3647-
return Pair{Any,Any}(retty, TypeError)
3646+
return Pair{Any,Any}(retty, ErrorException)
36483647
end
36493648
return Pair{Any,Any}(newty, Bottom)
36503649
end

Compiler/src/bootstrap.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,10 @@ function bootstrap!()
6767
end
6868
mi = specialize_method(m.method, Tuple{params...}, m.sparams)
6969
#isa_compileable_sig(mi) || println(stderr, "WARNING: inferring `", mi, "` which isn't expected to be called.")
70-
push!(methods, mi)
70+
typeinf_ext_toplevel(mi, world, isa_compileable_sig(mi) ? SOURCE_MODE_ABI : SOURCE_MODE_NOT_REQUIRED)
7171
end
7272
end
7373
end
74-
codeinfos = typeinf_ext_toplevel(methods, [world], TRIM_NO)
75-
for i = 1:2:length(codeinfos)
76-
ci = codeinfos[i]::CodeInstance
77-
src = codeinfos[i + 1]::CodeInfo
78-
isa_compileable_sig(ci.def) || continue # println(stderr, "WARNING: compiling `", ci.def, "` which isn't expected to be called.")
79-
ccall(:jl_add_codeinst_to_jit, Cvoid, (Any, Any), ci, src)
80-
end
8174
endtime = time()
8275
println("Base.Compiler ──── ", sub_float(endtime,starttime), " seconds")
8376
end

Compiler/src/ssair/irinterp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function concrete_eval_invoke(interp::AbstractInterpreter, ci::CodeInstance, arg
3232
end
3333

3434
function abstract_eval_invoke_inst(interp::AbstractInterpreter, inst::Instruction, irsv::IRInterpretationState)
35-
stmt = inst[:stmt]
35+
stmt = inst[:stmt]::Expr
3636
ci = stmt.args[1]
3737
if ci isa MethodInstance
3838
world = frame_world(irsv)

Compiler/src/ssair/passes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function find_def_for_use(
183183
end
184184

185185
function collect_leaves(compact::IncrementalCompact, @nospecialize(val), @nospecialize(typeconstraint), 𝕃ₒ::AbstractLattice,
186-
predecessors = ((@nospecialize(def), compact::IncrementalCompact) -> isa(def, PhiNode) ? def.values : nothing))
186+
predecessors::Pre = ((@nospecialize(def), compact::IncrementalCompact) -> isa(def, PhiNode) ? def.values : nothing)) where {Pre}
187187
if isa(val, Union{OldSSAValue, SSAValue})
188188
val, typeconstraint = simple_walk_constraint(compact, val, typeconstraint)
189189
end
@@ -271,7 +271,7 @@ Starting at `val` walk use-def chains to get all the leaves feeding into this `v
271271
`predecessors(def, compact)` is a callback which should return the set of possible
272272
predecessors for a "phi-like" node (PhiNode or Core.ifelse) or `nothing` otherwise.
273273
"""
274-
function walk_to_defs(compact::IncrementalCompact, @nospecialize(defssa), @nospecialize(typeconstraint), predecessors, 𝕃ₒ::AbstractLattice)
274+
function walk_to_defs(compact::IncrementalCompact, @nospecialize(defssa), @nospecialize(typeconstraint), predecessors::Pre, 𝕃ₒ::AbstractLattice) where {Pre}
275275
visited_philikes = AnySSAValue[]
276276
isa(defssa, AnySSAValue) || return Any[defssa], visited_philikes
277277
def = compact[defssa][:stmt]

0 commit comments

Comments
 (0)