[cfe-commits] r67152 - /cfe/trunk/lib/Analysis/RegionStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Tue Mar 17 18:54:31 PDT 2009


Author: zhongxingxu
Date: Tue Mar 17 20:54:31 2009
New Revision: 67152

URL: http://llvm.org/viewvc/llvm-project?rev=67152&view=rev
Log:
Use a work list to recursively build up the subregion mapping, and mark live
var region roots.

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Tue Mar 17 20:54:31 2009
@@ -955,8 +955,17 @@
   // Do a pass over the regions in the store.  For VarRegions we check if
   // the variable is still live and if so add it to the list of live roots.
   // For other regions we populate our region backmap.
+
+  llvm::SmallVector<const MemRegion*, 10> IntermediateRoots;
+
   for (RegionBindingsTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
-    const MemRegion* R = I.getKey();
+    IntermediateRoots.push_back(I.getKey());
+  }
+
+  while (!IntermediateRoots.empty()) {
+    const MemRegion* R = IntermediateRoots.back();
+    IntermediateRoots.pop_back();
+
     if (const VarRegion* VR = dyn_cast<VarRegion>(R)) {
       if (SymReaper.isLive(Loc, VR->getDecl()))
         RegionRoots.push_back(VR); // This is a live "root".
@@ -964,19 +973,18 @@
     else {
       // Get the super region for R.
       const MemRegion* SuperR = cast<SubRegion>(R)->getSuperRegion();
+
       // Get the current set of subregions for SuperR.
       const SubRegionsTy* SRptr = SubRegMap.lookup(SuperR);
       SubRegionsTy SR = SRptr ? *SRptr : SubRegF.GetEmptySet();
+
       // Add R to the subregions of SuperR.
       SubRegMap = SubRegMapF.Add(SubRegMap, SuperR, SubRegF.Add(SR, R));
-      
-      // Finally, check if SuperR is a VarRegion.  We need to do this
-      // to also mark SuperR as a root (as it may not have a value directly
-      // bound to it in the store).
-      if (const VarRegion* VR = dyn_cast<VarRegion>(SuperR)) {
-        if (SymReaper.isLive(Loc, VR->getDecl()))
-          RegionRoots.push_back(VR); // This is a live "root".
-      }
+
+      // Super region may be VarRegion or subregion of another VarRegion. Add it
+      // to the work list.
+      if (isa<SubRegion>(SuperR))
+        IntermediateRoots.push_back(SuperR);
     }
   }
   





More information about the cfe-commits mailing list