Skip to content

Commit b0d25d0

Browse files
aviateskKristofferC
authored andcommitted
absint: allow ad-hoc cancellation of concrete evaluation (#59908)
This change is not necessary for `NativeInterpreter` at all, but is particularly useful for JET. For error reporting, which is the purpose of `JETAnalyzer`, it is desirable to present error causes in a user-understandable form even when concrete evaluation presents errors. This requires analysis using regular abstract interpretation (constant propagation) in general. However, to reduce false positives, the precision that concrete evaluation brings is very important, and completely disabling concrete evaluation is not desirable either. Currently, `JETAnalyzer` aims to avoid this tradeoff by limiting concrete evaluation to only some functions, but this approach does not scale and occasionally causes problems like #59884. This commit enables ad-hoc cancellation of concrete evaluation based on the result of `concrete_eval_call`, allowing `JETAnalyzer` to fallback to abstract interpretation only when concrete evaluation causes errors, fundamentally avoiding such problems. (cherry picked from commit c6091de)
1 parent b074437 commit b0d25d0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,11 +872,12 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter,
872872
concrete_eval_result = nothing
873873
if eligibility === :concrete_eval
874874
concrete_eval_result = concrete_eval_call(interp, f, result, arginfo, sv, invokecall)
875-
# if we don't inline the result of this concrete evaluation,
876-
# give const-prop' a chance to inline a better method body
877-
if !may_optimize(interp) || (
878-
may_inline_concrete_result(concrete_eval_result.const_result::ConcreteResult) ||
879-
concrete_eval_result.rt === Bottom) # unless this call deterministically throws and thus is non-inlineable
875+
if (concrete_eval_result !== nothing && # allow external abstract interpreters to disable concrete evaluation ad-hoc
876+
# if we don't inline the result of this concrete evaluation,
877+
# give const-prop' a chance to inline a better method body
878+
(!may_optimize(interp) ||
879+
may_inline_concrete_result(concrete_eval_result.const_result::ConcreteResult) ||
880+
concrete_eval_result.rt === Bottom)) # unless this call deterministically throws and thus is non-inlineable
880881
return concrete_eval_result
881882
end
882883
# TODO allow semi-concrete interp for this call?

0 commit comments

Comments
 (0)