[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 23 19:05:06 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

DataStructureAA.cpp updated: 1.30 -> 1.31
---
Log message:

teach ds-aa about mod/ref for external function calls.


---
Diffs of the changes:  (+25 -1)

 DataStructureAA.cpp |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletion(-)


Index: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.30 llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.31
--- llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.30	Tue Mar 22 19:47:19 2005
+++ llvm/lib/Analysis/DataStructure/DataStructureAA.cpp	Wed Mar 23 21:04:50 2005
@@ -178,9 +178,33 @@
   AliasAnalysis::ModRefResult Result =AliasAnalysis::getModRefInfo(CS, P, Size);
   Function *F = CS.getCalledFunction();
 
-  if (!F || F->isExternal() || Result == NoModRef)
+  if (!F || Result == NoModRef)
     return Result;
 
+  if (F->isExternal()) {
+    // If we are calling an external function, and if this global doesn't escape
+    // the portion of the program we have analyzed, we can draw conclusions
+    // based on whether the global escapes the program.
+    Function *Caller = CS.getInstruction()->getParent()->getParent();
+    DSGraph *G = &TD->getDSGraph(*Caller);
+    DSScalarMap::iterator NI = G->getScalarMap().find(P);
+    if (NI == G->getScalarMap().end()) {
+      // If it wasn't in the local function graph, check the global graph.  This
+      // can occur for globals who are locally reference but hoisted out to the
+      // globals graph despite that.
+      G = G->getGlobalsGraph();
+      NI = G->getScalarMap().find(P);
+      if (NI == G->getScalarMap().end())
+        return Result;
+    }
+
+    // If we found a node and it's complete, it cannot be passed out to the
+    // called function.
+    if (NI->second.getNode()->isComplete())
+      return NoModRef;
+    return Result;
+  }
+
   // Get the graphs for the callee and caller.  Note that we want the BU graph
   // for the callee because we don't want all caller's effects incorporated!
   const Function *Caller = CS.getInstruction()->getParent()->getParent();






More information about the llvm-commits mailing list