diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-25 00:48:42 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-25 00:48:42 +0000 |
commit | 43d19d61d4ab124462152de2e0848ce4b2d8bdbe (patch) | |
tree | 8e538a4de4f5983ae947a898d140bc7debf7a117 /llvm/lib/Analysis/AliasAnalysis.cpp | |
parent | 67395e7c2c1c9ed95b147bd13ff25cf8b9983685 (diff) | |
download | bcm5719-llvm-43d19d61d4ab124462152de2e0848ce4b2d8bdbe.tar.gz bcm5719-llvm-43d19d61d4ab124462152de2e0848ce4b2d8bdbe.zip |
Make AliasAnalysis and related classes use
getAnalysisIfAvailable<TargetData>().
llvm-svn: 77028
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index c5523ec4634..1d2efc1eda0 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -88,7 +88,7 @@ AliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) { AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) { - return alias(L->getOperand(0), TD->getTypeStoreSize(L->getType()), + return alias(L->getOperand(0), getTypeStoreSize(L->getType()), P, Size) ? Ref : NoModRef; } @@ -97,7 +97,7 @@ AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) { // If the stored address cannot alias the pointer in question, then the // pointer cannot be modified by the store. if (!alias(S->getOperand(1), - TD->getTypeStoreSize(S->getOperand(0)->getType()), P, Size)) + getTypeStoreSize(S->getOperand(0)->getType()), P, Size)) return NoModRef; // If the pointer is a pointer to constant memory, then it could not have been @@ -177,18 +177,23 @@ AliasAnalysis::~AliasAnalysis() {} /// AliasAnalysis interface before any other methods are called. /// void AliasAnalysis::InitializeAliasAnalysis(Pass *P) { - TD = &P->getAnalysis<TargetData>(); + TD = P->getAnalysisIfAvailable<TargetData>(); AA = &P->getAnalysis<AliasAnalysis>(); } // getAnalysisUsage - All alias analysis implementations should invoke this -// directly (using AliasAnalysis::getAnalysisUsage(AU)) to make sure that -// TargetData is required by the pass. +// directly (using AliasAnalysis::getAnalysisUsage(AU)). void AliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired<TargetData>(); // All AA's need TargetData. AU.addRequired<AliasAnalysis>(); // All AA's chain } +/// getTypeStoreSize - Return the TargetData store size for the given type, +/// if known, or a conservative value otherwise. +/// +unsigned AliasAnalysis::getTypeStoreSize(const Type *Ty) { + return TD ? TD->getTypeStoreSize(Ty) : ~0u; +} + /// canBasicBlockModify - Return true if it is possible for execution of the /// specified basic block to modify the value pointed to by Ptr. /// |