diff options
author | Chris Lattner <sabre@nondot.org> | 2002-11-12 07:20:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-11-12 07:20:45 +0000 |
commit | 5190ce83744ceadeb0167330bbf83ff99de066ee (patch) | |
tree | 63080cd514b62e4181055b50b616a77bc0ba3599 /lib/Analysis/DataStructure/DataStructure.cpp | |
parent | 32f8e7d4e806ac29f01262afe1c270d129cf1ac5 (diff) |
Fix two bugs:
* The globals vector was getting broken and unsorted, this caused vortex
to get badly pessimized
* Node offset handling was being handled really poorly, and in particular
we were not merging types with offsets right. This causes several graphs
to be non-merged.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/DataStructure.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index f88b9997dd..432dbb0d5c 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -341,9 +341,9 @@ void MergeSortedVectors(vector<T> &Dest, const vector<T> &Src) { T Tmp = Dest[0]; // Save value in temporary... Dest = Src; // Copy over list... typename vector<T>::iterator I = - std::lower_bound(Dest.begin(), Dest.end(),Tmp); - if (I == Dest.end() || *I != Src[0]) // If not already contained... - Dest.insert(I, Src[0]); + std::lower_bound(Dest.begin(), Dest.end(), Tmp); + if (I == Dest.end() || *I != Tmp) // If not already contained... + Dest.insert(I, Tmp); } else { // Make a copy to the side of Dest... @@ -387,9 +387,28 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) { return; } + // If both nodes are not at offset 0, make sure that we are merging the node + // at an later offset into the node with the zero 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; + } + + // Now we know that Offset >= NH.Offset, so convert it so our "Offset" (with + // respect to NH.Offset) is now zero. NOffset is the distance from the base + // of our object that N starts from. + // + unsigned NOffset = Offset-NH.getOffset(); + unsigned NSize = N->getSize(); + // Merge the type entries of the two nodes together... if (N->Ty.Ty != Type::VoidTy) { - mergeTypeInfo(N->Ty.Ty, Offset); + mergeTypeInfo(N->Ty.Ty, NOffset); // mergeTypeInfo can cause collapsing, which can cause this node to become // dead. @@ -404,30 +423,19 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) { if (!N->isNodeCompletelyFolded()) { N->foldNodeCompletely(); if (hasNoReferrers()) return; + NSize = N->getSize(); } } else if (N->isNodeCompletelyFolded()) { foldNodeCompletely(); - Offset = 0; if (hasNoReferrers()) return; + Offset = 0; + NOffset = NH.getOffset(); + NSize = N->getSize(); } N = NH.getNode(); - assert((NodeType & DSNode::DEAD) == 0); - if (this == N || N == 0) return; assert((NodeType & DSNode::DEAD) == 0); - // If both nodes are not at offset 0, make sure that we are merging the node - // at an later offset into the node with the zero 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 std::cerr << "\n\nMerging:\n"; N->print(std::cerr, 0); @@ -435,14 +443,6 @@ void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) { print(std::cerr, 0); #endif - // Now we know that Offset <= NH.Offset, so convert it so our "Offset" (with - // respect to NH.Offset) is now zero. - // - unsigned NOffset = NH.getOffset()-Offset; - unsigned NSize = N->getSize(); - - assert((NodeType & DSNode::DEAD) == 0); - // Remove all edges pointing at N, causing them to point to 'this' instead. // Make sure to adjust their offset, not just the node pointer. // |