[llvm] [CodeGen] Remove dead hack for MIPS (PR #148039)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 07:50:53 PDT 2025


https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/148039

>From 5615068f0aedc9316503bee9bdb8daf79db3b965 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Thu, 10 Jul 2025 15:14:30 -0400
Subject: [PATCH 1/3] [CodeGen] Remove dead hack for MIPS

All tests pass without it now.
---
 llvm/lib/CodeGen/LiveVariables.cpp | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index 1f23418642bc6..e857ff665913a 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -534,10 +534,6 @@ void LiveVariables::runOnInstr(MachineInstr &MI,
         UseRegs.push_back(MOReg);
     } else {
       assert(MO.isDef());
-      // FIXME: We should not remove any dead flags. However the MIPS RDDSP
-      // instruction needs it at the moment: http://llvm.org/PR27116.
-      if (MOReg.isPhysical() && !MRI->isReserved(MOReg))
-        MO.setIsDead(false);
       DefRegs.push_back(MOReg);
     }
   }

>From 36a696d479deb54598ad5fa2303ff3aed28fd011 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Thu, 10 Jul 2025 15:30:30 -0400
Subject: [PATCH 2/3] Match logic for setIsKill above

---
 llvm/lib/CodeGen/LiveVariables.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index e857ff665913a..8bddde704e6b3 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -534,6 +534,8 @@ void LiveVariables::runOnInstr(MachineInstr &MI,
         UseRegs.push_back(MOReg);
     } else {
       assert(MO.isDef());
+      if (!(MOReg.isPhysical() && MRI->isReserved(MOReg)))
+        MO.setIsDead(false);
       DefRegs.push_back(MOReg);
     }
   }

>From 27e8d5b1ee13eb74f3d7347c2a30fdad1c893c85 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Wed, 16 Jul 2025 10:50:44 -0400
Subject: [PATCH 3/3] No more removing dead flags

---
 llvm/lib/CodeGen/LiveVariables.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index 8bddde704e6b3..e857ff665913a 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -534,8 +534,6 @@ void LiveVariables::runOnInstr(MachineInstr &MI,
         UseRegs.push_back(MOReg);
     } else {
       assert(MO.isDef());
-      if (!(MOReg.isPhysical() && MRI->isReserved(MOReg)))
-        MO.setIsDead(false);
       DefRegs.push_back(MOReg);
     }
   }



More information about the llvm-commits mailing list