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 | fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0b (patch) | |
tree | 9fe2f2a8710310b2c62877dd3dec1b60ae471bf8 /lib/Analysis/AliasAnalysis.cpp | |
parent | d5b385c09f134ccd5f9ed6f7b6b7a9f3410c6d44 (diff) | |
download | external_llvm-fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0b.zip external_llvm-fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0b.tar.gz external_llvm-fc2a3ed0c9e32cf7edaf5030fa0972b916cc5f0b.tar.bz2 |
Make AliasAnalysis and related classes use
getAnalysisIfAvailable<TargetData>().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/AliasAnalysis.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index c5523ec..1d2efc1 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/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. /// |