aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-02-24 01:07:55 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-02-24 01:07:55 +0000
commitb2597268c215e2349905c81bfc22f69849b5ab18 (patch)
tree7f0335ab95458fdbd924246a13f71395dcab1266
parentfae7f6de9ec18a6a8331b7ddbf51fd5f5c3e4288 (diff)
Use the same spill slot for all live ranges that descend form the same original
register. This avoids some silly stack slot shuffling when both sides of a copy get spilled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126353 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/InlineSpiller.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/CodeGen/InlineSpiller.cpp b/lib/CodeGen/InlineSpiller.cpp
index ba37e544e7..38e6c85902 100644
--- a/lib/CodeGen/InlineSpiller.cpp
+++ b/lib/CodeGen/InlineSpiller.cpp
@@ -345,7 +345,8 @@ void InlineSpiller::spill(LiveRangeEdit &edit) {
&& "Trying to spill a stack slot.");
DEBUG(dbgs() << "Inline spilling "
<< mri_.getRegClass(edit.getReg())->getName()
- << ':' << edit.getParent() << "\n");
+ << ':' << edit.getParent() << "\nFrom original "
+ << PrintReg(vrm_.getOriginal(edit.getReg())) << '\n');
assert(edit.getParent().isSpillable() &&
"Attempting to spill already spilled value.");
@@ -356,12 +357,20 @@ void InlineSpiller::spill(LiveRangeEdit &edit) {
return;
rc_ = mri_.getRegClass(edit.getReg());
- stackSlot_ = vrm_.assignVirt2StackSlot(edit_->getReg());
+
+ // Share a stack slot among all descendants of Orig.
+ unsigned Orig = vrm_.getOriginal(edit.getReg());
+ stackSlot_ = vrm_.getStackSlot(Orig);
+ if (stackSlot_ == VirtRegMap::NO_STACK_SLOT)
+ stackSlot_ = vrm_.assignVirt2StackSlot(Orig);
+
+ if (Orig != edit.getReg())
+ vrm_.assignVirt2StackSlot(edit.getReg(), stackSlot_);
// Update LiveStacks now that we are committed to spilling.
LiveInterval &stacklvr = lss_.getOrCreateInterval(stackSlot_, rc_);
- assert(stacklvr.empty() && "Just created stack slot not empty");
- stacklvr.getNextValue(SlotIndex(), 0, lss_.getVNInfoAllocator());
+ if (!stacklvr.hasAtLeastOneValue())
+ stacklvr.getNextValue(SlotIndex(), 0, lss_.getVNInfoAllocator());
stacklvr.MergeRangesInAsValue(edit_->getParent(), stacklvr.getValNumInfo(0));
// Iterate over instructions using register.