mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-22 10:33:23 +00:00
* 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4476 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e3aa8aa08f
commit
9b87c5c53c
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user