Skip to content

Commit 3ae69f6

Browse files
authored
Revert code changes from "strengthen assume_effects doc" PR (#58289)
Reverts only the functional changes from #58254, not the docs. Accessing this field here assumes that the counter valid is numeric and relevant to the current inference frame, neither of which is intended to be true, as we continue to add interfaces to execute methods outside of their current specific implementation with a monotonic world counter (e.g. with invoke on a Method, with precompile files, with external MethodTables, or with static compilation).
1 parent c7a092a commit 3ae69f6

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,20 +3527,6 @@ function merge_override_effects!(interp::AbstractInterpreter, effects::Effects,
35273527
# It is possible for arguments (GlobalRef/:static_parameter) to throw,
35283528
# but these will be recomputed during SSA construction later.
35293529
override = decode_statement_effects_override(sv)
3530-
if override.consistent
3531-
m = sv.linfo.def
3532-
if isa(m, Method)
3533-
# N.B.: We'd like deleted_world here, but we can't add an appropriate edge at this point.
3534-
# However, in order to reach here in the first place, ordinary method lookup would have
3535-
# had to add an edge and appropriate invalidation trigger.
3536-
valid_worlds = WorldRange(m.primary_world, typemax(UInt))
3537-
if sv.world.this in valid_worlds
3538-
update_valid_age!(sv, valid_worlds)
3539-
else
3540-
override = EffectsOverride(override, consistent=false)
3541-
end
3542-
end
3543-
end
35443530
effects = override_effects(effects, override)
35453531
set_curr_ssaflag!(sv, flags_for_effects(effects), IR_FLAGS_EFFECTS)
35463532
merge_effects!(interp, sv, effects)

Compiler/src/typeinfer.jl

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -469,17 +469,11 @@ function cycle_fix_limited(@nospecialize(typ), sv::InferenceState, cycleid::Int)
469469
return typ
470470
end
471471

472-
function adjust_effects(ipo_effects::Effects, def::Method, world::UInt)
472+
function adjust_effects(ipo_effects::Effects, def::Method)
473473
# override the analyzed effects using manually annotated effect settings
474474
override = decode_effects_override(def.purity)
475-
valid_worlds = WorldRange(0, typemax(UInt))
476475
if is_effect_overridden(override, :consistent)
477-
# See note on `typemax(Int)` instead of `deleted_world` in adjust_effects!
478-
override_valid_worlds = WorldRange(def.primary_world, typemax(UInt))
479-
if world in override_valid_worlds
480-
ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE)
481-
valid_worlds = override_valid_worlds
482-
end
476+
ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE)
483477
end
484478
if is_effect_overridden(override, :effect_free)
485479
ipo_effects = Effects(ipo_effects; effect_free=ALWAYS_TRUE)
@@ -507,7 +501,7 @@ function adjust_effects(ipo_effects::Effects, def::Method, world::UInt)
507501
if is_effect_overridden(override, :nortcall)
508502
ipo_effects = Effects(ipo_effects; nortcall=true)
509503
end
510-
return (ipo_effects, valid_worlds)
504+
return ipo_effects
511505
end
512506

513507
function adjust_effects(sv::InferenceState)
@@ -561,8 +555,7 @@ function adjust_effects(sv::InferenceState)
561555
# override the analyzed effects using manually annotated effect settings
562556
def = sv.linfo.def
563557
if isa(def, Method)
564-
(ipo_effects, valid_worlds) = adjust_effects(ipo_effects, def, sv.world.this)
565-
update_valid_age!(sv, valid_worlds)
558+
ipo_effects = adjust_effects(ipo_effects, def)
566559
end
567560

568561
return ipo_effects
@@ -601,9 +594,9 @@ function finishinfer!(me::InferenceState, interp::AbstractInterpreter, cycleid::
601594
end
602595
end
603596
result = me.result
597+
result.valid_worlds = me.world.valid_worlds
604598
result.result = bestguess
605599
ipo_effects = result.ipo_effects = me.ipo_effects = adjust_effects(me)
606-
result.valid_worlds = me.world.valid_worlds
607600
result.exc_result = me.exc_bestguess = refine_exception_type(me.exc_bestguess, ipo_effects)
608601
me.src.rettype = widenconst(ignorelimited(bestguess))
609602
me.src.ssaflags = me.ssaflags
@@ -1108,13 +1101,8 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
11081101
update_valid_age!(caller, frame.world.valid_worlds)
11091102
local isinferred = is_inferred(frame)
11101103
local edge = isinferred ? edge_ci : nothing
1111-
local effects, valid_worlds
1112-
if isinferred
1113-
effects = frame.result.ipo_effects # effects are adjusted already within `finish` for ipo_effects
1114-
else
1115-
(effects, valid_worlds) = adjust_effects(effects_for_cycle(frame.ipo_effects), method, frame.world.this)
1116-
update_valid_age!(caller, valid_worlds)
1117-
end
1104+
local effects = isinferred ? frame.result.ipo_effects : # effects are adjusted already within `finish` for ipo_effects
1105+
adjust_effects(effects_for_cycle(frame.ipo_effects), method)
11181106
local bestguess = frame.bestguess
11191107
local exc_bestguess = refine_exception_type(frame.exc_bestguess, effects)
11201108
# 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
11371125
# return the current knowledge about this cycle
11381126
frame = frame::InferenceState
11391127
update_valid_age!(caller, frame.world.valid_worlds)
1140-
(effects, valid_worlds) = adjust_effects(effects_for_cycle(frame.ipo_effects), method, frame.world.this)
1141-
update_valid_age!(caller, valid_worlds)
1128+
effects = adjust_effects(effects_for_cycle(frame.ipo_effects), method)
11421129
bestguess = frame.bestguess
11431130
exc_bestguess = refine_exception_type(frame.exc_bestguess, effects)
11441131
return Future(MethodCallResult(interp, caller, method, bestguess, exc_bestguess, effects, nothing, edgecycle, edgelimited))

0 commit comments

Comments
 (0)