diff options
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/CaptureTracking.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp index 2596789..7c74c65 100644 --- a/llvm/lib/Analysis/CaptureTracking.cpp +++ b/llvm/lib/Analysis/CaptureTracking.cpp @@ -158,7 +158,8 @@ namespace { /// storing the value (or part of it) into memory anywhere automatically /// counts as capturing it or not. bool llvm::PointerMayBeCaptured(const Value *V, - bool ReturnCaptures, bool StoreCaptures) { + bool ReturnCaptures, bool StoreCaptures, + unsigned MaxUsesToExplore) { assert(!isa<GlobalValue>(V) && "It doesn't make sense to ask whether a global is captured."); @@ -186,7 +187,8 @@ bool llvm::PointerMayBeCaptured(const Value *V, bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI, - OrderedBasicBlock *OBB) { + OrderedBasicBlock *OBB, + unsigned MaxUsesToExplore) { assert(!isa<GlobalValue>(V) && "It doesn't make sense to ask whether a global is captured."); bool UseNewOBB = OBB == nullptr; @@ -207,22 +209,18 @@ bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, return CB.Captured; } -/// TODO: Write a new FunctionPass AliasAnalysis so that it can keep -/// a cache. Then we can move the code from BasicAliasAnalysis into -/// that path, and remove this threshold. -static unsigned const Threshold = 20; - -void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) { +void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker, + unsigned MaxUsesToExplore) { assert(V->getType()->isPointerTy() && "Capture is for pointers only!"); - SmallVector<const Use *, Threshold> Worklist; - SmallSet<const Use *, Threshold> Visited; + SmallVector<const Use *, DefaultMaxUsesToExplore> Worklist; + SmallSet<const Use *, DefaultMaxUsesToExplore> Visited; auto AddUses = [&](const Value *V) { unsigned Count = 0; for (const Use &U : V->uses()) { // If there are lots of uses, conservatively say that the value // is captured to avoid taking too much compile time. - if (Count++ >= Threshold) + if (Count++ >= MaxUsesToExplore) return Tracker->tooManyUses(); if (!Visited.insert(&U).second) continue; |