[PATCH] D51474: Consider CSRs in computeRegisterLiveness

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 31 01:23:01 PDT 2018


arsenm updated this revision to Diff 163475.
arsenm added a comment.

Only check if MFI.isCalleeSavedInfoValid


https://reviews.llvm.org/D51474

Files:
  lib/CodeGen/MachineBasicBlock.cpp


Index: lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- lib/CodeGen/MachineBasicBlock.cpp
+++ lib/CodeGen/MachineBasicBlock.cpp
@@ -16,6 +16,7 @@
 #include "llvm/CodeGen/LiveIntervals.h"
 #include "llvm/CodeGen/LiveVariables.h"
 #include "llvm/CodeGen/MachineDominators.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
@@ -1400,6 +1401,21 @@
   // If we reached the end, it is safe to clobber Reg at the end of a block of
   // no successor has it live in.
   if (I == end()) {
+    const MachineFunction &MF = *getParent();
+    const MachineFrameInfo &MFI = MF.getFrameInfo();
+    if (isReturnBlock() && MFI.isCalleeSavedInfoValid()) {
+      const MachineRegisterInfo &MRI = MF.getRegInfo();
+      for (const MCPhysReg *CSR = MRI.getCalleeSavedRegs(); CSR && *CSR; ++CSR) {
+        if (*CSR == Reg)
+          return LQR_Live;
+      }
+
+      for (const CalleeSavedInfo &Info : MFI.getCalleeSavedInfo()) {
+        if (Info.isRestored() && Info.getReg() == Reg)
+          return LQR_Live;
+      }
+    }
+
     for (MachineBasicBlock *S : successors()) {
       for (MCSubRegIterator SubReg(Reg, TRI, /*IncludeSelf*/true);
            SubReg.isValid(); ++SubReg) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51474.163475.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180831/26960bab/attachment.bin>


More information about the llvm-commits mailing list