Propagate tied operands when copying a MachineInstr.
authorSimon Tatham <simon.tatham@arm.com>
Thu, 13 Oct 2022 08:18:31 +0000 (09:18 +0100)
committerSimon Tatham <simon.tatham@arm.com>
Thu, 13 Oct 2022 08:40:35 +0000 (09:40 +0100)
commit526ce9c9299ad1f8c2c5971204066dd02e528199
tree9af6f9257e37b8b344c8890bac832ebd1c589674
parent89c923655aad6de837e386aa6e1dfa72c16e2697
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
llvm/lib/CodeGen/MachineInstr.cpp
llvm/lib/CodeGen/ModuloSchedule.cpp
llvm/test/CodeGen/Thumb2/pipeliner-inlineasm.mir
llvm/test/CodeGen/Thumb2/pipeliner-preserve-ties.mir