diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 12eb9a03e323b..45f4dea1e46e1 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -897,7 +897,12 @@ function concrete_eval_eligible(interp::AbstractInterpreter, add_remark!(interp, sv, "[constprop] Concrete eval disabled for overlayed methods") end if !any_conditional(arginfo) - return :semi_concrete_eval + if may_optimize(interp) + return :semi_concrete_eval + else + # disable irinterp if optimization is disabled, since it requires optimized IR + add_remark!(interp, sv, "[constprop] Semi-concrete interpretation disabled for non-optimizing interpreter") + end end end return :none diff --git a/test/compiler/AbstractInterpreter.jl b/test/compiler/AbstractInterpreter.jl index 80288bac486ff..0b78d54803f7f 100644 --- a/test/compiler/AbstractInterpreter.jl +++ b/test/compiler/AbstractInterpreter.jl @@ -6,6 +6,17 @@ const CC = Core.Compiler include("irutils.jl") include("newinterp.jl") +# interpreter that performs abstract interpretation only +# (semi-concrete interpretation should be disabled automatically) +@newinterp AbsIntOnlyInterp1 +CC.may_optimize(::AbsIntOnlyInterp1) = false +@test Base.infer_return_type(Base.init_stdio, (Ptr{Cvoid},); interp=AbsIntOnlyInterp1()) >: IO + +# it should work even if the interpreter discards inferred source entirely +@newinterp AbsIntOnlyInterp2 +CC.may_optimize(::AbsIntOnlyInterp2) = false +CC.transform_result_for_cache(::AbsIntOnlyInterp2, ::Core.MethodInstance, ::CC.WorldRange, ::CC.InferenceResult) = nothing +@test Base.infer_return_type(Base.init_stdio, (Ptr{Cvoid},); interp=AbsIntOnlyInterp2()) >: IO # OverlayMethodTable # ==================