From: Ted Kremenek Date: Wed, 2 Sep 2009 06:03:18 +0000 (+0000) Subject: Replace uses of ImmutableSet in SymbolReaper with DenseSet. This was X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a97d54c165ca6b6e57b9f333059a84c2188dd591;p=clang 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80765 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/SymbolManager.h b/include/clang/Analysis/PathSensitive/SymbolManager.h index d2556cb75c..1a46e90b41 100644 --- a/include/clang/Analysis/PathSensitive/SymbolManager.h +++ b/include/clang/Analysis/PathSensitive/SymbolManager.h @@ -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 SetTy; - typedef SetTy::Factory FactoryTy; + typedef llvm::DenseSet 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(); } }; diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp index b94551e31f..d2a82fd1fc 100644 --- a/lib/Analysis/SymbolManager.cpp +++ b/lib/Analysis/SymbolManager.cpp @@ -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(sym)) {