aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/DataStructure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-04 19:47:04 +0000
committerChris Lattner <sabre@nondot.org>2004-03-04 19:47:04 +0000
commite6e93ccd0c8d336dc3fa195373ed2951738adba8 (patch)
tree9932c00319d0a12e0418e50a3cc25ef6f854c5e0 /lib/Analysis/DataStructure/DataStructure.cpp
parent7a3ae1fbada713dc6b079debf2a5ad5ba32157f7 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12125 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/DataStructure.cpp')
-rw-r--r--lib/Analysis/DataStructure/DataStructure.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp
index 7eb6a65e29..e3430e7a5d 100644
--- a/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/lib/Analysis/DataStructure/DataStructure.cpp
@@ -785,8 +785,22 @@ DSNodeHandle ReachabilityCloner::getClonedNH(const DSNodeHandle &SrcNH) {
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);