[llvm-commits] [llvm] r38467 - /llvm/trunk/lib/Support/SmallPtrSet.cpp
Owen Anderson
resistor at mac.com
Mon Jul 9 11:51:16 PDT 2007
Author: resistor
Date: Mon Jul 9 13:51:15 2007
New Revision: 38467
URL: http://llvm.org/viewvc/llvm-project?rev=38467&view=rev
Log:
Fix an error in the assignment operator that was causing an infinite loop in GVNPRE.cpp.
Patch by Chis Lattner.
Modified:
llvm/trunk/lib/Support/SmallPtrSet.cpp
Modified: llvm/trunk/lib/Support/SmallPtrSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SmallPtrSet.cpp?rev=38467&r1=38466&r2=38467&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SmallPtrSet.cpp (original)
+++ llvm/trunk/lib/Support/SmallPtrSet.cpp Mon Jul 9 13:51:15 2007
@@ -182,6 +182,8 @@
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 @@
// 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;
}
More information about the llvm-commits
mailing list