Add new getModRefInfo API to determine whether an Instruction and a call modify the...
authorDaniel Berlin <dberlin@dberlin.org>
Mon, 13 Apr 2015 23:25:41 +0000 (23:25 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Mon, 13 Apr 2015 23:25:41 +0000 (23:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234814 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/AliasAnalysis.h
lib/Analysis/AliasAnalysis.cpp

index d6ea91e2f134a2047064730fa44950a0ed4a67b4..6999bd1a0294c250f9e2f4ff3d53c77de3a927bc 100644 (file)
@@ -503,6 +503,10 @@ public:
   ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){
     return getModRefInfo(I, Location(P, Size));
   }
   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 
 
   /// getModRefInfo - Return information about whether two call sites may refer
   /// to the same set of memory locations.  See 
index c83236205587d8ac24a72977b0f9886601c20f98..43db1763bbbce87a5e7dbd79f8d77626e7ba6ea1 100644 (file)
@@ -82,6 +82,23 @@ void AliasAnalysis::addEscapingUse(Use &U) {
   AA->addEscapingUse(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,
 
 AliasAnalysis::ModRefResult
 AliasAnalysis::getModRefInfo(ImmutableCallSite CS,