From dd692a84faa2354aa334c2b72c90fe9a41979ab6 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Mon, 3 Jun 2024 17:29:53 +0900 Subject: [PATCH] apply Jameson' suggestion --- base/compiler/typeinfer.jl | 14 ++++++++++---- test/compiler/effects.jl | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index 1e319c2974b318..5abc92ee19eb79 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -236,15 +236,21 @@ function _typeinf(interp::AbstractInterpreter, frame::InferenceState) # with no active ip's, frame is done frames = frame.callers_in_cycle isempty(frames) && push!(frames, frame) - valid_worlds = WorldRange() + cycle_valid_worlds = WorldRange() + cycle_effects = EFFECTS_TOTAL for caller in frames @assert !(caller.dont_work_on_me) caller.dont_work_on_me = true - # might might not fully intersect these earlier, so do that now - valid_worlds = intersect(caller.valid_worlds, valid_worlds) + # converge the world age range and effects for this cycle here: + # all frames in the cycle should have the same bits of `valid_worlds` and `effects` + # that are simply the intersection of each partial computation, without having + # dependencies on each other (unlike rt and exct) + cycle_valid_worlds = intersect(cycle_valid_worlds, caller.valid_worlds) + cycle_effects = merge_effects(cycle_effects, caller.ipo_effects) end for caller in frames - caller.valid_worlds = valid_worlds + caller.valid_worlds = cycle_valid_worlds + caller.ipo_effects = cycle_effects finish(caller, caller.interp) end for caller in frames diff --git a/test/compiler/effects.jl b/test/compiler/effects.jl index 69ab79b83f0931..9d5dbc3983b72d 100644 --- a/test/compiler/effects.jl +++ b/test/compiler/effects.jl @@ -921,7 +921,7 @@ unknown_sparam_nothrow2(x::Ref{Ref{T}}) where T = (T; nothing) abstractly_recursive1() = abstractly_recursive2() abstractly_recursive2() = (Core.Compiler._return_type(abstractly_recursive1, Tuple{}); 1) abstractly_recursive3() = abstractly_recursive2() -@test Core.Compiler.is_terminates(Base.infer_effects(abstractly_recursive3, ())) +@test_broken Core.Compiler.is_terminates(Base.infer_effects(abstractly_recursive3, ())) actually_recursive1(x) = actually_recursive2(x) actually_recursive2(x) = (x <= 0) ? 1 : actually_recursive1(x - 1) actually_recursive3(x) = actually_recursive2(x)