================
@@ -2256,12 +2256,61 @@ bool SIFrameLowering::spillCalleeSavedRegisters(
     ArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const {
   MachineFunction *MF = MBB.getParent();
   const GCNSubtarget &ST = MF->getSubtarget<GCNSubtarget>();
-  if (!ST.useVGPRBlockOpsForCSR())
-    return false;
+  const SIInstrInfo *TII = ST.getInstrInfo();
+  const SIRegisterInfo *SITRI = static_cast<const SIRegisterInfo *>(TRI);
+  const MachineRegisterInfo &MRI = MF->getRegInfo();
+
+  if (!ST.useVGPRBlockOpsForCSR()) {
+    SparseBitVector<> LiveInRoots;
+    if (MRI.tracksLiveness()) {
+      for (const auto &LI : MBB.liveins()) {
+        for (MCRegUnitMaskIterator MI(LI.PhysReg, TRI); MI.isValid(); ++MI) {
+          auto [Unit, UnitLaneMask] = *MI;
+          if ((LI.LaneMask & UnitLaneMask).none())
+            continue;
+          for (MCRegUnitRootIterator RI(Unit, TRI); RI.isValid(); ++RI)
+            LiveInRoots.set(*RI);
+        }
+      }
+    }
+
+    auto UpdateLiveInCheckCanKill = [&](MCRegister Reg) {
+      if (!MRI.tracksLiveness())
+        return false;
+      for (MCRegUnitIterator UI(Reg, TRI); UI.isValid(); ++UI) {
+        for (MCRegUnitRootIterator RI(*UI, TRI); RI.isValid(); ++RI) {
+          if (LiveInRoots.test(*RI))
+            return false;
+        }
+      }
+      // Reg is live in to the spill
+      MBB.addLiveIn(Reg);
+      return true;
+    };
+
+    for (const CalleeSavedInfo &CS : CSI) {
+      // Insert the spill to the stack frame.
+      unsigned Reg = CS.getReg();
----------------
arsenm wrote:

Use MCRegister 

https://github.com/llvm/llvm-project/pull/164724
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to