[llvm] 6418bab - [CFG] Use comesBefore() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat May 15 03:17:41 PDT 2021
Author: Nikita Popov
Date: 2021-05-15T12:14:30+02:00
New Revision: 6418bab6f8827960b9d161f5c9c2b8f9702c80e0
URL: https://github.com/llvm/llvm-project/commit/6418bab6f8827960b9d161f5c9c2b8f9702c80e0
DIFF: https://github.com/llvm/llvm-project/commit/6418bab6f8827960b9d161f5c9c2b8f9702c80e0.diff
LOG: [CFG] Use comesBefore() (NFC)
Use comesBefore() instead of performing an instruction walk. In
line with the previous implementation, instructions are considered
to reach themselves.
Added:
Modified:
llvm/lib/Analysis/CFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/CFG.cpp b/llvm/lib/Analysis/CFG.cpp
index 33602ed71675..9b26c38e4916 100644
--- a/llvm/lib/Analysis/CFG.cpp
+++ b/llvm/lib/Analysis/CFG.cpp
@@ -242,12 +242,9 @@ bool llvm::isPotentiallyReachable(
if (LI && LI->getLoopFor(BB) != nullptr)
return true;
- // Linear scan, start at 'A', see whether we hit 'B' or the end first.
- for (BasicBlock::const_iterator I = A->getIterator(), E = BB->end(); I != E;
- ++I) {
- if (&*I == B)
- return true;
- }
+ // If A comes before B, then B is definitively reachable from A.
+ if (A == B || A->comesBefore(B))
+ return true;
// Can't be in a loop if it's the entry block -- the entry block may not
// have predecessors.
More information about the llvm-commits
mailing list