summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2015-04-13 23:25:41 +0000
committerDaniel Berlin <dberlin@dberlin.org>2015-04-13 23:25:41 +0000
commit8de312d2a991c3f360576b426e0f1f3bc5288921 (patch)
treef910cec6f19161653da180aab41c87a29d208b1d
parentb8a4d41327dedcba96c09c0b9414f83182a7120d (diff)
downloadbcm5719-llvm-8de312d2a991c3f360576b426e0f1f3bc5288921.tar.gz
bcm5719-llvm-8de312d2a991c3f360576b426e0f1f3bc5288921.zip
Add new getModRefInfo API to determine whether an Instruction and a call modify the same memory
llvm-svn: 234814
-rw-r--r--llvm/include/llvm/Analysis/AliasAnalysis.h4
-rw-r--r--llvm/lib/Analysis/AliasAnalysis.cpp17
2 files changed, 21 insertions, 0 deletions
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index d6ea91e2f13..6999bd1a029 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -503,6 +503,10 @@ public:
ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){
return getModRefInfo(I, Location(P, Size));
}
+ /// getModRefInfo - Return information about whether a call and an instruction
+ /// may refer to the same memory locations.
+ ModRefResult getModRefInfo(Instruction *I,
+ ImmutableCallSite Call);
/// getModRefInfo - Return information about whether two call sites may refer
/// to the same set of memory locations. See
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index c8323620558..43db1763bbb 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -82,6 +82,23 @@ void AliasAnalysis::addEscapingUse(Use &U) {
AA->addEscapingUse(U);
}
+AliasAnalysis::ModRefResult
+AliasAnalysis::getModRefInfo(Instruction *I, ImmutableCallSite Call) {
+ // We may have two calls
+ if (auto CS = ImmutableCallSite(I)) {
+ // Check if the two calls modify the same memory
+ return getModRefInfo(Call, CS);
+ } else {
+ // Otherwise, check if the call modifies or references the
+ // location this memory access defines. The best we can say
+ // is that if the call references what this instruction
+ // defines, it must be clobbered by this location.
+ const AliasAnalysis::Location DefLoc = AA->getLocation(I);
+ if (getModRefInfo(Call, DefLoc) != AliasAnalysis::NoModRef)
+ return AliasAnalysis::ModRef;
+ }
+ return AliasAnalysis::NoModRef;
+}
AliasAnalysis::ModRefResult
AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
OpenPOWER on IntegriCloud