[llvm] [MCP] Remove dead copies from basic blocks with successors. (PR #86973)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 09:56:23 PDT 2024


================
@@ -914,10 +914,19 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) {
       Tracker.clobberRegister(Reg, *TRI, *TII, UseCopyInstr);
   }
 
-  // If MBB doesn't have successors, delete the copies whose defs are not used.
-  // If MBB does have successors, then conservative assume the defs are live-out
-  // since we don't want to trust live-in lists.
-  if (MBB.succ_empty()) {
+  bool TracksLiveness = MRI->tracksLiveness();
+
+  // If a copy result is livein to a successor, it is not dead.
+  if (TracksLiveness && !MaybeDeadCopies.empty())
----------------
arsenm wrote:

Braces? Also move most of this to a helper function?

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


More information about the llvm-commits mailing list