summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-31 22:41:15 +0000
committerChris Lattner <sabre@nondot.org>2002-10-31 22:41:15 +0000
commitc1d88207117db0ffb4c58d1dd85ca0e1fb2022bd (patch)
tree36455b892f8fa9adbe086c68cbd89df1f2749fae /llvm/lib
parent5ef09c401b4f284b96fa159c95d1de42e8ce12e6 (diff)
downloadbcm5719-llvm-c1d88207117db0ffb4c58d1dd85ca0e1fb2022bd.tar.gz
bcm5719-llvm-c1d88207117db0ffb4c58d1dd85ca0e1fb2022bd.zip
* Minor optimization: when merging nodes, merge the smaller one into the
larger one. * Handle the case where we are merging two nodes of different size better. llvm-svn: 4476
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/DataStructure/DataStructure.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/DataStructure/DataStructure.cpp b/llvm/lib/Analysis/DataStructure/DataStructure.cpp
index cd2c8983194..44ecd01ab7e 100644
--- a/llvm/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/llvm/lib/Analysis/DataStructure/DataStructure.cpp
@@ -355,7 +355,7 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) {
// now completely folded.
//
if (isNodeCompletelyFolded()) {
- NH.getNode()->foldNodeCompletely();
+ N->foldNodeCompletely();
} else if (NH.getNode()->isNodeCompletelyFolded()) {
foldNodeCompletely();
Offset = 0;
@@ -367,6 +367,10 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) {
if (Offset > NH.getOffset()) {
N->mergeWith(DSNodeHandle(this, Offset), NH.getOffset());
return;
+ } else if (Offset == NH.getOffset() && getSize() < N->getSize()) {
+ // If the offsets are the same, merge the smaller node into the bigger node
+ N->mergeWith(DSNodeHandle(this, Offset), NH.getOffset());
+ return;
}
#if 0
@@ -381,9 +385,15 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) {
//
unsigned NOffset = NH.getOffset()-Offset;
+ // If our destination node is too small... try to grow it.
+ if (N->getSize()+NOffset > getSize() &&
+ growNode(N->getSize()+NOffset)) {
+ // Catastrophic failure occured and we had to collapse the node. In this
+ // case, collapse the other node as well.
+ N->foldNodeCompletely();
+ NOffset = 0;
+ }
unsigned NSize = N->getSize();
- assert(NSize+NOffset <= getSize() &&
- "Don't know how to merge extend a merged nodes size yet!");
// Remove all edges pointing at N, causing them to point to 'this' instead.
// Make sure to adjust their offset, not just the node pointer.
OpenPOWER on IntegriCloud