[llvm] f765e54 - [CaptureTracking] Clean up same instruction check (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat May 15 02:59:08 PDT 2021
Author: Nikita Popov
Date: 2021-05-15T11:58:55+02:00
New Revision: f765e54db2f1bafeed4cf62fa0d03d66ff13e548
URL: https://github.com/llvm/llvm-project/commit/f765e54db2f1bafeed4cf62fa0d03d66ff13e548
DIFF: https://github.com/llvm/llvm-project/commit/f765e54db2f1bafeed4cf62fa0d03d66ff13e548.diff
LOG: [CaptureTracking] Clean up same instruction check (NFC)
Check the BeforeHere == I case once in shouldExplore, instead of
handling it in four different places.
Added:
Modified:
llvm/lib/Analysis/CaptureTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp
index 7c3b4c6dc57a..179b09da1725 100644
--- a/llvm/lib/Analysis/CaptureTracking.cpp
+++ b/llvm/lib/Analysis/CaptureTracking.cpp
@@ -106,10 +106,12 @@ namespace {
void tooManyUses() override { Captured = true; }
bool isSafeToPrune(Instruction *I) {
+ assert(I != BeforeHere && "Should have been handled earlier");
+
BasicBlock *BB = I->getParent();
// We explore this usage only if the usage can reach "BeforeHere".
// If use is not reachable from entry, there is no need to explore.
- if (BeforeHere != I && !DT->isReachableFromEntry(BB))
+ if (!DT->isReachableFromEntry(BB))
return true;
// Compute the case where both instructions are inside the same basic
@@ -121,7 +123,7 @@ namespace {
// if it dominates every instruction in UseBB. A PHI is dominated only
// if the instruction dominates every possible use in the UseBB. Since
// UseBB == BB, avoid pruning.
- if (isa<InvokeInst>(BeforeHere) || isa<PHINode>(I) || I == BeforeHere)
+ if (isa<InvokeInst>(BeforeHere) || isa<PHINode>(I))
return false;
if (!BeforeHere->comesBefore(I))
return false;
@@ -144,7 +146,7 @@ namespace {
// If the value is defined in the same basic block as use and BeforeHere,
// there is no need to explore the use if BeforeHere dominates use.
// Check whether there is a path from I to BeforeHere.
- if (BeforeHere != I && DT->dominates(BeforeHere, I) &&
+ if (DT->dominates(BeforeHere, I) &&
!isPotentiallyReachable(I, BeforeHere, nullptr, DT))
return true;
@@ -154,13 +156,10 @@ namespace {
bool shouldExplore(const Use *U) override {
Instruction *I = cast<Instruction>(U->getUser());
- if (BeforeHere == I && !IncludeI)
- return false;
+ if (BeforeHere == I)
+ return IncludeI;
- if (isSafeToPrune(I))
- return false;
-
- return true;
+ return !isSafeToPrune(I);
}
bool captured(const Use *U) override {
More information about the llvm-commits
mailing list