Skip to content

Commit

Permalink
optimizer: minor code refactor (#41886)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Aug 14, 2021
1 parent 73e5522 commit 6bb978e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
17 changes: 8 additions & 9 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

#############
Expand Down
21 changes: 10 additions & 11 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6bb978e

Please sign in to comment.