X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FCaptureTracking.cpp;h=f2f8877af1a280dd44b49c1badf1aa5b6951eaf1;hb=1cb132f921c55f9584d06787b849ef0f255403b2;hp=e13c47a9bde784a1eac3d281597feaf6b2a8e6fe;hpb=8db585afaac3b5e1a4222d33b9abadac5c96f5f6;p=oota-llvm.git diff --git a/lib/Analysis/CaptureTracking.cpp b/lib/Analysis/CaptureTracking.cpp index e13c47a9bde..f2f8877af1a 100644 --- a/lib/Analysis/CaptureTracking.cpp +++ b/lib/Analysis/CaptureTracking.cpp @@ -57,14 +57,18 @@ namespace { /// Only support the case where the Value is defined in the same basic block /// as the given instruction and the use. struct CapturesBefore : public CaptureTracker { - CapturesBefore(bool ReturnCaptures, const Instruction *I, DominatorTree *DT) + CapturesBefore(bool ReturnCaptures, const Instruction *I, DominatorTree *DT, + bool IncludeI) : BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures), - Captured(false) {} + IncludeI(IncludeI), Captured(false) {} void tooManyUses() override { Captured = true; } bool shouldExplore(const Use *U) override { Instruction *I = cast(U->getUser()); + if (BeforeHere == I && !IncludeI) + return false; + 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. @@ -84,6 +88,9 @@ namespace { return false; Instruction *I = cast(U->getUser()); + if (BeforeHere == I && !IncludeI) + return false; + BasicBlock *BB = I->getParent(); // Same logic as in shouldExplore. if (BeforeHere != I && !DT->isReachableFromEntry(BB)) @@ -99,6 +106,7 @@ namespace { DominatorTree *DT; bool ReturnCaptures; + bool IncludeI; bool Captured; }; @@ -138,7 +146,7 @@ bool llvm::PointerMayBeCaptured(const Value *V, /// or not. bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, - DominatorTree *DT) { + DominatorTree *DT, bool IncludeI) { assert(!isa(V) && "It doesn't make sense to ask whether a global is captured."); @@ -148,7 +156,7 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, // TODO: See comment in PointerMayBeCaptured regarding what could be done // with StoreCaptures. - CapturesBefore CB(ReturnCaptures, I, DT); + CapturesBefore CB(ReturnCaptures, I, DT, IncludeI); PointerMayBeCaptured(V, &CB); return CB.Captured; }