Skip to content

Commit 3ed49fd

Browse files
authored
absint: merge const_prop_enabled into bail_out_const_call (#52921)
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.
1 parent b4f7263 commit 3ed49fd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ end
814814
function abstract_call_method_with_const_args(interp::AbstractInterpreter,
815815
result::MethodCallResult, @nospecialize(f), arginfo::ArgInfo, si::StmtInfo,
816816
match::MethodMatch, sv::AbsIntState, invokecall::Union{Nothing,InvokeCall}=nothing)
817-
if !const_prop_enabled(interp, match, sv) || bail_out_const_call(interp, result, si, sv)
817+
if bail_out_const_call(interp, result, si, match, sv)
818818
return nothing
819819
end
820820
eligibility = concrete_eval_eligible(interp, f, result, arginfo, sv)
@@ -847,26 +847,26 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter,
847847
return const_prop_call(interp, mi, result, arginfo, sv, concrete_eval_result)
848848
end
849849

850-
function const_prop_enabled(interp::AbstractInterpreter, match::MethodMatch, sv::AbsIntState)
850+
function bail_out_const_call(interp::AbstractInterpreter, result::MethodCallResult,
851+
si::StmtInfo, match::MethodMatch, sv::AbsIntState)
851852
if !InferenceParams(interp).ipo_constant_propagation
852853
add_remark!(interp, sv, "[constprop] Disabled by parameter")
853-
return false
854+
return true
854855
end
855856
if is_no_constprop(match.method)
856857
add_remark!(interp, sv, "[constprop] Disabled by method parameter")
857-
return false
858+
return true
858859
end
859-
return true
860-
end
861-
862-
function bail_out_const_call(interp::AbstractInterpreter, result::MethodCallResult,
863-
si::StmtInfo, sv::AbsIntState)
864860
if is_removable_if_unused(result.effects)
865-
if isa(result.rt, Const) || call_result_unused(si)
861+
if isa(result.rt, Const)
866862
add_remark!(interp, sv, "[constprop] No more information to be gained (const)")
867863
return true
864+
elseif call_result_unused(si)
865+
add_remark!(interp, sv, "[constprop] No more information to be gained (unused result)")
866+
return true
868867
end
869-
elseif result.rt === Bottom
868+
end
869+
if result.rt === Bottom
870870
if is_terminates(result.effects) && is_effect_free(result.effects)
871871
# In the future, we may want to add `&& isa(result.exct, Const)` to
872872
# the list of conditions here, but currently, our effect system isn't

0 commit comments

Comments
 (0)