[llvm] r259283 - Avoid overly large SmallPtrSet/SmallSet
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 17:24:32 PST 2016
Author: matze
Date: Fri Jan 29 19:24:31 2016
New Revision: 259283
URL: http://llvm.org/viewvc/llvm-project?rev=259283&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/Analysis/DemandedBits.h
llvm/trunk/include/llvm/IR/DebugInfo.h
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/Analysis/CFG.cpp
llvm/trunk/lib/Analysis/GlobalsModRef.cpp
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp
llvm/trunk/lib/Support/CommandLine.cpp
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/lib/Transforms/Utils/SplitModule.cpp
llvm/trunk/tools/bugpoint/CrashDebugger.cpp
Modified: llvm/trunk/include/llvm/Analysis/DemandedBits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DemandedBits.h?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DemandedBits.h (original)
+++ llvm/trunk/include/llvm/Analysis/DemandedBits.h Fri Jan 29 19:24:31 2016
@@ -63,7 +63,7 @@ private:
bool Analyzed;
// The set of visited instructions (non-integer-typed only).
- SmallPtrSet<Instruction*, 128> Visited;
+ SmallPtrSet<Instruction*, 32> Visited;
DenseMap<Instruction *, APInt> AliveBits;
};
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Fri Jan 29 19:24:31 2016
@@ -136,7 +136,7 @@ private:
SmallVector<DIGlobalVariable *, 8> GVs;
SmallVector<DIType *, 8> TYs;
SmallVector<DIScope *, 8> Scopes;
- SmallPtrSet<const MDNode *, 64> NodesSeen;
+ SmallPtrSet<const MDNode *, 32> NodesSeen;
DITypeIdentifierMap TypeIdentifierMap;
/// \brief Specify if TypeIdentifierMap is initialized.
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Fri Jan 29 19:24:31 2016
@@ -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<const MCSymbol *, 64> ThumbFuncs;
+ mutable SmallPtrSet<const MCSymbol *, 32> ThumbFuncs;
/// \brief The bundle alignment size currently set in the assembler.
///
Modified: llvm/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CFG.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CFG.cpp (original)
+++ llvm/trunk/lib/Analysis/CFG.cpp Fri Jan 29 19:24:31 2016
@@ -138,7 +138,7 @@ bool llvm::isPotentiallyReachableFromMan
// 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<const BasicBlock*, 64> Visited;
+ SmallPtrSet<const BasicBlock*, 32> Visited;
do {
BasicBlock *BB = Worklist.pop_back_val();
if (!Visited.insert(BB).second)
Modified: llvm/trunk/lib/Analysis/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/GlobalsModRef.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/GlobalsModRef.cpp Fri Jan 29 19:24:31 2016
@@ -269,7 +269,7 @@ GlobalsAAResult::getFunctionInfo(const 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<Function *, 64> TrackedFunctions;
+ SmallPtrSet<Function *, 32> TrackedFunctions;
for (Function &F : M)
if (F.hasLocalLinkage())
if (!AnalyzeUsesOfPointer(&F)) {
@@ -281,7 +281,7 @@ void GlobalsAAResult::AnalyzeGlobals(Mod
++NumNonAddrTakenFunctions;
}
- SmallPtrSet<Function *, 64> Readers, Writers;
+ SmallPtrSet<Function *, 16> Readers, Writers;
for (GlobalVariable &GV : M.globals())
if (GV.hasLocalLinkage()) {
if (!AnalyzeUsesOfPointer(&GV, &Readers,
Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Fri Jan 29 19:24:31 2016
@@ -854,7 +854,7 @@ MemoryDependenceAnalysis::getNonLocalCal
// isReadonlyCall - If this is a read-only call, we can be more aggressive.
bool isReadonlyCall = AA->onlyReadsMemory(QueryCS);
- SmallPtrSet<BasicBlock*, 64> Visited;
+ SmallPtrSet<BasicBlock*, 32> Visited;
unsigned NumSortedEntries = Cache.size();
DEBUG(AssertSorted(Cache));
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Jan 29 19:24:31 2016
@@ -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<SDNode *, 64> CombinedNodes;
+ SmallPtrSet<SDNode *, 32> CombinedNodes;
// AA - Used for DAG load/store alias analysis.
AliasAnalysis &AA;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Fri Jan 29 19:24:31 2016
@@ -321,7 +321,7 @@ void ScheduleDAGSDNodes::BuildSchedUnits
// Add all nodes in depth first order.
SmallVector<SDNode*, 64> Worklist;
- SmallPtrSet<SDNode*, 64> Visited;
+ SmallPtrSet<SDNode*, 32> Visited;
Worklist.push_back(DAG->getRoot().getNode());
Visited.insert(DAG->getRoot().getNode());
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp Fri Jan 29 19:24:31 2016
@@ -630,7 +630,7 @@ static bool printOperand(raw_ostream &OS
}
}
-typedef SmallPtrSet<const SDNode *, 128> VisitedSDNodeSet;
+typedef SmallPtrSet<const SDNode *, 32> 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.
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Jan 29 19:24:31 2016
@@ -669,7 +669,7 @@ void SelectionDAGISel::SelectBasicBlock(
}
void SelectionDAGISel::ComputeLiveOutVRegInfo() {
- SmallPtrSet<SDNode*, 128> VisitedNodes;
+ SmallPtrSet<SDNode*, 16> VisitedNodes;
SmallVector<SDNode*, 128> Worklist;
Worklist.push_back(CurDAG->getRoot().getNode());
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp Fri Jan 29 19:24:31 2016
@@ -258,7 +258,7 @@ static void removeDuplicatesGCPtrs(Small
SelectionDAGBuilder &Builder) {
// This is horribly inefficient, but I don't care right now
- SmallSet<SDValue, 64> Seen;
+ SmallSet<SDValue, 32> Seen;
SmallVector<const Value *, 64> NewBases, NewPtrs, NewRelocs;
for (size_t i = 0; i < Ptrs.size(); i++) {
Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Fri Jan 29 19:24:31 2016
@@ -303,7 +303,7 @@ void SjLjEHPrepare::lowerAcrossUnwindEdg
}
// Find all of the blocks that this value is live in.
- SmallPtrSet<BasicBlock *, 64> LiveBBs;
+ SmallPtrSet<BasicBlock *, 32> LiveBBs;
LiveBBs.insert(Inst->getParent());
while (!Users.empty()) {
Instruction *U = Users.back();
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Fri Jan 29 19:24:31 2016
@@ -1449,7 +1449,7 @@ static int OptNameCompare(const std::pai
static void sortOpts(StringMap<Option *> &OptMap,
SmallVectorImpl<std::pair<const char *, Option *>> &Opts,
bool ShowHidden) {
- SmallPtrSet<Option *, 128> OptionSet; // Duplicate option detection.
+ SmallPtrSet<Option *, 32> OptionSet; // Duplicate option detection.
for (StringMap<Option *>::iterator I = OptMap.begin(), E = OptMap.end();
I != E; ++I) {
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Jan 29 19:24:31 2016
@@ -7184,7 +7184,7 @@ void ARMTargetLowering::EmitSjLjDispatch
// Get an ordered list of the machine basic blocks for the jump table.
std::vector<MachineBasicBlock*> LPadList;
- SmallPtrSet<MachineBasicBlock*, 64> InvokeBBs;
+ SmallPtrSet<MachineBasicBlock*, 32> InvokeBBs;
LPadList.reserve(CallSiteNumToLPad.size());
for (unsigned I = 1; I <= MaxCSNum; ++I) {
SmallVectorImpl<MachineBasicBlock*> &MBBList = CallSiteNumToLPad[I];
Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Fri Jan 29 19:24:31 2016
@@ -1249,7 +1249,7 @@ int FunctionComparator::compare() {
// functions, then takes each block from each terminator in order. As an
// artifact, this also means that unreachable blocks are ignored.
SmallVector<const BasicBlock *, 8> FnLBBs, FnRBBs;
- SmallSet<const BasicBlock *, 128> VisitedBBs; // in terms of F1.
+ SmallPtrSet<const BasicBlock *, 32> VisitedBBs; // in terms of F1.
FnLBBs.push_back(&FnL->getEntryBlock());
FnRBBs.push_back(&FnR->getEntryBlock());
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Fri Jan 29 19:24:31 2016
@@ -163,10 +163,10 @@ protected:
EdgeWeightMap EdgeWeights;
/// \brief Set of visited blocks during propagation.
- SmallPtrSet<const BasicBlock *, 128> VisitedBlocks;
+ SmallPtrSet<const BasicBlock *, 32> VisitedBlocks;
/// \brief Set of visited edges during propagation.
- SmallSet<Edge, 128> VisitedEdges;
+ SmallSet<Edge, 32> VisitedEdges;
/// \brief Equivalence classes for block weights.
///
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Fri Jan 29 19:24:31 2016
@@ -3001,7 +3001,7 @@ static bool prepareICWorklistFromFunctio
// Do a depth-first traversal of the function, populate the worklist with
// the reachable instructions. Ignore blocks that are not reachable. Keep
// track of which blocks we visit.
- SmallPtrSet<BasicBlock *, 64> Visited;
+ SmallPtrSet<BasicBlock *, 32> Visited;
MadeIRChange |=
AddReachableCodeToWorklist(&F.front(), DL, Visited, ICWorklist, TLI);
Modified: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ADCE.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp Fri Jan 29 19:24:31 2016
@@ -34,7 +34,7 @@ using namespace llvm;
STATISTIC(NumRemoved, "Number of instructions removed");
static bool aggressiveDCE(Function& F) {
- SmallPtrSet<Instruction*, 128> Alive;
+ SmallPtrSet<Instruction*, 32> Alive;
SmallVector<Instruction*, 128> Worklist;
// Collect the set of "root" instructions that are known live.
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Fri Jan 29 19:24:31 2016
@@ -2718,7 +2718,7 @@ static void checkBasicSSA(DominatorTree
static void computeLiveInValues(DominatorTree &DT, Function &F,
GCPtrLivenessData &Data) {
- SmallSetVector<BasicBlock *, 200> Worklist;
+ SmallSetVector<BasicBlock *, 32> Worklist;
auto AddPredsToWorklist = [&](BasicBlock *BB) {
// We use a SetVector so that we don't have duplicates in the worklist.
Worklist.insert(pred_begin(BB), pred_end(BB));
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Fri Jan 29 19:24:31 2016
@@ -1465,7 +1465,7 @@ void llvm::removeUnwindEdge(BasicBlock *
/// if they are in a dead cycle. Return true if a change was made, false
/// otherwise.
bool llvm::removeUnreachableBlocks(Function &F, LazyValueInfo *LVI) {
- SmallPtrSet<BasicBlock*, 128> Reachable;
+ SmallPtrSet<BasicBlock*, 16> Reachable;
bool Changed = markAliveBlocks(F, Reachable);
// If there are unreachable blocks in the CFG...
Modified: llvm/trunk/lib/Transforms/Utils/SplitModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SplitModule.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SplitModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SplitModule.cpp Fri Jan 29 19:24:31 2016
@@ -138,7 +138,7 @@ static void findPartitions(Module *M, Cl
typedef std::pair<unsigned, ClusterMapType::iterator> SortType;
SmallVector<SortType, 64> Sets;
- SmallPtrSet<const GlobalValue *, 64> Visited;
+ SmallPtrSet<const GlobalValue *, 32> Visited;
// To guarantee determinism, we have to sort SCC according to size.
// When size is the same, use leader's name.
Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=259283&r1=259282&r2=259283&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original)
+++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Fri Jan 29 19:24:31 2016
@@ -459,7 +459,7 @@ bool ReduceCrashingInstructions::TestIns
Module *M = CloneModule(BD.getProgram(), VMap).release();
// Convert list to set for fast lookup...
- SmallPtrSet<Instruction*, 64> Instructions;
+ SmallPtrSet<Instruction*, 32> Instructions;
for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
assert(!isa<TerminatorInst>(Insts[i]));
Instructions.insert(cast<Instruction>(VMap[Insts[i]]));
@@ -600,7 +600,7 @@ public:
bool ReduceCrashingNamedMDOps::TestNamedMDOps(
std::vector<const MDNode *> &NamedMDOps) {
// Convert list to set for fast lookup...
- SmallPtrSet<const MDNode *, 64> OldMDNodeOps;
+ SmallPtrSet<const MDNode *, 32> OldMDNodeOps;
for (unsigned i = 0, e = NamedMDOps.size(); i != e; ++i) {
OldMDNodeOps.insert(NamedMDOps[i]);
}
More information about the llvm-commits
mailing list