Skip to content

Commit f6839f7

Browse files
authored
Merge branch 'master' into shuffle_ntuple
2 parents 79f55ec + 9f9d3ac commit f6839f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+573
-275
lines changed

.github/CODEOWNERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ CODEOWNERS @JuliaLang/github-actions
44

55
/.github/workflows/rerun_failed.yml @DilumAluthge
66
/.github/workflows/statuses.yml @DilumAluthge
7+
/base/special/ @oscardssmith
8+
/base/sort.jl @LilithHafner
9+
/test/sorting.jl @LilithHafner
10+
/stdlib/*_jll @giordano
11+
/base/binaryplatforms.jl @giordano
12+
/src/julia_gcext.h @fingolfin
13+
/test/gcext/gcext.c @fingolfin

Compiler/src/optimize.jl

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,46 @@ struct InliningState{Interp<:AbstractInterpreter}
147147
edges::Vector{Any}
148148
world::UInt
149149
interp::Interp
150+
opt_cache::IdDict{MethodInstance,CodeInstance}
150151
end
151-
function InliningState(sv::InferenceState, interp::AbstractInterpreter)
152-
return InliningState(sv.edges, frame_world(sv), interp)
152+
function InliningState(sv::InferenceState, interp::AbstractInterpreter,
153+
opt_cache::IdDict{MethodInstance,CodeInstance}=IdDict{MethodInstance,CodeInstance}())
154+
return InliningState(sv.edges, frame_world(sv), interp, opt_cache)
153155
end
154-
function InliningState(interp::AbstractInterpreter)
155-
return InliningState(Any[], get_inference_world(interp), interp)
156+
function InliningState(interp::AbstractInterpreter,
157+
opt_cache::IdDict{MethodInstance,CodeInstance}=IdDict{MethodInstance,CodeInstance}())
158+
return InliningState(Any[], get_inference_world(interp), interp, opt_cache)
159+
end
160+
161+
struct OptimizerCache{CodeCache}
162+
wvc::WorldView{CodeCache}
163+
owner
164+
opt_cache::IdDict{MethodInstance,CodeInstance}
165+
function OptimizerCache(
166+
wvc::WorldView{CodeCache},
167+
@nospecialize(owner),
168+
opt_cache::IdDict{MethodInstance,CodeInstance}) where CodeCache
169+
new{CodeCache}(wvc, owner, opt_cache)
170+
end
171+
end
172+
function get((; wvc, owner, opt_cache)::OptimizerCache, mi::MethodInstance, default)
173+
if haskey(opt_cache, mi)
174+
codeinst = opt_cache[mi]
175+
@assert codeinst.min_world wvc.worlds.min_world &&
176+
wvc.worlds.max_world codeinst.max_world &&
177+
codeinst.owner === owner
178+
@assert isdefined(codeinst, :inferred) && codeinst.inferred === nothing
179+
return codeinst
180+
end
181+
return get(wvc, mi, default)
156182
end
157183

158184
# get `code_cache(::AbstractInterpreter)` from `state::InliningState`
159-
code_cache(state::InliningState) = WorldView(code_cache(state.interp), state.world)
185+
function code_cache(state::InliningState)
186+
cache = WorldView(code_cache(state.interp), state.world)
187+
owner = cache_owner(state.interp)
188+
return OptimizerCache(cache, owner, state.opt_cache)
189+
end
160190

161191
mutable struct OptimizationResult
162192
ir::IRCode
@@ -183,13 +213,15 @@ mutable struct OptimizationState{Interp<:AbstractInterpreter}
183213
bb_vartables::Vector{Union{Nothing,VarTable}}
184214
insert_coverage::Bool
185215
end
186-
function OptimizationState(sv::InferenceState, interp::AbstractInterpreter)
187-
inlining = InliningState(sv, interp)
216+
function OptimizationState(sv::InferenceState, interp::AbstractInterpreter,
217+
opt_cache::IdDict{MethodInstance,CodeInstance}=IdDict{MethodInstance,CodeInstance}())
218+
inlining = InliningState(sv, interp, opt_cache)
188219
return OptimizationState(sv.linfo, sv.src, nothing, sv.stmt_info, sv.mod,
189220
sv.sptypes, sv.slottypes, inlining, sv.cfg,
190221
sv.unreachable, sv.bb_vartables, sv.insert_coverage)
191222
end
192-
function OptimizationState(mi::MethodInstance, src::CodeInfo, interp::AbstractInterpreter)
223+
function OptimizationState(mi::MethodInstance, src::CodeInfo, interp::AbstractInterpreter,
224+
opt_cache::IdDict{MethodInstance,CodeInstance}=IdDict{MethodInstance,CodeInstance}())
193225
# prepare src for running optimization passes if it isn't already
194226
nssavalues = src.ssavaluetypes
195227
if nssavalues isa Int
@@ -209,7 +241,7 @@ function OptimizationState(mi::MethodInstance, src::CodeInfo, interp::AbstractIn
209241
mod = isa(def, Method) ? def.module : def
210242
# Allow using the global MI cache, but don't track edges.
211243
# This method is mostly used for unit testing the optimizer
212-
inlining = InliningState(interp)
244+
inlining = InliningState(interp, opt_cache)
213245
cfg = compute_basic_blocks(src.code)
214246
unreachable = BitSet()
215247
bb_vartables = Union{VarTable,Nothing}[]

Compiler/src/ssair/inlining.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,14 +1159,18 @@ function is_builtin(𝕃ₒ::AbstractLattice, s::Signature)
11591159
end
11601160

11611161
function handle_invoke_call!(todo::Vector{Pair{Int,Any}},
1162-
ir::IRCode, idx::Int, stmt::Expr, info::InvokeCallInfo, flag::UInt32,
1162+
ir::IRCode, idx::Int, stmt::Expr, @nospecialize(info), flag::UInt32,
11631163
sig::Signature, state::InliningState)
1164-
match = info.match
1164+
nspl = nsplit(info)
1165+
nspl == 0 && return nothing # e.g. InvokeCICallInfo
1166+
@assert nspl == 1
1167+
mresult = getsplit(info, 1)
1168+
match = mresult.matches[1]
11651169
if !match.fully_covers
11661170
# TODO: We could union split out the signature check and continue on
11671171
return nothing
11681172
end
1169-
result = info.result
1173+
result = getresult(info, 1)
11701174
if isa(result, ConcreteResult)
11711175
item = concrete_result_item(result, info, state)
11721176
elseif isa(result, SemiConcreteResult)
@@ -1648,7 +1652,7 @@ function assemble_inline_todo!(ir::IRCode, state::InliningState)
16481652
handle_opaque_closure_call!(todo, ir, idx, stmt, info, flag, sig, state)
16491653
elseif isa(info, ModifyOpInfo)
16501654
handle_modifyop!_call!(ir, idx, stmt, info, state)
1651-
elseif isa(info, InvokeCallInfo)
1655+
elseif sig.f === Core.invoke
16521656
handle_invoke_call!(todo, ir, idx, stmt, info, flag, sig, state)
16531657
elseif isa(info, FinalizerInfo)
16541658
handle_finalizer_call!(ir, idx, stmt, info, state)

Compiler/src/stmtinfo.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ struct InvokeCICallInfo <: CallInfo
278278
end
279279
add_edges_impl(edges::Vector{Any}, info::InvokeCICallInfo) =
280280
add_inlining_edge!(edges, info.edge)
281+
nsplit_impl(info::InvokeCICallInfo) = 0
281282

282283
"""
283284
info::InvokeCallInfo
@@ -390,6 +391,11 @@ function add_inlining_edge!(edges::Vector{Any}, edge::CodeInstance)
390391
nothing
391392
end
392393

394+
nsplit_impl(info::InvokeCallInfo) = 1
395+
getsplit_impl(info::InvokeCallInfo, idx::Int) = (@assert idx == 1; MethodLookupResult(Core.MethodMatch[info.match],
396+
WorldRange(typemin(UInt), typemax(UInt)), false))
397+
getresult_impl(info::InvokeCallInfo, idx::Int) = (@assert idx == 1; info.result)
398+
393399

394400
"""
395401
info::OpaqueClosureCallInfo

0 commit comments

Comments
 (0)