diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-11 21:50:19 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-11 21:50:19 +0000 |
commit | 65316d674914067bd0b6da080f8a7cf7c1aa0e78 (patch) | |
tree | dbbe995413eaf4a98c9a91bcda9189180b33266a /llvm/lib/Analysis | |
parent | bf65066a37ed3254b1a738e85af59057a1c688c5 (diff) | |
download | bcm5719-llvm-65316d674914067bd0b6da080f8a7cf7c1aa0e78.tar.gz bcm5719-llvm-65316d674914067bd0b6da080f8a7cf7c1aa0e78.zip |
Add helper functions for computing the Location of load, store,
and vaarg instructions.
llvm-svn: 118845
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 33 | ||||
-rw-r--r-- | llvm/lib/Analysis/MemDepPrinter.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 26 |
3 files changed, 30 insertions, 42 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 9c0bded3721..94a6d41872c 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -194,6 +194,24 @@ AliasAnalysis::getModRefBehavior(const Function *F) { // AliasAnalysis non-virtual helper method implementation //===----------------------------------------------------------------------===// +AliasAnalysis::Location AliasAnalysis::getLocation(const LoadInst *LI) { + return Location(LI->getPointerOperand(), + getTypeStoreSize(LI->getType()), + LI->getMetadata(LLVMContext::MD_tbaa)); +} + +AliasAnalysis::Location AliasAnalysis::getLocation(const StoreInst *SI) { + return Location(SI->getPointerOperand(), + getTypeStoreSize(SI->getValueOperand()->getType()), + SI->getMetadata(LLVMContext::MD_tbaa)); +} + +AliasAnalysis::Location AliasAnalysis::getLocation(const VAArgInst *VI) { + return Location(VI->getPointerOperand(), + UnknownSize, + VI->getMetadata(LLVMContext::MD_tbaa)); +} + AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) { // Be conservative in the face of volatile. @@ -202,10 +220,7 @@ AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) { // If the load address doesn't alias the given address, it doesn't read // or write the specified memory. - if (!alias(Location(L->getOperand(0), - getTypeStoreSize(L->getType()), - L->getMetadata(LLVMContext::MD_tbaa)), - Loc)) + if (!alias(getLocation(L), Loc)) return NoModRef; // Otherwise, a load just reads. @@ -220,10 +235,7 @@ AliasAnalysis::getModRefInfo(const StoreInst *S, const Location &Loc) { // If the store address cannot alias the pointer in question, then the // specified memory cannot be modified by the store. - if (!alias(Location(S->getOperand(1), - getTypeStoreSize(S->getOperand(0)->getType()), - S->getMetadata(LLVMContext::MD_tbaa)), - Loc)) + if (!alias(getLocation(S), Loc)) return NoModRef; // If the pointer is a pointer to constant memory, then it could not have been @@ -239,10 +251,7 @@ AliasAnalysis::ModRefResult AliasAnalysis::getModRefInfo(const VAArgInst *V, const Location &Loc) { // If the va_arg address cannot alias the pointer in question, then the // specified memory cannot be accessed by the va_arg. - if (!alias(Location(V->getOperand(0), - UnknownSize, - V->getMetadata(LLVMContext::MD_tbaa)), - Loc)) + if (!alias(getLocation(V), Loc)) return NoModRef; // If the pointer is a pointer to constant memory, then it could not have been diff --git a/llvm/lib/Analysis/MemDepPrinter.cpp b/llvm/lib/Analysis/MemDepPrinter.cpp index 90a7c576f07..64d215c37cc 100644 --- a/llvm/lib/Analysis/MemDepPrinter.cpp +++ b/llvm/lib/Analysis/MemDepPrinter.cpp @@ -102,22 +102,15 @@ bool MemDepPrinter::runOnFunction(Function &F) { SmallVector<NonLocalDepResult, 4> NLDI; if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) { // FIXME: Volatile is not handled properly here. - AliasAnalysis::Location Loc(LI->getPointerOperand(), - AA.getTypeStoreSize(LI->getType()), - LI->getMetadata(LLVMContext::MD_tbaa)); + AliasAnalysis::Location Loc = AA.getLocation(LI); MDA.getNonLocalPointerDependency(Loc, !LI->isVolatile(), LI->getParent(), NLDI); } else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { // FIXME: Volatile is not handled properly here. - AliasAnalysis::Location Loc(SI->getPointerOperand(), - AA.getTypeStoreSize(SI->getValueOperand() - ->getType()), - SI->getMetadata(LLVMContext::MD_tbaa)); + AliasAnalysis::Location Loc = AA.getLocation(SI); MDA.getNonLocalPointerDependency(Loc, false, SI->getParent(), NLDI); } else if (VAArgInst *VI = dyn_cast<VAArgInst>(Inst)) { - AliasAnalysis::Location Loc(SI->getPointerOperand(), - AliasAnalysis::UnknownSize, - SI->getMetadata(LLVMContext::MD_tbaa)); + AliasAnalysis::Location Loc = AA.getLocation(VI); MDA.getNonLocalPointerDependency(Loc, false, VI->getParent(), NLDI); } else { llvm_unreachable("Unknown memory instruction!"); diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 96af281c395..a16e334e020 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -115,9 +115,7 @@ AliasAnalysis::ModRefResult GetLocation(const Instruction *Inst, Loc = AliasAnalysis::Location(); return AliasAnalysis::ModRef; } - Loc = AliasAnalysis::Location(LI->getPointerOperand(), - AA->getTypeStoreSize(LI->getType()), - LI->getMetadata(LLVMContext::MD_tbaa)); + Loc = AA->getLocation(LI); return AliasAnalysis::Ref; } @@ -126,17 +124,12 @@ AliasAnalysis::ModRefResult GetLocation(const Instruction *Inst, Loc = AliasAnalysis::Location(); return AliasAnalysis::ModRef; } - Loc = AliasAnalysis::Location(SI->getPointerOperand(), - AA->getTypeStoreSize(SI->getValueOperand() - ->getType()), - SI->getMetadata(LLVMContext::MD_tbaa)); + Loc = AA->getLocation(SI); return AliasAnalysis::Mod; } if (const VAArgInst *V = dyn_cast<VAArgInst>(Inst)) { - Loc = AliasAnalysis::Location(V->getPointerOperand(), - AA->getTypeStoreSize(V->getType()), - V->getMetadata(LLVMContext::MD_tbaa)); + Loc = AA->getLocation(V); return AliasAnalysis::ModRef; } @@ -288,10 +281,7 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, // Values depend on loads if the pointers are must aliased. This means that // a load depends on another must aliased load from the same value. if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) { - Value *Pointer = LI->getPointerOperand(); - uint64_t PointerSize = AA->getTypeStoreSize(LI->getType()); - MDNode *TBAATag = LI->getMetadata(LLVMContext::MD_tbaa); - AliasAnalysis::Location LoadLoc(Pointer, PointerSize, TBAATag); + AliasAnalysis::Location LoadLoc = AA->getLocation(LI); // If we found a pointer, check if it could be the same as our pointer. AliasAnalysis::AliasResult R = AA->alias(LoadLoc, MemLoc); @@ -324,14 +314,10 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, // Ok, this store might clobber the query pointer. Check to see if it is // a must alias: in this case, we want to return this as a def. - Value *Pointer = SI->getPointerOperand(); - uint64_t PointerSize = AA->getTypeStoreSize(SI->getOperand(0)->getType()); - MDNode *TBAATag = SI->getMetadata(LLVMContext::MD_tbaa); + AliasAnalysis::Location StoreLoc = AA->getLocation(SI); // If we found a pointer, check if it could be the same as our pointer. - AliasAnalysis::AliasResult R = - AA->alias(AliasAnalysis::Location(Pointer, PointerSize, TBAATag), - MemLoc); + AliasAnalysis::AliasResult R = AA->alias(StoreLoc, MemLoc); if (R == AliasAnalysis::NoAlias) continue; |