Skip to content

Commit

Permalink
absint: merge const_prop_enabled into bail_out_const_call (#52921)
Browse files Browse the repository at this point in the history
Both of these interfaces have nearly identical roles. Considering the
simplicity in the codebase and the possible overloads by external
abstract interpreters, it seems more sensible to unify them into one
interface. Also tweaks remarks a bit.
  • Loading branch information
aviatesk authored Jan 17, 2024
1 parent b4f7263 commit 3ed49fd
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ end
function abstract_call_method_with_const_args(interp::AbstractInterpreter,
result::MethodCallResult, @nospecialize(f), arginfo::ArgInfo, si::StmtInfo,
match::MethodMatch, sv::AbsIntState, invokecall::Union{Nothing,InvokeCall}=nothing)
if !const_prop_enabled(interp, match, sv) || bail_out_const_call(interp, result, si, sv)
if bail_out_const_call(interp, result, si, match, sv)
return nothing
end
eligibility = concrete_eval_eligible(interp, f, result, arginfo, sv)
Expand Down Expand Up @@ -847,26 +847,26 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter,
return const_prop_call(interp, mi, result, arginfo, sv, concrete_eval_result)
end

function const_prop_enabled(interp::AbstractInterpreter, match::MethodMatch, sv::AbsIntState)
function bail_out_const_call(interp::AbstractInterpreter, result::MethodCallResult,
si::StmtInfo, match::MethodMatch, sv::AbsIntState)
if !InferenceParams(interp).ipo_constant_propagation
add_remark!(interp, sv, "[constprop] Disabled by parameter")
return false
return true
end
if is_no_constprop(match.method)
add_remark!(interp, sv, "[constprop] Disabled by method parameter")
return false
return true
end
return true
end

function bail_out_const_call(interp::AbstractInterpreter, result::MethodCallResult,
si::StmtInfo, sv::AbsIntState)
if is_removable_if_unused(result.effects)
if isa(result.rt, Const) || call_result_unused(si)
if isa(result.rt, Const)
add_remark!(interp, sv, "[constprop] No more information to be gained (const)")
return true
elseif call_result_unused(si)
add_remark!(interp, sv, "[constprop] No more information to be gained (unused result)")
return true
end
elseif result.rt === Bottom
end
if result.rt === Bottom
if is_terminates(result.effects) && is_effect_free(result.effects)
# In the future, we may want to add `&& isa(result.exct, Const)` to
# the list of conditions here, but currently, our effect system isn't
Expand Down

0 comments on commit 3ed49fd

Please sign in to comment.