-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix condition for unreachable
code in IRCode conversion
#53512
Fix condition for unreachable
code in IRCode conversion
#53512
Conversation
Needs a test before this merges, but otherwise this should be good to go. As far as I can tell, this bug is present on 1.9 but I believe it is being masked by a difference in our 21 ┄ %58 = φᶜ (%85)::Base.GenericCondition{ReentrantLock}
│ φ (#20 => %59, #2 => %1)::Base.GenericCondition{ReentrantLock}
│ %71 = φᶜ (%86, %98)::Core.Compiler.MaybeUndef(Core.Const(nothing))
│ φ (#20 => %73, #2 => #undef)::Core.Compiler.MaybeUndef(Union{})
│ %76 = φᶜ (%87, %103)::Core.Compiler.MaybeUndef(Core.Const(nothing))
│ φ (#20 => %78, #2 => #undef)::Core.Compiler.MaybeUndef(Union{})
│ %81 = φᶜ (%88)::Core.Compiler.MaybeUndef(Union{})
│ φ (#20 => %82, #2 => #undef)::Core.Compiler.MaybeUndef(Union{})
└─── $(Expr(:leave, 1)) |
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.
LGTM
c8d1ad8
to
9f3f0a3
Compare
Maybe merge this @topolarity, while we're waiting on #53553? |
9f3f0a3
to
a028b62
Compare
This is a partial back-port of JuliaLang#50924, where we discovered that the optimizer would ignore: 1. must-throw `%XX = SlotNumber(_)` statements 2. must-throw `goto #bb if not %x` statements when re-building the CFG during IRCode conversion. This is mostly harmless, except that in the case of (1) we can accidentally fall through the statically deleted (`Const()`-wrapped) code from inference and observe a control-flow edge that never should have existed, such as an edge into a catch block. Such an edge is invalid semantically and breaks our SSA conversion. This one-line change fixes (1) but not (2), which is enough for IR validity. We should follow-up with a tweak to `compute_basic_blocks` to enforce this requirement. The test added here is very brittle, but it's better than nothing until we have utilities to provide hand-written (pre-optimizer) IR and pass it through part of our pipeline.
a028b62
to
fc7a881
Compare
035d17a
into
JuliaLang:kc/backports-release-1.10
…53512) This is a partial back-port of JuliaLang#50924, where we discovered that the optimizer would ignore: 1. must-throw `%XX = SlotNumber(_)` statements 2. must-throw `goto #bb if not %x` statements This is mostly harmless, except that in the case of (1) we can accidentally fall through the statically deleted (`Const()`-wrapped) code from inference and end up observing a control-flow edge that never existed. If the spurious edge is to a catch block, then the edge is invalid semantically and breaks our SSA conversion. This one-line change fixes (1) but not (2), which is enough for IR validity. Resolves part of JuliaLang#53366. (cherry picked from commit 035d17a)
This is a partial back-port of #50924, where we discovered that the optimizer would ignore:
%XX = SlotNumber(_)
statementsgoto #bb if not %x
statementsThis is mostly harmless, except that in the case of (1) we can accidentally fall through the statically deleted (
Const()
-wrapped) code from inference and end up observing a control-flow edge that never existed.If the spurious edge is to a catch block, then the edge is invalid semantically and breaks our SSA conversion.
This one-line change fixes (1) but not (2), which is enough for IR validity.
Resolves part of #53366.