aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-11-06 21:12:10 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-11-06 21:12:10 +0000
commit945923c3f11ee4ad9f261a9bca0c0a104d6804f8 (patch)
tree0c8ffa9cc7a4dfb05b9e5fe0bdb07ec17ae842de
parentd7697db6bda38893803b773a06d3a81354e15c42 (diff)
downloadexternal_llvm-945923c3f11ee4ad9f261a9bca0c0a104d6804f8.zip
external_llvm-945923c3f11ee4ad9f261a9bca0c0a104d6804f8.tar.gz
external_llvm-945923c3f11ee4ad9f261a9bca0c0a104d6804f8.tar.bz2
When the allocator rewrite a spill register with new virtual register, it replaces other operands of the same register. Watch out for situations where
only some of the operands are sub-register uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43776 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index 9301c28..929b1e7 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -379,10 +379,19 @@ addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, unsigned reg) {
if (!MI->getOperand(j).isRegister())
continue;
unsigned RegJ = MI->getOperand(j).getReg();
- if (RegJ != 0 && MRegisterInfo::isVirtualRegister(RegJ) &&
- RegMap->isSubRegister(RegJ))
+ if (RegJ == 0 || MRegisterInfo::isPhysicalRegister(RegJ))
+ continue;
+ bool isSubRegJ = RegMap->isSubRegister(RegJ);
+ if (isSubRegJ) {
+ assert(!isSubReg || RegMap->getSubRegisterIndex(RegJ) == SubIdx);
RegJ = RegMap->getSuperRegister(RegJ);
- if (RegJ == li.reg) {
+ }
+ // Important to check "isSubRegJ == isSubReg".
+ // e.g. %reg1024 = MOVSX32rr16 %reg1025. It's possible that both
+ // registers are coalesced to the same register but only %reg1025 is
+ // a sub-register use. They should not be rewritten to the same
+ // register.
+ if (RegJ == li.reg && isSubRegJ == isSubReg) {
MI->getOperand(j).setReg(NewVReg);
HasUse |= MI->getOperand(j).isUse();
HasDef |= MI->getOperand(j).isDef();