diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-08-09 20:19:16 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-08-09 20:19:16 +0000 |
commit | e4b9c4f1871c5f17681fdf143104c6834055b25b (patch) | |
tree | 0c46735cb6425e607fc2233342b6e5e8c1911b1b /lib/CodeGen/TwoAddressInstructionPass.cpp | |
parent | 9de1ac267e197d40cec7a14041f2bf69498536c9 (diff) | |
download | external_llvm-e4b9c4f1871c5f17681fdf143104c6834055b25b.zip external_llvm-e4b9c4f1871c5f17681fdf143104c6834055b25b.tar.gz external_llvm-e4b9c4f1871c5f17681fdf143104c6834055b25b.tar.bz2 |
A REG_SEQUENCE instruction may use the same register twice.
If we are emitting COPY instructions for the REG_SEQUENCE, make sure the kill
flag goes on the last COPY. Otherwise we may be using a killed register.
<rdar://problem/8287792>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r-- | lib/CodeGen/TwoAddressInstructionPass.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp index 2e17ebc..f58f8f5 100644 --- a/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -1446,7 +1446,17 @@ bool TwoAddressInstructionPass::EliminateRegSequences() { // // If the REG_SEQUENCE doesn't kill its source, keeping live variables // correctly up to date becomes very difficult. Insert a copy. - // + + // Defer any kill flag to the last operand using SrcReg. Otherwise, we + // might insert a COPY that uses SrcReg after is was killed. + if (isKill) + for (unsigned j = i + 2; j < e; j += 2) + if (MI->getOperand(j).getReg() == SrcReg) { + MI->getOperand(j).setIsKill(); + isKill = false; + break; + } + MachineBasicBlock::iterator InsertLoc = MI; MachineInstr *CopyMI = BuildMI(*MI->getParent(), InsertLoc, MI->getDebugLoc(), TII->get(TargetOpcode::COPY)) |