Fix a self-memcpy which only breaks under Valgrind's memcpy
authorChandler Carruth <chandlerc@gmail.com>
Tue, 26 Nov 2013 00:44:36 +0000 (00:44 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 26 Nov 2013 00:44:36 +0000 (00:44 +0000)
implementation. Silliness, but it'll be a trivial performance
optimization. This should clear up a failure on the vg_leak bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195704 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/SmallPtrSet.cpp

index e37e23b7bb1760a420aefb089b7a7f2ff84c655a..fa8d91545e71064bde1cf0b7b7d22f27182d2b39 100644 (file)
@@ -218,6 +218,9 @@ SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize,
 /// CopyFrom - implement operator= from a smallptrset that has the same pointer
 /// type, but may have a different small size.
 void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) {
+  if (&RHS == this)
+    return;
+
   if (isSmall() && RHS.isSmall())
     assert(CurArraySize == RHS.CurArraySize &&
            "Cannot assign sets with different small sizes");