From d33bb62823b37dab31f996cfbe7a5b8563d85e9b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 18 Nov 2015 06:52:18 +0000 Subject: [PATCH] Default SetVector to use a DenseSet. We use to have an odd difference among MapVector and SetVector. The map used a DenseMop, but the set used a SmallSet, which in turn uses a std::set. I have changed SetVector to use a DenseSet. If you were depending on the old behaviour you can pass an explicit set type or use SmallSetVector. The common cases for needing to do it are: * Optimizing for small sets. * Sets for types not supported by DenseSet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253439 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/SetVector.h | 3 ++- lib/Analysis/AliasAnalysisEvaluator.cpp | 10 ++++------ utils/TableGen/AsmMatcherEmitter.cpp | 6 +++--- utils/TableGen/FixedLenDecoderEmitter.cpp | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/llvm/ADT/SetVector.h b/include/llvm/ADT/SetVector.h index ad0a0dfac63..3ab202d8d71 100644 --- a/include/llvm/ADT/SetVector.h +++ b/include/llvm/ADT/SetVector.h @@ -20,6 +20,7 @@ #ifndef LLVM_ADT_SETVECTOR_H #define LLVM_ADT_SETVECTOR_H +#include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallSet.h" #include #include @@ -33,7 +34,7 @@ namespace llvm { /// property of a deterministic iteration order. The order of iteration is the /// order of insertion. template , - typename Set = SmallSet > + typename Set = DenseSet> class SetVector { public: typedef T value_type; diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index b1dca1d9375..c2a95cc31ea 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -145,7 +145,7 @@ bool AAEval::runOnFunction(Function &F) { AliasAnalysis &AA = getAnalysis().getAAResults(); SetVector Pointers; - SetVector CallSites; + SmallSetVector CallSites; SetVector Loads; SetVector Stores; @@ -284,8 +284,7 @@ bool AAEval::runOnFunction(Function &F) { } // Mod/ref alias analysis: compare all pairs of calls and values - for (SetVector::iterator C = CallSites.begin(), - Ce = CallSites.end(); C != Ce; ++C) { + for (auto C = CallSites.begin(), Ce = CallSites.end(); C != Ce; ++C) { Instruction *I = C->getInstruction(); for (SetVector::iterator V = Pointers.begin(), Ve = Pointers.end(); @@ -316,9 +315,8 @@ bool AAEval::runOnFunction(Function &F) { } // Mod/ref alias analysis: compare all pairs of calls - for (SetVector::iterator C = CallSites.begin(), - Ce = CallSites.end(); C != Ce; ++C) { - for (SetVector::iterator D = CallSites.begin(); D != Ce; ++D) { + for (auto C = CallSites.begin(), Ce = CallSites.end(); C != Ce; ++C) { + for (auto D = CallSites.begin(); D != Ce; ++D) { if (D == C) continue; switch (AA.getModRefInfo(*C, *D)) { diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index f1b9ab39387..e55bbd37610 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -1722,7 +1722,7 @@ void MatchableInfo::buildAliasResultOperands() { } static unsigned getConverterOperandID(const std::string &Name, - SetVector &Table, + SmallSetVector &Table, bool &IsNew) { IsNew = Table.insert(Name); @@ -1738,8 +1738,8 @@ static unsigned getConverterOperandID(const std::string &Name, static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, std::vector> &Infos, raw_ostream &OS) { - SetVector OperandConversionKinds; - SetVector InstructionConversionKinds; + SmallSetVector OperandConversionKinds; + SmallSetVector InstructionConversionKinds; std::vector > ConversionTable; size_t MaxRowLength = 2; // minimum is custom converter plus terminator. diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index df61511c8dd..8ca4a1bf540 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -65,8 +65,8 @@ typedef std::vector DecoderTable; typedef uint32_t DecoderFixup; typedef std::vector FixupList; typedef std::vector FixupScopeList; -typedef SetVector PredicateSet; -typedef SetVector DecoderSet; +typedef SmallSetVector PredicateSet; +typedef SmallSetVector DecoderSet; struct DecoderTableInfo { DecoderTable Table; FixupScopeList FixupStack; -- 2.34.1