diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index 349ed52c01529..1898aa8b75778 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -101,16 +101,15 @@ function OptimizationState(linfo::MethodInstance, params::OptimizationParams, in end function ir_to_codeinf!(opt::OptimizationState) - optdef = opt.linfo.def - replace_code_newstyle!(opt.src, opt.ir::IRCode, isa(optdef, Method) ? Int(optdef.nargs) : 0) + (; linfo, src) = opt + optdef = linfo.def + replace_code_newstyle!(src, opt.ir::IRCode, isa(optdef, Method) ? Int(optdef.nargs) : 0) opt.ir = nothing - let src = opt.src::CodeInfo - widen_all_consts!(src) - src.inferred = true - # finish updating the result struct - validate_code_in_debug_mode(opt.linfo, src, "optimized") - return src - end + widen_all_consts!(src) + src.inferred = true + # finish updating the result struct + validate_code_in_debug_mode(linfo, src, "optimized") + return src end ############# diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index d523d64926876..5bbf576d9f536 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -720,20 +720,19 @@ function compileable_specialization(et::Union{EdgeTracker, Nothing}, (; linfo):: end function resolve_todo(todo::InliningTodo, state::InliningState) - spec = todo.spec::DelayedInliningSpec + (; match) = todo.spec::DelayedInliningSpec #XXX: update_valid_age!(min_valid[1], max_valid[1], sv) isconst, src = false, nothing - if isa(spec.match, InferenceResult) - let inferred_src = spec.match.src - if isa(inferred_src, Const) - if !is_inlineable_constant(inferred_src.val) - return compileable_specialization(state.et, spec.match) - end - isconst, src = true, quoted(inferred_src.val) - else - isconst, src = false, inferred_src + if isa(match, InferenceResult) + inferred_src = match.src + if isa(inferred_src, Const) + if !is_inlineable_constant(inferred_src.val) + return compileable_specialization(state.et, match) end + isconst, src = true, quoted(inferred_src.val) + else + isconst, src = false, inferred_src end else linfo = get(state.mi_cache, todo.mi, nothing) @@ -761,7 +760,7 @@ function resolve_todo(todo::InliningTodo, state::InliningState) end if src === nothing - return compileable_specialization(et, spec.match) + return compileable_specialization(et, match) end if isa(src, IRCode)