[llvm-commits] [llvm] r163702 - /llvm/trunk/lib/CodeGen/StackColoring.cpp

Nadav Rotem nrotem at apple.com
Wed Sep 12 04:06:26 PDT 2012


Author: nadav
Date: Wed Sep 12 06:06:26 2012
New Revision: 163702

URL: http://llvm.org/viewvc/llvm-project?rev=163702&view=rev
Log:
Add a flag to disable the code that looks for allocas which escaped the lifetime regions. This is useful for debugging. No testcase because without this check we fail on assertions when finding escaped allocas.

Modified:
    llvm/trunk/lib/CodeGen/StackColoring.cpp

Modified: llvm/trunk/lib/CodeGen/StackColoring.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackColoring.cpp?rev=163702&r1=163701&r2=163702&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackColoring.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackColoring.cpp Wed Sep 12 06:06:26 2012
@@ -59,12 +59,20 @@
 
 static cl::opt<bool>
 DisableColoring("no-stack-coloring",
-               cl::init(false), cl::Hidden,
-               cl::desc("Suppress stack coloring"));
+        cl::init(false), cl::Hidden,
+        cl::desc("Disable stack coloring"));
 
-STATISTIC(NumMarkerSeen,  "Number of life markers found.");
+static cl::opt<bool>
+CheckEscapedAllocas("stack-coloring-check-escaped",
+        cl::init(true), cl::Hidden,
+        cl::desc("Look for allocas which escaped the lifetime region"));
+
+STATISTIC(NumMarkerSeen,  "Number of lifetime markers found.");
 STATISTIC(StackSpaceSaved, "Number of bytes saved due to merging slots.");
 STATISTIC(StackSlotMerged, "Number of stack slot merged.");
+STATISTIC(EscapedAllocas,
+          "Number of allocas that escaped the lifetime region");
+
 
 //===----------------------------------------------------------------------===//
 //                           StackColoring Pass
@@ -104,7 +112,7 @@
   /// VNInfo is used for the construction of LiveIntervals.
   VNInfo::Allocator VNInfoAllocator;
   /// SlotIndex analysis object.
-  SlotIndexes* Indexes;
+  SlotIndexes *Indexes;
 
   /// The list of lifetime markers found. These markers are to be removed
   /// once the coloring is done.
@@ -533,7 +541,7 @@
 #ifndef NDEBUG
         if (!I->isDebugValue()) {
           SlotIndex Index = Indexes->getInstructionIndex(I);
-          LiveInterval* Interval = Intervals[FromSlot];
+          LiveInterval *Interval = Intervals[FromSlot];
           assert(Interval->find(Index) != Interval->end() &&
                "Found instruction usage outside of live range.");
         }
@@ -583,6 +591,7 @@
         if (Interval->find(Index) == Interval->end()) {
           Intervals[Slot]->clear();
           DEBUG(dbgs()<<"Invalidating range #"<<Slot<<"\n");
+          EscapedAllocas++;
         }
       }
     }
@@ -662,7 +671,10 @@
   // Propagate the liveness information.
   calculateLiveIntervals(NumSlots);
 
-  removeInvalidSlotRanges();
+  // Search for allocas which are used outside of the declared lifetime
+  // markers.
+  if (CheckEscapedAllocas)
+    removeInvalidSlotRanges();
 
   // Maps old slots to new slots.
   DenseMap<int, int> SlotRemap;





More information about the llvm-commits mailing list