Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's called a Depth-First tree after all, not a dept-first-but-feel-free-to-record-any-of-the-parents tree. In particular, in order for the semi-dominator condition to hold, the parent in the DFS tree needs to be the predecessor with the highest DFS number. Here we were accidentally doing the opposite casuing us to look at the wrong node in case the sdom and the idom are not the same. To understand #31121, consider the following CFG (minimized from the bug report to show the issue), as well as the corresponding DFS numbering and sdom assignment ``` CFG DFS sdom A 1 0 | \ | \ |\ B C 2 5 1 1 /|/ /|/ /|/ | D | 3 | 1 \| \| \| E 4 2 ``` This bug caused us to record the parent of `E` as `B`, when it should have been `D` (the relevant invariant here is that the parent in the DFS tree is the predecessor with the highest DFS number). As a result, when computing idoms from the sdoms, we were incorrectly looking at `B`, seeing that the sdom matched the ancestor in the DFS tree and thus concluding that `E`'s idom was `B` rather than `A`. As a result, we neglected to insert a phi node in `E`. Fixes #31121
- Loading branch information