Skip to content

Commit c688e27

Browse files
committed
Revert "Strengthen language around @assume_effects :consistent (#58254)"
This reverts the invalid functional changes from commit d7cd271, keeping only the doc updates.
1 parent 3864b18 commit c688e27

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
@@ -3499,20 +3499,6 @@ function merge_override_effects!(interp::AbstractInterpreter, effects::Effects,
34993499
# It is possible for arguments (GlobalRef/:static_parameter) to throw,
35003500
# but these will be recomputed during SSA construction later.
35013501
override = decode_statement_effects_override(sv)
3502-
if override.consistent
3503-
m = sv.linfo.def
3504-
if isa(m, Method)
3505-
# N.B.: We'd like deleted_world here, but we can't add an appropriate edge at this point.
3506-
# However, in order to reach here in the first place, ordinary method lookup would have
3507-
# had to add an edge and appropriate invalidation trigger.
3508-
valid_worlds = WorldRange(m.primary_world, typemax(Int))
3509-
if sv.world.this in valid_worlds
3510-
update_valid_age!(sv, valid_worlds)
3511-
else
3512-
override = EffectsOverride(override, consistent=false)
3513-
end
3514-
end
3515-
end
35163502
effects = override_effects(effects, override)
35173503
set_curr_ssaflag!(sv, flags_for_effects(effects), IR_FLAGS_EFFECTS)
35183504
merge_effects!(interp, sv, effects)

Compiler/src/typeinfer.jl

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

474-
function adjust_effects(ipo_effects::Effects, def::Method, world::UInt)
474+
function adjust_effects(ipo_effects::Effects, def::Method)
475475
# override the analyzed effects using manually annotated effect settings
476476
override = decode_effects_override(def.purity)
477-
valid_worlds = WorldRange(0, typemax(UInt))
478477
if is_effect_overridden(override, :consistent)
479-
# See note on `typemax(Int)` instead of `deleted_world` in adjust_effects!
480-
override_valid_worlds = WorldRange(def.primary_world, typemax(Int))
481-
if world in override_valid_worlds
482-
ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE)
483-
valid_worlds = override_valid_worlds
484-
end
478+
ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE)
485479
end
486480
if is_effect_overridden(override, :effect_free)
487481
ipo_effects = Effects(ipo_effects; effect_free=ALWAYS_TRUE)
@@ -509,7 +503,7 @@ function adjust_effects(ipo_effects::Effects, def::Method, world::UInt)
509503
if is_effect_overridden(override, :nortcall)
510504
ipo_effects = Effects(ipo_effects; nortcall=true)
511505
end
512-
return (ipo_effects, valid_worlds)
506+
return ipo_effects
513507
end
514508

515509
function adjust_effects(sv::InferenceState)
@@ -563,8 +557,7 @@ function adjust_effects(sv::InferenceState)
563557
# override the analyzed effects using manually annotated effect settings
564558
def = sv.linfo.def
565559
if isa(def, Method)
566-
(ipo_effects, valid_worlds) = adjust_effects(ipo_effects, def, sv.world.this)
567-
update_valid_age!(sv, valid_worlds)
560+
ipo_effects = adjust_effects(ipo_effects, def)
568561
end
569562

570563
return ipo_effects
@@ -602,9 +595,9 @@ function finishinfer!(me::InferenceState, interp::AbstractInterpreter, cycleid::
602595
end
603596
end
604597
result = me.result
598+
result.valid_worlds = me.world.valid_worlds
605599
result.result = bestguess
606600
ipo_effects = result.ipo_effects = me.ipo_effects = adjust_effects(me)
607-
result.valid_worlds = me.world.valid_worlds
608601
result.exc_result = me.exc_bestguess = refine_exception_type(me.exc_bestguess, ipo_effects)
609602
me.src.rettype = widenconst(ignorelimited(bestguess))
610603
me.src.ssaflags = me.ssaflags
@@ -1067,13 +1060,8 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
10671060
update_valid_age!(caller, frame.world.valid_worlds)
10681061
local isinferred = is_inferred(frame)
10691062
local edge = isinferred ? edge_ci : nothing
1070-
local effects, valid_worlds
1071-
if isinferred
1072-
effects = frame.result.ipo_effects # effects are adjusted already within `finish` for ipo_effects
1073-
else
1074-
(effects, valid_worlds) = adjust_effects(effects_for_cycle(frame.ipo_effects), method, frame.world.this)
1075-
update_valid_age!(caller, valid_worlds)
1076-
end
1063+
local effects = isinferred ? frame.result.ipo_effects : # effects are adjusted already within `finish` for ipo_effects
1064+
adjust_effects(effects_for_cycle(frame.ipo_effects), method)
10771065
local bestguess = frame.bestguess
10781066
local exc_bestguess = refine_exception_type(frame.exc_bestguess, effects)
10791067
# propagate newly inferred source to the inliner, allowing efficient inlining w/o deserialization:
@@ -1096,8 +1084,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
10961084
# return the current knowledge about this cycle
10971085
frame = frame::InferenceState
10981086
update_valid_age!(caller, frame.world.valid_worlds)
1099-
(effects, valid_worlds) = adjust_effects(effects_for_cycle(frame.ipo_effects), method, frame.world.this)
1100-
update_valid_age!(caller, valid_worlds)
1087+
effects = adjust_effects(effects_for_cycle(frame.ipo_effects), method)
11011088
bestguess = frame.bestguess
11021089
exc_bestguess = refine_exception_type(frame.exc_bestguess, effects)
11031090
return Future(MethodCallResult(interp, caller, method, bestguess, exc_bestguess, effects, nothing, edgecycle, edgelimited))

0 commit comments

Comments
 (0)