summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegisterCoalescer.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-19 20:54:03 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-19 20:54:03 +0000
commit56366601765c1ff43f8796c271a818f8c272af27 (patch)
tree1715e7ea15393386a246ac04dd0929ca7788b256 /lib/CodeGen/RegisterCoalescer.cpp
parent87d35e8c715f5116b072ef8fd742c0cfb6fb5ce4 (diff)
downloadllvm-56366601765c1ff43f8796c271a818f8c272af27.tar.gz
llvm-56366601765c1ff43f8796c271a818f8c272af27.tar.bz2
llvm-56366601765c1ff43f8796c271a818f8c272af27.tar.xz
Fix an ancient bug in removeCopyByCommutingDef().
Before rewriting uses of one value in A to register B, check that there are no tied uses. That would require multiple A values to be rewritten. This bug can't bite in the current version of the code for a fairly subtle reason: A tied use would have caused 2-addr to insert a copy before the use. If the copy has been coalesced, it will be found by the same loop changed by this patch, and the optimization is aborted. This was exposed by 400.perlbench and lua after applying a patch that deletes joined copies aggressively. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegisterCoalescer.cpp')
-rw-r--r--lib/CodeGen/RegisterCoalescer.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp
index dbd2cdd8d3..5e876df866 100644
--- a/lib/CodeGen/RegisterCoalescer.cpp
+++ b/lib/CodeGen/RegisterCoalescer.cpp
@@ -687,9 +687,12 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
MachineInstr *UseMI = &*UI;
SlotIndex UseIdx = LIS->getInstructionIndex(UseMI);
LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx);
- if (ULR == IntA.end())
+ if (ULR == IntA.end() || ULR->valno != AValNo)
continue;
- if (ULR->valno == AValNo && JoinedCopies.count(UseMI))
+ if (JoinedCopies.count(UseMI))
+ return false;
+ // If this use is tied to a def, we can't rewrite the register.
+ if (UseMI->isRegTiedToDefOperand(UI.getOperandNo()))
return false;
}