[llvm-branch-commits] [llvm] [mcp-frameinst: 3/3]: [MCP] Never eliminate frame-setup/destroy instructions (PR #186237)

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


slinder1 wrote:

Changes since last push:
```diff
diff --git b/llvm/lib/CodeGen/MachineCopyPropagation.cpp a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -604,7 +604,7 @@ static bool isNopCopy(const MachineInstr &PreviousCopy, MCRegister Src,
 /// copying the super registers.
 bool MachineCopyPropagation::eraseIfRedundant(MachineInstr &Copy,
                                               MCRegister Dst, MCRegister Src) {
-  if (isNeverRedundant(Src) || isNeverRedundant(Dst))
+  if (isNeverRedundant(Copy) || isNeverRedundant(Src) || isNeverRedundant(Dst))
     return false;
 
   // Search for an existing copy.
@@ -665,7 +665,7 @@ bool MachineCopyPropagation::isBackwardPropagatableCopy(
   if (!Dst || !Src)
     return false;
 
-  if (isNeverRedundant(Src))
+  if (isNeverRedundant(Copy) || isNeverRedundant(Dst) || isNeverRedundant(Src))
     return false;
 
   return CopyOperands.Source->isRenamable() && CopyOperands.Source->isKill();
@@ -952,7 +952,7 @@ void MachineCopyPropagation::forwardCopyPropagateBlock(MachineBasicBlock &MBB) {
       if (!TRI->regsOverlap(Dst, Src)) {
         // FIXME: Document why this does not consider `RegSrc`, similar to how
         // `backwardCopyPropagateBlock` does.
-        if (!isNeverRedundant(Dst))
+        if (!isNeverRedundant(MI) && !isNeverRedundant(Dst))
           MaybeDeadCopies.insert(&MI);
       }
     }
@@ -997,7 +997,7 @@ void MachineCopyPropagation::forwardCopyPropagateBlock(MachineBasicBlock &MBB) {
         std::optional<DestSourcePair> CopyOperands =
             isCopyInstr(*MaybeDead, *TII, UseCopyInstr);
         MCRegister Reg = CopyOperands->Destination->getReg().asMCReg();
-        assert(!isNeverRedundant(Reg));
+        assert(!isNeverRedundant(*MaybeDead) && !isNeverRedundant(Reg));
 
         if (!RegMask->clobbersPhysReg(Reg)) {
           ++DI;
@@ -1065,7 +1065,7 @@ void MachineCopyPropagation::forwardCopyPropagateBlock(MachineBasicBlock &MBB) {
           *isCopyInstr(*MaybeDead, *TII, UseCopyInstr);
 
       auto [Dst, Src] = getDstSrcMCRegs(CopyOperands);
-      assert(!isNeverRedundant(Dst));
+      assert(!isNeverRedundant(*MaybeDead) && !isNeverRedundant(Dst));
 
       // Update matching debug values, if any.
       const auto &DbgUsers = CopyDbgUsers[MaybeDead];

```

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


More information about the llvm-branch-commits mailing list