aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/CaptureTracking.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-09-24 09:56:56 -0400
committerNico Weber <thakis@chromium.org>2021-09-24 09:57:59 -0400
commitdf56fc6ebbee6c458b0473185277b7860f7e3408 (patch)
tree20927e536302e5a75bdca316525715910fd7c097 /llvm/lib/Analysis/CaptureTracking.cpp
parent626e2a6c6236d2fd7582928a0363d381c55eb43d (diff)
downloadllvm-df56fc6ebbee6c458b0473185277b7860f7e3408.zip
llvm-df56fc6ebbee6c458b0473185277b7860f7e3408.tar.gz
llvm-df56fc6ebbee6c458b0473185277b7860f7e3408.tar.bz2
Revert "[DSE] Track earliest escape, use for loads in isReadClobber."
This reverts commit 5ce89279c0986d0bcbe526dce52f91dd0c16427c. Makes clang crash, see comments on https://reviews.llvm.org/D109844
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r--llvm/lib/Analysis/CaptureTracking.cpp76
1 files changed, 0 insertions, 76 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp
index 8955658..49fc65f6 100644
--- a/llvm/lib/Analysis/CaptureTracking.cpp
+++ b/llvm/lib/Analysis/CaptureTracking.cpp
@@ -143,66 +143,6 @@ namespace {
const LoopInfo *LI;
};
-
- /// Find the 'earliest' instruction before which the pointer is known not to
- /// be captured. Here an instruction A is considered earlier than instruction
- /// B, if A dominates B. If 2 escapes do not dominate each other, the
- /// terminator of the common dominator is chosen. If not all uses cannot be
- /// analyzed, the earliest escape is set to the first instruction in the
- /// function entry block.
- // NOTE: Users have to make sure instructions compared against the earliest
- // escape are not in a cycle.
- struct EarliestCaptures : public CaptureTracker {
-
- EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT)
- : DT(DT), ReturnCaptures(ReturnCaptures), Captured(false), F(F) {}
-
- void tooManyUses() override {
- Captured = true;
- EarliestCapture = &*F.getEntryBlock().begin();
- }
-
- bool captured(const Use *U) override {
- Instruction *I = cast<Instruction>(U->getUser());
- if (isa<ReturnInst>(I) && !ReturnCaptures)
- return false;
-
- if (!EarliestCapture) {
- EarliestCapture = I;
- } else if (EarliestCapture->getParent() == I->getParent()) {
- if (I->comesBefore(EarliestCapture))
- EarliestCapture = I;
- } else {
- BasicBlock *CurrentBB = I->getParent();
- BasicBlock *EarliestBB = EarliestCapture->getParent();
- if (DT.dominates(EarliestBB, CurrentBB)) {
- // EarliestCapture already comes before the current use.
- } else if (DT.dominates(CurrentBB, EarliestBB)) {
- EarliestCapture = I;
- } else {
- // Otherwise find the nearest common dominator and use its terminator.
- auto *NearestCommonDom =
- DT.findNearestCommonDominator(CurrentBB, EarliestBB);
- EarliestCapture = NearestCommonDom->getTerminator();
- }
- }
- Captured = true;
-
- // Return false to continue analysis; we need to see all potential
- // captures.
- return false;
- }
-
- Instruction *EarliestCapture = nullptr;
-
- const DominatorTree &DT;
-
- bool ReturnCaptures;
-
- bool Captured;
-
- Function &F;
- };
}
/// PointerMayBeCaptured - Return true if this pointer value may be captured
@@ -266,22 +206,6 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
return CB.Captured;
}
-Instruction *llvm::FindEarliestCapture(const Value *V, Function &F,
- bool ReturnCaptures, bool StoreCaptures,
- const DominatorTree &DT,
- unsigned MaxUsesToExplore) {
- assert(!isa<GlobalValue>(V) &&
- "It doesn't make sense to ask whether a global is captured.");
-
- EarliestCaptures CB(ReturnCaptures, F, DT);
- PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
- if (CB.Captured)
- ++NumCapturedBefore;
- else
- ++NumNotCapturedBefore;
- return CB.EarliestCapture;
-}
-
void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
unsigned MaxUsesToExplore) {
assert(V->getType()->isPointerTy() && "Capture is for pointers only!");