summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/SmallPtrSet.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-07-09 18:51:15 +0000
committerOwen Anderson <resistor@mac.com>2007-07-09 18:51:15 +0000
commitaee901745de3effeb000f66714bad39abbebfcca (patch)
tree9bad8ffe2ec8b60ec823b92037f8ba1c3c023ec1 /llvm/lib/Support/SmallPtrSet.cpp
parent318ff8dd942b20d29feb719137d25e34ce58fde9 (diff)
downloadbcm5719-llvm-aee901745de3effeb000f66714bad39abbebfcca.tar.gz
bcm5719-llvm-aee901745de3effeb000f66714bad39abbebfcca.zip
Fix an error in the assignment operator that was causing an infinite loop in GVNPRE.cpp.
Patch by Chis Lattner. llvm-svn: 38467
Diffstat (limited to 'llvm/lib/Support/SmallPtrSet.cpp')
-rw-r--r--llvm/lib/Support/SmallPtrSet.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp
index 81c4bc752fb..5ad243033fc 100644
--- a/llvm/lib/Support/SmallPtrSet.cpp
+++ b/llvm/lib/Support/SmallPtrSet.cpp
@@ -182,6 +182,8 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
if (!isSmall())
delete [] CurArray;
+ NumElements = NumTombstones = 0;
+
// Get a power of two larger than twice the RHS size.
CurArraySize = 1 << Log2_32(RHS.size()*4);
@@ -199,12 +201,18 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
// Now that we know we have enough space, and that the current array is empty,
// copy over all the elements from the RHS.
-
for (void **BucketPtr = RHS.CurArray, **E = RHS.CurArray+RHS.CurArraySize;
BucketPtr != E; ++BucketPtr) {
// Copy over the element if it is valid.
void *Elt = *BucketPtr;
- if (Elt != getTombstoneMarker() && Elt != getEmptyMarker())
- *const_cast<void**>(FindBucketFor(Elt)) = Elt;
+ if (Elt != getTombstoneMarker() && Elt != getEmptyMarker()) {
+ if (isSmall())
+ SmallArray[NumElements++] = Elt;
+ else
+ *const_cast<void**>(FindBucketFor(Elt)) = Elt;
+ }
}
+
+ if (!isSmall())
+ NumElements = RHS.NumElements;
}
OpenPOWER on IntegriCloud