SSAUpdater: don't mistake pre-existing block arguments for inserted phis - #91417
Open
eeckstein wants to merge 1 commit into
Open
SSAUpdater: don't mistake pre-existing block arguments for inserted phis#91417eeckstein wants to merge 1 commit into
eeckstein wants to merge 1 commit into
Conversation
`isPhi(in:)` returned true for _any_ block argument of a block, but both of its uses meant "a phi which this updater inserted into this block". If an available value happened to be a pre-existing block argument (e.g. a `switch_enum` payload argument), the guards misfired: * `clearValues` refused to invalidate the stale value in that block, so the block and its successors kept forwarding it. * `propagateValuesThrough` then never recomputed the block for the same reason. Consequently a join block could see the same value arriving from both the defining and the non-defining path, conclude that its predecessors agree, and skip the required phi. The value was then forwarded unconditionally on a path where it was never defined. This miscompiled nested loops with a conditional assignment in the inner loop: MandatoryRedundantLoadElimination turned the store of the inner loop's induction variable into an unconditional back-edge argument, so the variable was updated in every iteration instead of only when the condition held. Wrong code was generated even at -Onone. Track the blocks in which the updater inserted a phi in a `BasicBlockSet` and check that in addition to the value being an argument of the block. rdar://184416312
Contributor
Author
|
@swift-ci smoke test |
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.
isPhi(in:)returned true for any block argument of a block, but both of its uses meant "a phi which this updater inserted into this block". If an available value happened to be a pre-existing block argument (e.g. aswitch_enumpayload argument), the guards misfired:clearValuesrefused to invalidate the stale value in that block, so the block and its successors kept forwarding it.propagateValuesThroughthen never recomputed the block for the same reason.Consequently a join block could see the same value arriving from both the defining and the non-defining path, conclude that its predecessors agree, and skip the required phi. The value was then forwarded unconditionally on a path where it was never defined.
This miscompiled nested loops with a conditional assignment in the inner loop: MandatoryRedundantLoadElimination turned the store of the inner loop's induction variable into an unconditional back-edge argument, so the variable was updated in every iteration instead of only when the condition held. Wrong code was generated even at -Onone.
Track the blocks in which the updater inserted a phi in a
BasicBlockSetand check that in addition to the value being an argument of the block.rdar://184416312