[cfe-commits] r140403 - /cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp

Anna Zaks ganna at apple.com
Fri Sep 23 12:14:09 PDT 2011


Author: zaks
Date: Fri Sep 23 14:14:09 2011
New Revision: 140403

URL: http://llvm.org/viewvc/llvm-project?rev=140403&view=rev
Log:
Move immutable map canonization out of the removeDeadBindings loop (via using ImmutableMapRef). Gives ~2% speedup.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp?rev=140403&r1=140402&r2=140403&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp Fri Sep 23 14:14:09 2011
@@ -159,6 +159,10 @@
   MarkLiveCallback CB(SymReaper);
   ScanReachableSymbols RSScaner(ST, CB);
 
+  llvm::ImmutableMapRef<const Stmt*,SVal>
+    EBMapRef(NewEnv.ExprBindings.getRootWithoutRetain(),
+             F.getTreeFactory());
+
   // Iterate over the block-expr bindings.
   for (Environment::iterator I = Env.begin(), E = Env.end();
        I != E; ++I) {
@@ -177,7 +181,7 @@
 
     if (SymReaper.isLive(BlkExpr)) {
       // Copy the binding to the new map.
-      NewEnv.ExprBindings = F.add(NewEnv.ExprBindings, BlkExpr, X);
+      EBMapRef = EBMapRef.add(BlkExpr, X);
 
       // If the block expr's value is a memory region, then mark that region.
       if (isa<loc::MemRegionVal>(X)) {
@@ -195,7 +199,7 @@
     // beginning of itself, but we need its UndefinedVal to determine its
     // SVal.
     if (X.isUndef() && cast<UndefinedVal>(X).getData())
-      NewEnv.ExprBindings = F.add(NewEnv.ExprBindings, BlkExpr, X);
+      EBMapRef = EBMapRef.add(BlkExpr, X);
   }
   
   // Go through he deferred locations and add them to the new environment if
@@ -203,9 +207,10 @@
   for (SmallVectorImpl<std::pair<const Stmt*, SVal> >::iterator
       I = deferredLocations.begin(), E = deferredLocations.end(); I != E; ++I) {
     const Stmt *S = (Stmt*) (((uintptr_t) I->first) & (uintptr_t) ~0x1);
-    if (NewEnv.ExprBindings.lookup(S))
-      NewEnv.ExprBindings = F.add(NewEnv.ExprBindings, I->first, I->second);
+    if (EBMapRef.lookup(S))
+      EBMapRef = EBMapRef.add(I->first, I->second);
   }
 
+  NewEnv.ExprBindings = EBMapRef.asImmutableMap();
   return NewEnv;
 }





More information about the cfe-commits mailing list