[PATCH] D16705: Avoid overly large SmallPtrSet/SmallSet
Matthias Braun via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 28 19:44:51 PST 2016
MatzeB created this revision.
MatzeB added reviewers: chandlerc, reames, echristo.
MatzeB added a subscriber: cfe-commits.
MatzeB set the repository for this revision to rL LLVM.
Herald added a subscriber: mcrosier.
These sets perform linear searching in small mode so it is never a good
idea to use SmallSize/N bigger than 32.
Repository:
rL LLVM
http://reviews.llvm.org/D16705
Files:
lib/Analysis/PseudoConstantAnalysis.cpp
lib/Sema/SemaDeclObjC.cpp
lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -26,10 +26,6 @@
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "llvm/ADT/SmallSet.h"
-// The number of CFGBlock pointers we want to reserve memory for. This is used
-// once for each function we analyze.
-#define DEFAULT_CFGBLOCKS 256
-
using namespace clang;
using namespace ento;
@@ -39,7 +35,7 @@
void checkEndAnalysis(ExplodedGraph &G, BugReporter &B,
ExprEngine &Eng) const;
private:
- typedef llvm::SmallSet<unsigned, DEFAULT_CFGBLOCKS> CFGBlocksSet;
+ typedef llvm::SmallSet<unsigned, 32> CFGBlocksSet;
static inline const Stmt *getUnreachableStmt(const CFGBlock *CB);
static void FindUnreachableEntryPoints(const CFGBlock *CB,
Index: lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
+++ lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
@@ -43,7 +43,7 @@
ExprEngine &Eng) const {
const CFG *C = nullptr;
const SourceManager &SM = B.getSourceManager();
- llvm::SmallPtrSet<const CFGBlock*, 256> reachable;
+ llvm::SmallPtrSet<const CFGBlock*, 32> reachable;
// Root node should have the location context of the top most function.
const ExplodedNode *GraphRoot = *G.roots_begin();
Index: lib/Sema/SemaDeclObjC.cpp
===================================================================
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -3843,7 +3843,7 @@
}
}
- typedef llvm::SmallPtrSet<ObjCMethodDecl*, 128>::iterator iterator;
+ typedef llvm::SmallPtrSetImpl<ObjCMethodDecl*>::iterator iterator;
iterator begin() const { return Overridden.begin(); }
iterator end() const { return Overridden.end(); }
Index: lib/Analysis/PseudoConstantAnalysis.cpp
===================================================================
--- lib/Analysis/PseudoConstantAnalysis.cpp
+++ lib/Analysis/PseudoConstantAnalysis.cpp
@@ -22,9 +22,7 @@
using namespace clang;
-// The number of ValueDecls we want to keep track of by default (per-function)
-#define VARDECL_SET_SIZE 256
-typedef llvm::SmallPtrSet<const VarDecl*, VARDECL_SET_SIZE> VarDeclSet;
+typedef llvm::SmallPtrSet<const VarDecl*, 32> VarDeclSet;
PseudoConstantAnalysis::PseudoConstantAnalysis(const Stmt *DeclBody) :
DeclBody(DeclBody), Analyzed(false) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16705.46337.patch
Type: text/x-patch
Size: 2659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160129/c9504aae/attachment.bin>
More information about the cfe-commits
mailing list