Always rewrite GotoIfNot with unreachable branches#51062
Merged
topolarity merged 1 commit intoJuliaLang:masterfrom Aug 28, 2023
Merged
Always rewrite GotoIfNot with unreachable branches#51062topolarity merged 1 commit intoJuliaLang:masterfrom
topolarity merged 1 commit intoJuliaLang:masterfrom
Conversation
Member
Author
|
kudos to @maleadt for the heads up on the PkgEval failures |
Member
|
Add a test, please, otherwise LGTM. |
Keno
approved these changes
Aug 26, 2023
This resolves a regression introduced in JuliaLang#50943 (comment) The problem was that we now expect the explicit CFG of the IR to correspond 1-1 in terms of reachability to the information we get from inference. That means that we have to unconditionally re-write control flow to match the branches that inference ended up actually exploring. This change also modifies Inference to update the ssaflags on GotoIfNot and GotoNode statements, so that we can be sure these `@assert`s will trip if Inference is ever made smart enough to fold Union{Const(true), Float64}-style conditions.
57abcb0 to
4d3de1a
Compare
Member
Author
|
Test coverage added. Should be ready to land after approval and passing CI. This now has an assert so that it will not silently break if Inference gets smart enough to partially-explore |
Keno
approved these changes
Aug 28, 2023
Keno
reviewed
Aug 28, 2023
| end | ||
| condval = maybe_extract_const_bool(condt) | ||
| nothrow = (condval !== nothing) || ⊑(𝕃ᵢ, orig_condt, Bool) | ||
| nothrow && add_curr_ssaflag!(frame, IR_FLAG_NOTHROW) |
Member
There was a problem hiding this comment.
There's some additional issues here where the merge_effects! down below isn't in the right place, but I'm already fixing that in #50805.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves a regression introduced in #50943 (comment)
That PR requires the Goto/GotoIfNot statements of the IR to correspond 1-1 (in terms of reachability) to the information we get from inference. To make that happen, we have to unconditionally re-write control flow to match the branches that inference ended up actually exploring.
The problem is that we were choosing not to do this if the GotoIfNot condition seemed to be maybe-non-Boolean.
Thankfully, it turns out that check is unnecessary because Inference when following conditionals does not consider "true or non-Bool" etc. If it did, we'd instead have to re-write these branches as a
typeassert; gototo encode the reachability