summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-05-13 00:00:35 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-05-13 00:00:35 +0000
commit4aab8b54250754bd282f87889d50be8018f6d39d (patch)
treea07d13fdeeb278b4accef0fd1e938486731ca7c1 /llvm/lib
parentecf016601212fb655947def982a50f102315dd01 (diff)
downloadbcm5719-llvm-4aab8b54250754bd282f87889d50be8018f6d39d.tar.gz
bcm5719-llvm-4aab8b54250754bd282f87889d50be8018f6d39d.zip
If REG_SEQUENCE source is livein, copy it first. Also, update livevariables information when a copy is introduced.
llvm-svn: 103680
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TwoAddressInstructionPass.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index bd24bab13e7..9f00311fb44 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -1175,17 +1175,36 @@ bool TwoAddressInstructionPass::EliminateRegSequences() {
llvm_unreachable(0);
}
- if (!Seen.insert(SrcReg)) {
- // REG_SEQUENCE cannot have duplicated operands. Add a copy.
+ MachineInstr *DefMI = MRI->getVRegDef(SrcReg);
+ if (!Seen.insert(SrcReg) || MI->getParent() != DefMI->getParent()) {
+ // REG_SEQUENCE cannot have duplicated operands, add a copy.
+ // Also add an copy if the source if live-in the block. We don't want
+ // to end up with a partial-redef of a livein, e.g.
+ // BB0:
+ // reg1051:10<def> =
+ // ...
+ // BB1:
+ // ... = reg1051:10
+ // BB2:
+ // reg1051:9<def> =
+ // LiveIntervalAnalysis won't like it.
const TargetRegisterClass *RC = MRI->getRegClass(SrcReg);
unsigned NewReg = MRI->createVirtualRegister(RC);
+ MachineBasicBlock::iterator InsertLoc = MI;
bool Emitted =
- TII->copyRegToReg(*MI->getParent(), MI, NewReg, SrcReg, RC, RC,
+ TII->copyRegToReg(*MI->getParent(), InsertLoc, NewReg, SrcReg, RC, RC,
MI->getDebugLoc());
(void)Emitted;
assert(Emitted && "Unable to issue a copy instruction!\n");
MI->getOperand(i).setReg(NewReg);
- MI->getOperand(i).setIsKill();
+ if (MI->getOperand(i).isKill()) {
+ MachineBasicBlock::iterator CopyMI = prior(InsertLoc);
+ MachineOperand *KillMO = CopyMI->findRegisterUseOperand(SrcReg);
+ KillMO->setIsKill();
+ if (LV)
+ // Update live variables
+ LV->replaceKillInstruction(SrcReg, MI, &*CopyMI);
+ }
}
}
OpenPOWER on IntegriCloud