diff options
author | Dan Gohman <gohman@apple.com> | 2009-11-19 21:57:48 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-11-19 21:57:48 +0000 |
commit | 94e617627d06af901a12526a176cbfb67835e6d9 (patch) | |
tree | 68b59578330dbad228e938b3367a198d2b22a3a4 /llvm/lib/Analysis/CaptureTracking.cpp | |
parent | b6c7704a8df88e8b4e975af7e52b78c198e72daf (diff) | |
download | llvm-94e617627d06af901a12526a176cbfb67835e6d9.zip llvm-94e617627d06af901a12526a176cbfb67835e6d9.tar.gz llvm-94e617627d06af901a12526a176cbfb67835e6d9.tar.bz2 |
Extend CaptureTracking to indicate when a value is never stored, even
if it is not ultimately captured. Teach BasicAliasAnalysis that a
local object address which does not escape and is never stored does
not alias with a value resulting from a load.
llvm-svn: 89398
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/CaptureTracking.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp index 7cd055dcd..ae0766b 100644 --- a/llvm/lib/Analysis/CaptureTracking.cpp +++ b/llvm/lib/Analysis/CaptureTracking.cpp @@ -28,8 +28,11 @@ using namespace llvm; /// by the enclosing function (which is required to exist). This routine can /// be expensive, so consider caching the results. The boolean ReturnCaptures /// specifies whether returning the value (or part of it) from the function +/// counts as capturing it or not. The boolean StoreCaptures specified whether +/// 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 llvm::PointerMayBeCaptured(const Value *V, + bool ReturnCaptures, bool StoreCaptures) { assert(isa<PointerType>(V->getType()) && "Capture is for pointers only!"); SmallVector<Use*, 16> Worklist; SmallSet<Use*, 16> Visited; @@ -82,7 +85,11 @@ bool llvm::PointerMayBeCaptured(const Value *V, bool ReturnCaptures) { break; case Instruction::Store: if (V == I->getOperand(0)) - // Stored the pointer - it may be captured. + // Stored the pointer - conservatively assume it may be captured. + // TODO: If StoreCaptures is not true, we could do Fancy analysis + // to determine whether this store is not actually an escape point. + // In that case, BasicAliasAnalysis should be updated as well to + // take advantage of this. return true; // Storing to the pointee does not cause the pointer to be captured. break; |