Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Oct 11, 2024
1 parent a941cd8 commit 52efd2b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,9 @@ function semi_concrete_eval_call(interp::AbstractInterpreter,
mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::AbsIntState)
world = frame_world(sv)
mi_cache = WorldView(code_cache(interp), world)
code = get(mi_cache, mi, nothing)
if code !== nothing
irsv = IRInterpretationState(interp, code, mi, arginfo.argtypes, world)
codeinst = get(mi_cache, mi, nothing)
if codeinst !== nothing
irsv = IRInterpretationState(interp, codeinst, mi, arginfo.argtypes, world)
if irsv !== nothing
assign_parentchild!(irsv, sv)
rt, (nothrow, noub) = ir_abstract_constant_propagation(interp, irsv)
Expand All @@ -1237,7 +1237,7 @@ function semi_concrete_eval_call(interp::AbstractInterpreter,
effects = Effects(effects; noub=ALWAYS_TRUE)
end
exct = refine_exception_type(result.exct, effects)
return ConstCallResults(rt, exct, SemiConcreteResult(mi, ir, effects, spec_info(irsv)), effects)
return ConstCallResults(rt, exct, SemiConcreteResult(codeinst, ir, effects, spec_info(irsv)), effects)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ end

function semiconcrete_result_item(result::SemiConcreteResult,
@nospecialize(info::CallInfo), flag::UInt32, state::InliningState)
mi = result.mi
mi = result.edge.def
et = InliningEdgeTracker(state)

if (!OptimizationParams(state.interp).inlining || is_stmt_noinline(flag) ||
Expand All @@ -1478,7 +1478,7 @@ end

function handle_semi_concrete_result!(cases::Vector{InliningCase}, result::SemiConcreteResult,
match::MethodMatch, @nospecialize(info::CallInfo), flag::UInt32, state::InliningState)
mi = result.mi
mi = result.edge.def
spec_types = match.spec_types
validate_sparams(mi.sparam_vals) || return false
item = semiconcrete_result_item(result, info, flag, state)
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/stmtinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct ConcreteResult <: ConstResult
end

struct SemiConcreteResult <: ConstResult
mi::MethodInstance
edge::CodeInstance
ir::IRCode
effects::Effects
spec_info::SpecInfo
Expand Down
15 changes: 8 additions & 7 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,12 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
end
if frame === false
# completely new, but check again after reserving in the engine
if cache_mode == CACHE_MODE_GLOBAL
ci = engine_reserve(interp, mi)
ci_from_engine = cache_mode == CACHE_MODE_GLOBAL ? engine_reserve(interp, mi) : nothing
if ci_from_engine !== nothing
let codeinst = get(code_cache(interp), mi, nothing)
if codeinst isa CodeInstance # return existing rettype if the code is already inferred
engine_reject(interp, ci)
engine_reject(interp, ci_from_engine)
ci_from_engine = nothing
inferred = @atomic :monotonic codeinst.inferred
if inferred === nothing && force_inline
cache_mode = CACHE_MODE_VOLATILE
Expand All @@ -805,15 +806,15 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
end
end
result = InferenceResult(mi, typeinf_lattice(interp))
if cache_mode == CACHE_MODE_GLOBAL
result.ci = ci
if ci_from_engine !== nothing
result.ci = ci_from_engine
end
frame = InferenceState(result, cache_mode, interp) # always use the cache for edge targets
if frame === nothing
add_remark!(interp, caller, "[typeinf_edge] Failed to retrieve source")
# can't get the source for this, so we know nothing
if cache_mode == CACHE_MODE_GLOBAL
engine_reject(interp, ci)
if ci_from_engine !== nothing
engine_reject(interp, ci_from_engine)
end
return Future(EdgeCall_to_MethodCall_Result(interp, caller, method, EdgeCallResult(Any, Any, nothing, Effects()), edgecycle, edgelimited))
end
Expand Down

0 comments on commit 52efd2b

Please sign in to comment.