summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-09-12 11:06:26 +0000
committerNadav Rotem <nrotem@apple.com>2012-09-12 11:06:26 +0000
commit9566ca9af852fc9b688b69f4aa3302bb2230827f (patch)
treebaeebabc078ffe47f89db18b4f6d57f29a78665c /llvm/lib/CodeGen
parentf331aa9c00d46f4fca65cb16ebef97e6749fbd88 (diff)
downloadbcm5719-llvm-9566ca9af852fc9b688b69f4aa3302bb2230827f.tar.gz
bcm5719-llvm-9566ca9af852fc9b688b69f4aa3302bb2230827f.zip
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.
llvm-svn: 163702
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/StackColoring.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 0deb35ad7fb..a14d730025f 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -59,12 +59,20 @@ using namespace llvm;
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 @@ class StackColoring : public MachineFunctionPass {
/// 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 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
#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 @@ void StackColoring::removeInvalidSlotRanges() {
if (Interval->find(Index) == Interval->end()) {
Intervals[Slot]->clear();
DEBUG(dbgs()<<"Invalidating range #"<<Slot<<"\n");
+ EscapedAllocas++;
}
}
}
@@ -662,7 +671,10 @@ bool StackColoring::runOnMachineFunction(MachineFunction &Func) {
// 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;
OpenPOWER on IntegriCloud