]> granicus.if.org Git - clang/commitdiff
Replace uses of ImmutableSet in SymbolReaper with DenseSet. This was
authorTed Kremenek <kremenek@apple.com>
Wed, 2 Sep 2009 06:03:18 +0000 (06:03 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 2 Sep 2009 06:03:18 +0000 (06:03 +0000)
motivated from Shark profiles that shows that 'markLive' was very
heavy when using --analyzer-store=region.  On my benchmark file, this
reduces the analysis time for --analyzer-store=region from 19.5s to
13.5s and for --analyzer-store=basic from 5.3s to 3.5s.  For the
benchmark file, this is a reduction of about 30% analysis time for
both analysis modes (a huge win).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80765 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/SymbolManager.h
lib/Analysis/SymbolManager.cpp

index d2556cb75c7cbec48533d3ae5492c5e81f4dbc8e..1a46e90b4194610edb36754b79b242c9fd2ccc34 100644 (file)
@@ -21,8 +21,7 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/ImmutableSet.h"
+#include "llvm/ADT/DenseSet.h"
 
 namespace llvm {
   class raw_ostream;
@@ -327,10 +326,8 @@ public:
 };
   
 class SymbolReaper {
-  typedef llvm::ImmutableSet<SymbolRef> SetTy;
-  typedef SetTy::Factory FactoryTy;
+  typedef llvm::DenseSet<SymbolRef> SetTy;
   
-  FactoryTy F;
   SetTy TheLiving;
   SetTy TheDead;
   LiveVariables& Liveness;
@@ -338,8 +335,9 @@ class SymbolReaper {
   
 public:
   SymbolReaper(LiveVariables& liveness, SymbolManager& symmgr)
-  : TheLiving(F.GetEmptySet()), TheDead(F.GetEmptySet()),
-    Liveness(liveness), SymMgr(symmgr) {}
+    : Liveness(liveness), SymMgr(symmgr) {}
+  
+  ~SymbolReaper() {}
 
   bool isLive(SymbolRef sym);
 
@@ -354,12 +352,12 @@ public:
   void markLive(SymbolRef sym);
   bool maybeDead(SymbolRef sym);
   
-  typedef SetTy::iterator dead_iterator;
+  typedef SetTy::const_iterator dead_iterator;
   dead_iterator dead_begin() const { return TheDead.begin(); }
   dead_iterator dead_end() const { return TheDead.end(); }
   
   bool hasDeadSymbols() const {
-    return !TheDead.isEmpty();
+    return !TheDead.empty();
   }
 };
   
index b94551e31f225cf710f75efcd3e1f4ef30e11e17..d2a82fd1fc95b0225ab6dc2575bfa78f831914a4 100644 (file)
@@ -191,20 +191,20 @@ bool SymbolManager::canSymbolicate(QualType T) {
 }
 
 void SymbolReaper::markLive(SymbolRef sym) {
-  TheLiving = F.Add(TheLiving, sym);
-  TheDead = F.Remove(TheDead, sym);
+  TheLiving.insert(sym);
+  TheDead.erase(sym);
 }
 
 bool SymbolReaper::maybeDead(SymbolRef sym) {
   if (isLive(sym))
     return false;
   
-  TheDead = F.Add(TheDead, sym);
+  TheDead.insert(sym);
   return true;
 }
 
 bool SymbolReaper::isLive(SymbolRef sym) {
-  if (TheLiving.contains(sym))
+  if (TheLiving.count(sym))
     return true;
   
   if (const SymbolDerived *derived = dyn_cast<SymbolDerived>(sym)) {