simplify this function a bit, allow DS-AA to build on/improve the mod/ref
authorChris Lattner <sabre@nondot.org>
Thu, 17 Mar 2005 20:16:58 +0000 (20:16 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Mar 2005 20:16:58 +0000 (20:16 +0000)
results returned by AA, not just use one or the other.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20662 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/DataStructureAA.cpp

index 74fdb1f590f5987b96919167cc3eac9d03dcc8b1..2d62162d1d9e73e304a0fe91e577c86f07a17282 100644 (file)
@@ -173,9 +173,11 @@ AliasAnalysis::AliasResult DSAA::alias(const Value *V1, unsigned V1Size,
 ///
 AliasAnalysis::ModRefResult
 DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
+  AliasAnalysis::ModRefResult Result =AliasAnalysis::getModRefInfo(CS, P, Size);
   Function *F = CS.getCalledFunction();
-  if (!F || F->isExternal())
-    return AliasAnalysis::getModRefInfo(CS, P, Size);
+
+  if (!F || F->isExternal() || Result == NoModRef)
+    return Result;
 
   // Clone the function TD graph, clearing off Mod/Ref flags
   const Function *csParent = CS.getInstruction()->getParent()->getParent();
@@ -189,12 +191,13 @@ DSAA::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
 
   // Report the flags that have been added
   const DSNodeHandle &DSH = TDGraph.getNodeForValue(P);
-  if (const DSNode *N = DSH.getNode())
-    if (N->isModified())
-      return N->isRead() ? ModRef : Mod;
-    else
-      return N->isRead() ? Ref : NoModRef;
-  return NoModRef;
+  if (const DSNode *N = DSH.getNode()) {
+    if (!N->isModified())   // We proved it was not modified.
+      Result = ModRefResult(Result & ~Mod);
+    if (!N->isRead())       // We proved it was not read.
+      Result = ModRefResult(Result & ~Ref);
+  }
+  return Result;
 }