Skip to content
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

irinterp: Don't introduce invalid CFGs #49797

Merged
merged 1 commit into from
May 13, 2023
Merged

irinterp: Don't introduce invalid CFGs #49797

merged 1 commit into from
May 13, 2023

Conversation

Keno
Copy link
Member

@Keno Keno commented May 12, 2023

This is yet another followup to #49692 and #49750.
With the introduced change, we kill the CFG edge from the basic block with the discovered error to its successors.
However, we have an invariant in the verifier that the CFG should always match the IR.
Turns out this is for good reason, as we assume in a number of places (including, ironically in the irinterp) that a GotoNode/GotoIfNot terminator means that the BB has the corresponding number of successors in the IR. Fix all this by killing the rest of the basic block when we discover that it is unreachable and if possible introducing an unreachable node at the end.
However, of course if the erroring statement is the fallthrough terminator itself, there is no space for an unreachable node. We fix this by tweaking the verification to allow this case, as its really no worse than the other problems with fall-through terminators (#41476), but of course it would be good to address that as part of a more general IR refactor.

This is yet another followup to #49692 and #49750.
With the introduced change, we kill the CFG edge
from the basic block with the discovered error to
its successors. However, we have an invariant in
the verifier that the CFG should always match the
IR. Turns out this is for good reason, as we assume
in a number of places (including, ironically in the
irinterp) that a GotoNode/GotoIfNot terminator means
that the BB has the corresponding number of successors
in the IR. Fix all this by killing the rest of the basic
block when we discover that it is unreachable and if
possible introducing an unreachable node at the end.
However, of course if the erroring statement is the
fallthrough terminator itself, there is no space for
an unreachable node. We fix this by tweaking the
verification to allow this case, as its really
no worse than the other problems with fall-through
terminators (#41476), but of course it would be good
to address that as part of a more general IR refactor.
@Keno Keno merged commit 7e1431f into master May 13, 2023
@Keno Keno deleted the kf/irinterpinvalid2 branch May 13, 2023 21:27
Keno added a commit that referenced this pull request May 14, 2023
If a fall-through terminator was already Bottom, we should not attempt
to rekill the successor edge, because it was already deleted.
Yet another fix in the #49692, #49750, #49797 series, which is
turning out to be quite a rabit hole. Also fix a typo in the
verifer tweak where we were looking at the BB idx rather than
the terminator idx.
Keno added a commit that referenced this pull request May 15, 2023
If a fall-through terminator was already Bottom, we should not attempt
to rekill the successor edge, because it was already deleted.
Yet another fix in the #49692, #49750, #49797 series, which is
turning out to be quite a rabit hole. Also fix a typo in the
verifer tweak where we were looking at the BB idx rather than
the terminator idx.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant