simplify this function a bit, allow DS-AA to build on/improve the mod/ref
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
diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp
index 74fdb1f..2d62162 100644
--- a/lib/Analysis/DataStructure/DataStructureAA.cpp
+++ b/lib/Analysis/DataStructure/DataStructureAA.cpp
@@ -173,9 +173,11 @@
 ///
 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 @@
 
   // 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;
 }