[llvm] RegisterCoalescer: Fix producing malformed IMPLICIT_DEFs (PR #73784)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 2 06:46:41 PST 2023


================
@@ -1694,12 +1694,19 @@ MachineInstr *RegisterCoalescer::eliminateUndefCopy(MachineInstr *CopyMI) {
   // The source interval may also have been on an undef use, in which case the
   // copy introduced a live value.
   if (((V && V->isPHIDef()) || (!V && !DstLI.liveAt(Idx)))) {
-    CopyMI->setDesc(TII->get(TargetOpcode::IMPLICIT_DEF));
     for (unsigned i = CopyMI->getNumOperands(); i != 0; --i) {
       MachineOperand &MO = CopyMI->getOperand(i-1);
-      if (MO.isReg() && MO.isUse())
+      if (MO.isReg()) {
+        if (MO.isUse())
+          CopyMI->removeOperand(i - 1);
+      } else {
+        assert(MO.isImm() &&
+               (CopyMI->getOpcode() == TargetOpcode::SUBREG_TO_REG));
----------------
arsenm wrote:

Everything else suggests this function only handles copies, except for the exception it handles "copy-like" which only includes SUBREG_TO_REG, with the 2 immediate operands 

https://github.com/llvm/llvm-project/pull/73784


More information about the llvm-commits mailing list