summaryrefslogtreecommitdiff
path: root/lib/CodeGen/StackColoring.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-09-10 12:39:35 +0000
committerNadav Rotem <nrotem@apple.com>2012-09-10 12:39:35 +0000
commite47feeb823ebf496e82db6a666d4c0fbaeb158b4 (patch)
tree3f21995ebef5c3b04c895d850743b05cd08c06a1 /lib/CodeGen/StackColoring.cpp
parent8100d244ff1e29c5e4cc864152c2e210dc6c4275 (diff)
downloadllvm-e47feeb823ebf496e82db6a666d4c0fbaeb158b4.tar.gz
llvm-e47feeb823ebf496e82db6a666d4c0fbaeb158b4.tar.bz2
llvm-e47feeb823ebf496e82db6a666d4c0fbaeb158b4.tar.xz
Stack Coloring: Add support for multiple regions of the same slot, within a single basic block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/StackColoring.cpp')
-rw-r--r--lib/CodeGen/StackColoring.cpp56
1 files changed, 33 insertions, 23 deletions
diff --git a/lib/CodeGen/StackColoring.cpp b/lib/CodeGen/StackColoring.cpp
index b0cbda827c..027096b810 100644
--- a/lib/CodeGen/StackColoring.cpp
+++ b/lib/CodeGen/StackColoring.cpp
@@ -351,40 +351,50 @@ void StackColoring::calculateLiveIntervals(unsigned NumSlots) {
Finishes.clear();
Finishes.resize(NumSlots);
- BitVector Alive = BlockLiveness[MBB].LiveIn;
- Alive |= BlockLiveness[MBB].LiveOut;
-
- if (Alive.any()) {
- for (int pos = Alive.find_first(); pos != -1;
- pos = Alive.find_next(pos)) {
- Starts[pos] = Indexes->getMBBStartIdx(MBB);
- Finishes[pos] = Indexes->getMBBEndIdx(MBB);
- }
- }
-
+ // Create the interval for the basic blocks with lifetime markers in them.
for (SmallVector<MachineInstr*, 8>::iterator it = Markers.begin(),
e = Markers.end(); it != e; ++it) {
MachineInstr *MI = *it;
+ if (MI->getParent() != MBB)
+ continue;
+
assert((MI->getOpcode() == TargetOpcode::LIFETIME_START ||
MI->getOpcode() == TargetOpcode::LIFETIME_END) &&
"Invalid Lifetime marker");
- if (MI->getParent() == MBB) {
- bool IsStart = MI->getOpcode() == TargetOpcode::LIFETIME_START;
- MachineOperand &Mo = MI->getOperand(0);
- int Slot = Mo.getIndex();
- assert(Slot >= 0 && "Invalid slot");
- if (IsStart) {
- Starts[Slot] = Indexes->getInstructionIndex(MI);
- } else {
- Finishes[Slot] = Indexes->getInstructionIndex(MI);
- }
+ bool IsStart = MI->getOpcode() == TargetOpcode::LIFETIME_START;
+ MachineOperand &Mo = MI->getOperand(0);
+ int Slot = Mo.getIndex();
+ assert(Slot >= 0 && "Invalid slot");
+
+ SlotIndex ThisIndex = Indexes->getInstructionIndex(MI);
+
+ if (IsStart) {
+ if (!Starts[Slot].isValid() || Starts[Slot] > ThisIndex)
+ Starts[Slot] = ThisIndex;
+ } else {
+ if (!Finishes[Slot].isValid() || Finishes[Slot] < ThisIndex)
+ Finishes[Slot] = ThisIndex;
+ }
+ }
+
+ // Create the interval of the blocks that we previously found to be 'alive'.
+ BitVector Alive = BlockLiveness[MBB].LiveIn;
+ Alive |= BlockLiveness[MBB].LiveOut;
+
+ if (Alive.any()) {
+ for (int pos = Alive.find_first(); pos != -1;
+ pos = Alive.find_next(pos)) {
+ if (!Starts[pos].isValid())
+ Starts[pos] = Indexes->getMBBStartIdx(MBB);
+ if (!Finishes[pos].isValid())
+ Finishes[pos] = Indexes->getMBBEndIdx(MBB);
}
}
for (unsigned i = 0; i < NumSlots; ++i) {
- assert(!!Starts[i] == !!Finishes[i] && "Unmatched range");
- if (Starts[i] == Finishes[i])
+ assert(Starts[i].isValid() == Finishes[i].isValid() && "Unmatched range");
+ if (!Starts[i].isValid())
continue;
assert(Starts[i] && Finishes[i] && "Invalid interval");