[PATCH] D20933: Preallocate ExplodedNode hash table

Ben Craig via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 13:12:34 PDT 2016


bcraig updated this revision to Diff 60177.
bcraig added a comment.

Capping the pre-reserve space


http://reviews.llvm.org/D20933

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: lib/StaticAnalyzer/Core/CoreEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -208,6 +208,9 @@
 
   // Check if we have a steps limit
   bool UnlimitedSteps = Steps == 0;
+  const unsigned PreReservationCap = 4000000;
+  if(!UnlimitedSteps)
+    G.reserve(std::min(Steps,PreReservationCap));
 
   while (WList->hasWork()) {
     if (!UnlimitedSteps) {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
===================================================================
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
@@ -321,6 +321,8 @@
   bool empty() const { return NumNodes == 0; }
   unsigned size() const { return NumNodes; }
 
+  void reserve(unsigned NodeCount) { Nodes.reserve(NodeCount); }
+
   // Iterators.
   typedef ExplodedNode                        NodeTy;
   typedef llvm::FoldingSet<ExplodedNode>      AllNodesTy;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20933.60177.patch
Type: text/x-patch
Size: 1067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160609/4ddf1a9e/attachment.bin>


More information about the cfe-commits mailing list