diff options
author | Simon Tatham <simon.tatham@arm.com> | 2022-10-13 09:18:31 +0100 |
---|---|---|
committer | Simon Tatham <simon.tatham@arm.com> | 2022-10-13 09:40:35 +0100 |
commit | 526ce9c9299ad1f8c2c5971204066dd02e528199 (patch) | |
tree | 9af6f9257e37b8b344c8890bac832ebd1c589674 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 89c923655aad6de837e386aa6e1dfa72c16e2697 (diff) | |
download | llvm-526ce9c9299ad1f8c2c5971204066dd02e528199.zip llvm-526ce9c9299ad1f8c2c5971204066dd02e528199.tar.gz llvm-526ce9c9299ad1f8c2c5971204066dd02e528199.tar.bz2 |
Propagate tied operands when copying a MachineInstr.
MachineInstr's copy constructor works by calling the addOperand method
to add each operand of the old MachineInstr to the new one, one by
one. But addOperand deliberately avoids trying to replicate ties
between operands, on the grounds that the tie refers to operands by
index, and the indices aren't necessarily finalized yet.
This led to a code generation fault when the machine pipeliner cloned
an Arm conditional instruction, and lost the tie between the output
register and the input value to be used when the condition failed to
execute.
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D135434
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 18d11e6b..19a1ede 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -129,6 +129,14 @@ MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI) for (const MachineOperand &MO : MI.operands()) addOperand(MF, MO); + // Replicate ties between the operands, which addOperand was not + // able to do reliably. + for (unsigned i = 0, e = getNumOperands(); i < e; ++i) { + MachineOperand &NewMO = getOperand(i); + const MachineOperand &OrigMO = MI.getOperand(i); + NewMO.TiedTo = OrigMO.TiedTo; + } + // Copy all the sensible flags. setFlags(MI.Flags); } |