summaryrefslogtreecommitdiff
path: root/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-11-11 21:50:19 +0000
committerDan Gohman <gohman@apple.com>2010-11-11 21:50:19 +0000
commit6d8eb156e6be727570b300bac7712f745a318c7d (patch)
treecd4250cc4395e8077f2dac80017fbe44ae96a94b /lib/Analysis/AliasAnalysis.cpp
parentef5b390263ebe6e22c89cb16faebf0fb3c4ce1ee (diff)
downloadllvm-6d8eb156e6be727570b300bac7712f745a318c7d.tar.gz
llvm-6d8eb156e6be727570b300bac7712f745a318c7d.tar.bz2
llvm-6d8eb156e6be727570b300bac7712f745a318c7d.tar.xz
Add helper functions for computing the Location of load, store,
and vaarg instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--lib/Analysis/AliasAnalysis.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp
index 9c0bded372..94a6d41872 100644
--- a/lib/Analysis/AliasAnalysis.cpp
+++ b/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