[cfe-commits] r80765 - in /cfe/trunk: include/clang/Analysis/PathSensitive/SymbolManager.h lib/Analysis/SymbolManager.cpp

Ted Kremenek kremenek at apple.com
Tue Sep 1 23:03:19 PDT 2009


Author: kremenek
Date: Wed Sep  2 01:03:18 2009
New Revision: 80765

URL: http://llvm.org/viewvc/llvm-project?rev=80765&view=rev
Log:
Replace uses of ImmutableSet in SymbolReaper with DenseSet.  This was
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).

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
    cfe/trunk/lib/Analysis/SymbolManager.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h?rev=80765&r1=80764&r2=80765&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Wed Sep  2 01:03:18 2009
@@ -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 @@
 };
   
 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 @@
   
 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 @@
   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();
   }
 };
   

Modified: cfe/trunk/lib/Analysis/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SymbolManager.cpp?rev=80765&r1=80764&r2=80765&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Analysis/SymbolManager.cpp Wed Sep  2 01:03:18 2009
@@ -191,20 +191,20 @@
 }
 
 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)) {





More information about the cfe-commits mailing list