Index: llvm/trunk/tools/llvm-exegesis/lib/Clustering.h =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Clustering.h +++ llvm/trunk/tools/llvm-exegesis/lib/Clustering.h @@ -104,7 +104,7 @@ const std::vector &Points, double EpsilonSquared); llvm::Error validateAndSetup(); void dbScan(size_t MinPts); - void rangeQuery(size_t Q, llvm::SmallVectorImpl &Scratchpad) const; + void rangeQuery(size_t Q, std::vector &Scratchpad) const; const std::vector &Points_; const double EpsilonSquared_; Index: llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp =================================================================== --- llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp +++ llvm/trunk/tools/llvm-exegesis/lib/Clustering.cpp @@ -34,8 +34,9 @@ // Finds the points at distance less than sqrt(EpsilonSquared) of Q (not // including Q). void InstructionBenchmarkClustering::rangeQuery( - const size_t Q, llvm::SmallVectorImpl &Neighbors) const { + const size_t Q, std::vector &Neighbors) const { Neighbors.clear(); + Neighbors.reserve(Points_.size() - 1); // The Q itself isn't a neighbor. const auto &QMeasurements = Points_[Q].Measurements; for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) { if (P == Q) @@ -91,7 +92,7 @@ } void InstructionBenchmarkClustering::dbScan(const size_t MinPts) { - llvm::SmallVector Neighbors; // Persistent buffer to avoid allocs. + std::vector Neighbors; // Persistent buffer to avoid allocs. for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) { if (!ClusterIdForPoint_[P].isUndef()) continue; // Previously processed in inner loop. @@ -136,6 +137,8 @@ } } } + // assert(Neighbors.capacity() == (Points_.size() - 1)); + // ^ True, but it is not quaranteed to be true in all the cases. // Add noisy points to noise cluster. for (size_t P = 0, NumPoints = Points_.size(); P < NumPoints; ++P) {