From b30f2f51410449a6d476fed5c486a4ef8fd5f912 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Sat, 30 Jan 2016 01:24:31 +0000 Subject: [PATCH] Avoid overly large SmallPtrSet/SmallSet These sets perform linear searching in small mode so it is never a good idea to use SmallSize/N bigger than 32. llvm-svn: 259283 --- llvm/include/llvm/Analysis/DemandedBits.h | 2 +- llvm/include/llvm/IR/DebugInfo.h | 2 +- llvm/include/llvm/MC/MCAssembler.h | 2 +- llvm/lib/Analysis/CFG.cpp | 2 +- llvm/lib/Analysis/GlobalsModRef.cpp | 4 ++-- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 2 +- llvm/lib/CodeGen/SjLjEHPrepare.cpp | 2 +- llvm/lib/Support/CommandLine.cpp | 2 +- llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 +- llvm/lib/Transforms/IPO/MergeFunctions.cpp | 2 +- llvm/lib/Transforms/IPO/SampleProfile.cpp | 4 ++-- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 2 +- llvm/lib/Transforms/Scalar/ADCE.cpp | 2 +- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 2 +- llvm/lib/Transforms/Utils/Local.cpp | 2 +- llvm/lib/Transforms/Utils/SplitModule.cpp | 2 +- llvm/tools/bugpoint/CrashDebugger.cpp | 4 ++-- 22 files changed, 25 insertions(+), 25 deletions(-) diff --git a/llvm/include/llvm/Analysis/DemandedBits.h b/llvm/include/llvm/Analysis/DemandedBits.h index 42932bf..ef31d81 100644 --- a/llvm/include/llvm/Analysis/DemandedBits.h +++ b/llvm/include/llvm/Analysis/DemandedBits.h @@ -63,7 +63,7 @@ private: bool Analyzed; // The set of visited instructions (non-integer-typed only). - SmallPtrSet Visited; + SmallPtrSet Visited; DenseMap AliveBits; }; diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h index 4caceac..1f1a699 100644 --- a/llvm/include/llvm/IR/DebugInfo.h +++ b/llvm/include/llvm/IR/DebugInfo.h @@ -136,7 +136,7 @@ private: SmallVector GVs; SmallVector TYs; SmallVector Scopes; - SmallPtrSet NodesSeen; + SmallPtrSet NodesSeen; DITypeIdentifierMap TypeIdentifierMap; /// \brief Specify if TypeIdentifierMap is initialized. diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h index c0bd128..ff069a8 100644 --- a/llvm/include/llvm/MC/MCAssembler.h +++ b/llvm/include/llvm/MC/MCAssembler.h @@ -123,7 +123,7 @@ private: // here. Maybe when the relocation stuff moves to target specific, // this can go with it? The streamer would need some target specific // refactoring too. - mutable SmallPtrSet ThumbFuncs; + mutable SmallPtrSet ThumbFuncs; /// \brief The bundle alignment size currently set in the assembler. /// diff --git a/llvm/lib/Analysis/CFG.cpp b/llvm/lib/Analysis/CFG.cpp index 0dfd57d..a319be8 100644 --- a/llvm/lib/Analysis/CFG.cpp +++ b/llvm/lib/Analysis/CFG.cpp @@ -138,7 +138,7 @@ bool llvm::isPotentiallyReachableFromMany( // Limit the number of blocks we visit. The goal is to avoid run-away compile // times on large CFGs without hampering sensible code. Arbitrarily chosen. unsigned Limit = 32; - SmallSet Visited; + SmallPtrSet Visited; do { BasicBlock *BB = Worklist.pop_back_val(); if (!Visited.insert(BB).second) diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp index db3d5f7..8338dcc 100644 --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -269,7 +269,7 @@ GlobalsAAResult::getFunctionInfo(const Function *F) { /// (really, their address passed to something nontrivial), record this fact, /// and record the functions that they are used directly in. void GlobalsAAResult::AnalyzeGlobals(Module &M) { - SmallPtrSet TrackedFunctions; + SmallPtrSet TrackedFunctions; for (Function &F : M) if (F.hasLocalLinkage()) if (!AnalyzeUsesOfPointer(&F)) { @@ -281,7 +281,7 @@ void GlobalsAAResult::AnalyzeGlobals(Module &M) { ++NumNonAddrTakenFunctions; } - SmallPtrSet Readers, Writers; + SmallPtrSet Readers, Writers; for (GlobalVariable &GV : M.globals()) if (GV.hasLocalLinkage()) { if (!AnalyzeUsesOfPointer(&GV, &Readers, diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 6918360..9492801 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -854,7 +854,7 @@ MemoryDependenceAnalysis::getNonLocalCallDependency(CallSite QueryCS) { // isReadonlyCall - If this is a read-only call, we can be more aggressive. bool isReadonlyCall = AA->onlyReadsMemory(QueryCS); - SmallPtrSet Visited; + SmallPtrSet Visited; unsigned NumSortedEntries = Cache.size(); DEBUG(AssertSorted(Cache)); diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index fea77d0..6323a4b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -112,7 +112,7 @@ namespace { /// /// This is used to allow us to reliably add any operands of a DAG node /// which have not yet been combined to the worklist. - SmallPtrSet CombinedNodes; + SmallPtrSet CombinedNodes; // AA - Used for DAG load/store alias analysis. AliasAnalysis &AA; diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp index 2a6c853..c71163c6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -321,7 +321,7 @@ void ScheduleDAGSDNodes::BuildSchedUnits() { // Add all nodes in depth first order. SmallVector Worklist; - SmallPtrSet Visited; + SmallPtrSet Visited; Worklist.push_back(DAG->getRoot().getNode()); Visited.insert(DAG->getRoot().getNode()); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index 6555ccc..69612ed 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -630,7 +630,7 @@ static bool printOperand(raw_ostream &OS, const SelectionDAG *G, } } -typedef SmallPtrSet VisitedSDNodeSet; +typedef SmallPtrSet VisitedSDNodeSet; static void DumpNodesr(raw_ostream &OS, const SDNode *N, unsigned indent, const SelectionDAG *G, VisitedSDNodeSet &once) { if (!once.insert(N).second) // If we've been here before, return now. diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 8239720..952018e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -669,7 +669,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock::const_iterator Begin, } void SelectionDAGISel::ComputeLiveOutVRegInfo() { - SmallPtrSet VisitedNodes; + SmallPtrSet VisitedNodes; SmallVector Worklist; Worklist.push_back(CurDAG->getRoot().getNode()); diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 02545a7..edd0ca4 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -258,7 +258,7 @@ static void removeDuplicatesGCPtrs(SmallVectorImpl &Bases, SelectionDAGBuilder &Builder) { // This is horribly inefficient, but I don't care right now - SmallSet Seen; + SmallSet Seen; SmallVector NewBases, NewPtrs, NewRelocs; for (size_t i = 0; i < Ptrs.size(); i++) { diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp index e1f242a..14436618 100644 --- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp +++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp @@ -303,7 +303,7 @@ void SjLjEHPrepare::lowerAcrossUnwindEdges(Function &F, } // Find all of the blocks that this value is live in. - SmallPtrSet LiveBBs; + SmallPtrSet LiveBBs; LiveBBs.insert(Inst->getParent()); while (!Users.empty()) { Instruction *U = Users.back(); diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index fdcdb03..c1615a0 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1449,7 +1449,7 @@ static int OptNameCompare(const std::pair *LHS, static void sortOpts(StringMap