llvm.org GIT mirror llvm / 4ebcbff
An unreachable block may have a route to a reachable block, don't fast-path return that it can't. A block reachable from the entry block can't have any route to a block that's not reachable from the entry block (if it did, that route would make it reachable from the entry block). That is the intended performance optimization for isPotentiallyReachable. For the case where we ask whether an unreachable from entry block has a route to a reachable from entry block, we can't conclude one way or the other. Fix a bug where we claimed there could be no such route. The fix in rL357425 ironically reintroduced the very bug it was fixing but only when a DominatorTree is provided. This fixes the remaining bug. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357734 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 4 months ago
2 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
253253 }
254254
255255 if (DT) {
256 if (DT->isReachableFromEntry(A->getParent()) !=
257 DT->isReachableFromEntry(B->getParent()))
256 if (DT->isReachableFromEntry(A->getParent()) &&
257 !DT->isReachableFromEntry(B->getParent()))
258258 return false;
259259 if (!ExclusionSet || ExclusionSet->empty()) {
260260 if (A->getParent() == &A->getParent()->getParent()->getEntryBlock() &&
490490 "}");
491491 ExpectPath(true);
492492 }
493
494 TEST_F(IsPotentiallyReachableTest, UnreachableToReachable) {
495 ParseAssembly("define void @test() {\n"
496 "entry:\n"
497 " br label %exit\n"
498 "unreachableblock:\n"
499 " %A = bitcast i8 undef to i8\n"
500 " br label %exit\n"
501 "exit:\n"
502 " %B = bitcast i8 undef to i8\n"
503 " ret void\n"
504 "}");
505 ExpectPath(true);
506 }