[llvm] [mcp-frameinst: 1/3]: [MCP][NFC] Cleanup and prepare to preserve frame-setup/destroy (PR #186240)

Scott Linder via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 14:05:20 PDT 2026


slinder1 wrote:

Changes since last push:
```diff
diff --git b/llvm/lib/CodeGen/MachineCopyPropagation.cpp a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -223,7 +223,8 @@ public:
           if (SrcCopy != Copies.end() && SrcCopy->second.LastSeenUseInCopy) {
             // If SrcCopy defines multiple values, we only need
             // to erase the record for Def in DefRegs.
-            for (auto *Itr = SrcCopy->second.DefRegs.begin();
+            // NOLINTNEXTLINE(llvm-qualified-auto)
+            for (auto Itr = SrcCopy->second.DefRegs.begin();
                  Itr != SrcCopy->second.DefRegs.end(); Itr++) {
               if (*Itr == Def) {
                 SrcCopy->second.DefRegs.erase(Itr);
@@ -487,12 +488,6 @@ private:
     // zero).
     return MRI->isReserved(CopyOperand);
   }
-  /// Returns true iff the @p Copy instruction must never be eliminated as
-  /// redundant. This overload does not consider the operands of @p Copy.
-  bool isNeverRedundant(const MachineInstr &Copy) {
-    // FIXME: A future change will implement this.
-    return false;
-  }
   bool hasImplicitOverlap(const MachineInstr &MI, const MachineOperand &Use);
   bool hasOverlappingMultipleDef(const MachineInstr &MI,
                                  const MachineOperand &MODef, MCRegister Def);
@@ -603,7 +598,7 @@ static bool isNopCopy(const MachineInstr &PreviousCopy, MCRegister Src,
 /// copying the super registers.
 bool MachineCopyPropagation::eraseIfRedundant(MachineInstr &Copy,
                                               MCRegister Src, MCRegister Def) {
-  if (isNeverRedundant(Copy) || isNeverRedundant(Src) || isNeverRedundant(Def))
+  if (isNeverRedundant(Src) || isNeverRedundant(Def))
     return false;
 
   // Search for an existing copy.
@@ -668,7 +663,7 @@ bool MachineCopyPropagation::isBackwardPropagatableCopy(
   if (!Def || !Src)
     return false;
 
-  if (isNeverRedundant(Copy) || isNeverRedundant(Def) || isNeverRedundant(Src))
+  if (isNeverRedundant(Def) || isNeverRedundant(Src))
     return false;
 
   return CopyOperands.Source->isRenamable() && CopyOperands.Source->isKill();
@@ -968,7 +963,7 @@ void MachineCopyPropagation::forwardCopyPropagateBlock(MachineBasicBlock &MBB) {
         MCRegister Def = RegDef.asMCReg();
         // FIXME: Document why this does not consider `RegSrc`, similar to how
         // `backwardCopyPropagateBlock` does.
-        if (!isNeverRedundant(MI) && !isNeverRedundant(Def))
+        if (!isNeverRedundant(Def))
           MaybeDeadCopies.insert(&MI);
       }
     }

```

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


More information about the llvm-commits mailing list