We should excluded unreachable operands from processing as their DFS visitation order is undefined. When renameUses function sorts OpsToRename (https://fburl.com/d2wubn60), the comparator assumes that the parent block of the operand has a corresponding dominator tree node. This is not the case for unreachable operands and crashes the compiler.
Details
- Reviewers
• dberlin mgrang davide efriedma - Commits
- rZORG29f76bfd8bae: [PredicateInfo] Do not process unreachable operands.
rG29f76bfd8bae: [PredicateInfo] Do not process unreachable operands.
rG9d020de3e867: [PredicateInfo] Do not process unreachable operands.
rL360796: [PredicateInfo] Do not process unreachable operands.
Diff Detail
- Repository
- rL LLVM
Event Timeline
Testcase?
For any non-PHI instruction that is reachable, all of its operands must also be reachable. We can use this to reduce the number of places we need to check for reachability. I'm pretty sure the new checks in processSwitch and processBranch are useless: iterating over the domtree will not visit unreachable blocks. And we should probably add a check to PredicateInfo::buildPredicateInfo to avoid processing assumes in unreachable code, rather than checking the reachability of the operands of an assume.
Thank you for your comments @efriedma! I addressed your comments and added a test case. The test segfaults clang without proposed change.
LGTM with one minor comment.
llvm/lib/Transforms/Utils/PredicateInfo.cpp | ||
---|---|---|
476 ↗ | (On Diff #199648) | It would be more clear to use isReachableFromEntry (which does the same thing, but it has a better name). |