From a80b5aaedb35341408096148972c480e3540efbe Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 30 Apr 2025 13:36:38 -0400 Subject: [PATCH] Revert "Strengthen language around `@assume_effects` :consistent (#58254)" This reverts the invalid functional changes from commit d7cd2710f6d919cd99e3b26a8056bbaeee74560c, keeping only the doc updates. --- Compiler/src/abstractinterpretation.jl | 14 ------------- Compiler/src/typeinfer.jl | 29 +++++++------------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/Compiler/src/abstractinterpretation.jl b/Compiler/src/abstractinterpretation.jl index 8d64575331e4a..924b83c4d2142 100644 --- a/Compiler/src/abstractinterpretation.jl +++ b/Compiler/src/abstractinterpretation.jl @@ -3527,20 +3527,6 @@ function merge_override_effects!(interp::AbstractInterpreter, effects::Effects, # It is possible for arguments (GlobalRef/:static_parameter) to throw, # but these will be recomputed during SSA construction later. override = decode_statement_effects_override(sv) - if override.consistent - m = sv.linfo.def - if isa(m, Method) - # N.B.: We'd like deleted_world here, but we can't add an appropriate edge at this point. - # However, in order to reach here in the first place, ordinary method lookup would have - # had to add an edge and appropriate invalidation trigger. - valid_worlds = WorldRange(m.primary_world, typemax(UInt)) - if sv.world.this in valid_worlds - update_valid_age!(sv, valid_worlds) - else - override = EffectsOverride(override, consistent=false) - end - end - end effects = override_effects(effects, override) set_curr_ssaflag!(sv, flags_for_effects(effects), IR_FLAGS_EFFECTS) merge_effects!(interp, sv, effects) diff --git a/Compiler/src/typeinfer.jl b/Compiler/src/typeinfer.jl index dacde593fe1f2..0af8b61e74970 100644 --- a/Compiler/src/typeinfer.jl +++ b/Compiler/src/typeinfer.jl @@ -469,17 +469,11 @@ function cycle_fix_limited(@nospecialize(typ), sv::InferenceState, cycleid::Int) return typ end -function adjust_effects(ipo_effects::Effects, def::Method, world::UInt) +function adjust_effects(ipo_effects::Effects, def::Method) # override the analyzed effects using manually annotated effect settings override = decode_effects_override(def.purity) - valid_worlds = WorldRange(0, typemax(UInt)) if is_effect_overridden(override, :consistent) - # See note on `typemax(Int)` instead of `deleted_world` in adjust_effects! - override_valid_worlds = WorldRange(def.primary_world, typemax(UInt)) - if world in override_valid_worlds - ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE) - valid_worlds = override_valid_worlds - end + ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE) end if is_effect_overridden(override, :effect_free) ipo_effects = Effects(ipo_effects; effect_free=ALWAYS_TRUE) @@ -507,7 +501,7 @@ function adjust_effects(ipo_effects::Effects, def::Method, world::UInt) if is_effect_overridden(override, :nortcall) ipo_effects = Effects(ipo_effects; nortcall=true) end - return (ipo_effects, valid_worlds) + return ipo_effects end function adjust_effects(sv::InferenceState) @@ -561,8 +555,7 @@ function adjust_effects(sv::InferenceState) # override the analyzed effects using manually annotated effect settings def = sv.linfo.def if isa(def, Method) - (ipo_effects, valid_worlds) = adjust_effects(ipo_effects, def, sv.world.this) - update_valid_age!(sv, valid_worlds) + ipo_effects = adjust_effects(ipo_effects, def) end return ipo_effects @@ -601,9 +594,9 @@ function finishinfer!(me::InferenceState, interp::AbstractInterpreter, cycleid:: end end result = me.result + result.valid_worlds = me.world.valid_worlds result.result = bestguess ipo_effects = result.ipo_effects = me.ipo_effects = adjust_effects(me) - result.valid_worlds = me.world.valid_worlds result.exc_result = me.exc_bestguess = refine_exception_type(me.exc_bestguess, ipo_effects) me.src.rettype = widenconst(ignorelimited(bestguess)) me.src.ssaflags = me.ssaflags @@ -1108,13 +1101,8 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize update_valid_age!(caller, frame.world.valid_worlds) local isinferred = is_inferred(frame) local edge = isinferred ? edge_ci : nothing - local effects, valid_worlds - if isinferred - effects = frame.result.ipo_effects # effects are adjusted already within `finish` for ipo_effects - else - (effects, valid_worlds) = adjust_effects(effects_for_cycle(frame.ipo_effects), method, frame.world.this) - update_valid_age!(caller, valid_worlds) - end + local effects = isinferred ? frame.result.ipo_effects : # effects are adjusted already within `finish` for ipo_effects + adjust_effects(effects_for_cycle(frame.ipo_effects), method) local bestguess = frame.bestguess local exc_bestguess = refine_exception_type(frame.exc_bestguess, effects) # propagate newly inferred source to the inliner, allowing efficient inlining w/o deserialization: @@ -1137,8 +1125,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize # return the current knowledge about this cycle frame = frame::InferenceState update_valid_age!(caller, frame.world.valid_worlds) - (effects, valid_worlds) = adjust_effects(effects_for_cycle(frame.ipo_effects), method, frame.world.this) - update_valid_age!(caller, valid_worlds) + effects = adjust_effects(effects_for_cycle(frame.ipo_effects), method) bestguess = frame.bestguess exc_bestguess = refine_exception_type(frame.exc_bestguess, effects) return Future(MethodCallResult(interp, caller, method, bestguess, exc_bestguess, effects, nothing, edgecycle, edgelimited))