summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveRangeEdit.cpp
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2011-12-12 22:16:27 +0000
committerPete Cooper <peter_cooper@apple.com>2011-12-12 22:16:27 +0000
commit4777ebb767d1b590c05d502c4a7f6adef4e6d5d1 (patch)
tree966f9a340cc4d85b357a317b7b695c1610fcf1c0 /lib/CodeGen/LiveRangeEdit.cpp
parent22614a02eb8855548a892139e54e478c70050f9f (diff)
downloadllvm-4777ebb767d1b590c05d502c4a7f6adef4e6d5d1.tar.gz
llvm-4777ebb767d1b590c05d502c4a7f6adef4e6d5d1.tar.bz2
llvm-4777ebb767d1b590c05d502c4a7f6adef4e6d5d1.tar.xz
Fixed register allocator splitting a live range on a spilling variable.
If we create new intervals for a variable that is being spilled, then those new intervals are not guaranteed to also spill. This means that anything reading from the original spilling value might not get the correct value if spills were missed. Fixes <rdar://problem/10546864> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveRangeEdit.cpp')
-rw-r--r--lib/CodeGen/LiveRangeEdit.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/LiveRangeEdit.cpp b/lib/CodeGen/LiveRangeEdit.cpp
index 428b252f97..a470877e12 100644
--- a/lib/CodeGen/LiveRangeEdit.cpp
+++ b/lib/CodeGen/LiveRangeEdit.cpp
@@ -210,7 +210,8 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI,
void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
LiveIntervals &LIS, VirtRegMap &VRM,
- const TargetInstrInfo &TII) {
+ const TargetInstrInfo &TII,
+ ArrayRef<unsigned> RegsBeingSpilled) {
SetVector<LiveInterval*,
SmallVector<LiveInterval*, 8>,
SmallPtrSet<LiveInterval*, 8> > ToShrink;
@@ -290,6 +291,21 @@ void LiveRangeEdit::eliminateDeadDefs(SmallVectorImpl<MachineInstr*> &Dead,
delegate_->LRE_WillShrinkVirtReg(LI->reg);
if (!LIS.shrinkToUses(LI, &Dead))
continue;
+
+ // Don't create new intervals for a register being spilled.
+ // The new intervals would have to be spilled anyway so its not worth it.
+ // Also they currently aren't spilled so creating them and not spilling
+ // them results in incorrect code.
+ bool BeingSpilled = false;
+ for (unsigned i = 0, e = RegsBeingSpilled.size(); i != e; ++i) {
+ if (LI->reg == RegsBeingSpilled[i]) {
+ BeingSpilled = true;
+ break;
+ }
+ }
+
+ if (BeingSpilled) continue;
+
// LI may have been separated, create new intervals.
LI->RenumberValues(LIS);