ir: Don't accidentally consider pending statements from previous block #52863
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.
When IncremetnalCompact deletes and edge between blocks, it needs to go to the target and delete any reference to the edge from the PhiNodes therein. What happened in #52858, is that we had a situtation like:
To do the deletion, we use
CompactPeekIterator
, which gets a list of original statements and iterates over all the statements inside the range, including pending ones. However, there is a semantic confusion about whether to include all all statements since the previous statement (%a above), or only those statements that are actually attached to the first instruction (%b above). This of course doesn't really matter usually unless you're at a BasicBlock boundary.For the present case, we really do not want the instructions in the previous basic block - the iteration of PhiNodes terminates if it seems a stmt that cannot be in the phi block, so mistakenly seeing one of those instructions causes it to fail to fix a PhiNode that it should have, causing #52858.
We fix #52858 by giving the CompactPeekIterator a flag to only return stmts in the correct basic block. While we're at it, also fix the condition for what kinds of statements are allowed in the phi block, as that was clarified more recently than this code was written.