-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
effects: look for :terminate_globally override in backedge termination check
#44106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
:terminates_locally with :terminate_globally setting:terminates_locally with :terminates_globally setting
0ffec99 to
57d386c
Compare
base/expr.jl
Outdated
| nothrow = true | ||
| elseif setting === :terminates_globally | ||
| terminates_globally = true | ||
| terminates_globally = terminates_locally = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering whether it would be better for debugging not to set this override and instead just also check for the global override also on the backedge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that sounds better.
Well, now I'm a bit confused about an expected usecase of :terminates_locally, since we usually take all control flow edges into account. Is it supposed to prove termination when constant propagation eliminates control flow edges that contain potentially-non-terminating calls?
57d386c to
27586a8
Compare
:terminates_locally with :terminates_globally setting:terminate_globally override in backedge termination check
…ation check (JuliaLang#44106) Now we can "fix" JuliaLang#41694: ```julia Base.@assume_effects :terminates_globally function issue41694(x) res = 1 1 < x < 20 || throw("bad") while x > 1 res *= x x -= 1 end return res end @test fully_eliminated() do issue41694(2) end ```
…ation check (JuliaLang#44106) Now we can "fix" JuliaLang#41694: ```julia Base.@assume_effects :terminates_globally function issue41694(x) res = 1 1 < x < 20 || throw("bad") while x > 1 res *= x x -= 1 end return res end @test fully_eliminated() do issue41694(2) end ```
…ation check (JuliaLang#44106) Now we can "fix" JuliaLang#41694: ```julia Base.@assume_effects :terminates_globally function issue41694(x) res = 1 1 < x < 20 || throw("bad") while x > 1 res *= x x -= 1 end return res end @test fully_eliminated() do issue41694(2) end ```
While working on #44515, I found we missed to override edge effect with effects set by `Base.@assume_effects`. This commit adds edge effect override mechanism for `:consistent`/`:effect_free`/`:nothrow` settings in the same way as we did for `:terminates_globally` in #44106. Now we can do something like: ```julia const ___CONST_DICT___ = Dict{Any,Any}(:a => 1, :b => 2) Base.@assume_effects :consistent :effect_free :terminates_globally consteval(f, args...) = f(args...) @test fully_eliminated() do consteval(getindex, ___CONST_DICT___, :a) end ```
While working on #44515, I found we missed to override edge effect with effects set by `Base.@assume_effects`. This commit adds edge effect override mechanism for `:consistent`/`:effect_free`/`:nothrow` settings in the same way as we did for `:terminates_globally` in #44106. Now we can do something like: ```julia const ___CONST_DICT___ = Dict{Any,Any}(:a => 1, :b => 2) Base.@assume_effects :consistent :effect_free :terminates_globally consteval(f, args...) = f(args...) @test fully_eliminated() do consteval(getindex, ___CONST_DICT___, :a) end ```
While working on #44515, I found we missed to override edge effect with effects set by `Base.@assume_effects`. This commit adds edge effect override mechanism for `:consistent`/`:effect_free`/`:nothrow` settings in the same way as we did for `:terminates_globally` in #44106. Now we can do something like: ```julia const ___CONST_DICT___ = Dict{Any,Any}(:a => 1, :b => 2) Base.@assume_effects :consistent :effect_free :terminates_globally consteval(f, args...) = f(args...) @test fully_eliminated() do consteval(getindex, ___CONST_DICT___, :a) end ```
Now we can "fix" #41694: