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

Chris Lattner lattner at cs.uiuc.edu
Thu Mar 4 13:48:01 PST 2004


Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.168 -> 1.169

---
Log message:

Implement a FIXME, improving the efficiency of DSA on povray.
This reduces CBU time from 145s -> 122s (debug build), reduces # allocated nodes
from 129420 to 116477.


---
Diffs of the changes:  (+16 -2)

Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.168 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.169
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.168	Thu Mar  4 11:06:53 2004
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Thu Mar  4 13:47:04 2004
@@ -785,8 +785,22 @@
   if (!NH.isNull())    // Node already mapped?
     return DSNodeHandle(NH.getNode(), NH.getOffset()+SrcNH.getOffset());
 
-  // FIXME if SrcNH has globals and the dest graph contains the same globals, we
-  // could use 'merge' to do this work more efficiently!
+  // If SrcNH has globals and the destination graph has one of the same globals,
+  // merge this node with the destination node, which is much more efficient.
+  if (SN->global_begin() != SN->global_end()) {
+    DSScalarMap &DestSM = Dest.getScalarMap();
+    for (DSNode::global_iterator I = SN->global_begin(), E = SN->global_end();
+         I != E; ++I) {
+      GlobalValue *GV = *I;
+      DSScalarMap::iterator GI = DestSM.find(GV);
+      if (GI != DestSM.end() && !GI->second.isNull()) {
+        // We found one, use merge instead!
+        merge(GI->second, Src.getNodeForValue(GV));
+        assert(!NH.isNull() && "Didn't merge node!");
+        return DSNodeHandle(NH.getNode(), NH.getOffset()+SrcNH.getOffset());
+      }
+    }
+  }
 
   DSNode *DN = new DSNode(*SN, &Dest, true /* Null out all links */);
   DN->maskNodeTypes(BitsToKeep);





More information about the llvm-commits mailing list