Index: include/llvm/ADT/SmallPtrSet.h =================================================================== --- include/llvm/ADT/SmallPtrSet.h +++ include/llvm/ADT/SmallPtrSet.h @@ -351,6 +351,11 @@ /// SmallPtrSetImplBase for details of the algorithm. template class SmallPtrSet : public SmallPtrSetImpl { + // In small mode SmallPtrSet uses linear search for the elements, so it is + // not a good idea to choose this value too high. You may consider using a + // DenseSet<> instead if you expect many elements in the set. + static_assert(SmallSize <= 32, "SmallSize should be small"); + typedef SmallPtrSetImpl BaseT; // Make sure that SmallSize is a power of two, round up if not. Index: include/llvm/ADT/SmallSet.h =================================================================== --- include/llvm/ADT/SmallSet.h +++ include/llvm/ADT/SmallSet.h @@ -38,6 +38,11 @@ typedef typename SmallVector::const_iterator VIterator; typedef typename SmallVector::iterator mutable_iterator; + // In small mode SmallPtrSet uses linear search for the elements, so it is + // not a good idea to choose this value too high. You may consider using a + // DenseSet<> instead if you expect many elements in the set. + static_assert(N <= 32, "N should be small"); + public: typedef size_t size_type; SmallSet() {}