[4.0] Fix dominator tree update in array specialization #12122
Merged
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.
We need to walk the dominator tree starting at the header and update the
dominator of all nodes outside the loop we hit i.e the dominator tree nodes that
are immediately dominated 'by the loop' instead of only updating dominated exit
blocks.
Explanation: The dominator tree update in array specialization pass is broken in cases where there are blocks outside the loop that are dominated by the loop but are not exit blocks. As a result the dominator tree was not correctly updated and we would detect this and crash in the compiler when run with -sil-verify-all. We used to only update exit blocks that are dominated by the loop header. The fix is to walk the dominator tree starting from the header and update all blocks that are immediately dominated by the loop (i.e first blocks that we hit along the domtree walk that are not loop blocks).
Scope of Issue: This bug has existed since the introduction of the array specialization pass.
Risk: Low. Should only affect cases that were failing before
Testing: Added swift regression test
rdar://34523864