[llvm-bugs] [Bug 42999] New: ShrinkWrap pass uses wrong csr

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 14 17:39:48 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42999

            Bug ID: 42999
           Summary: ShrinkWrap pass uses wrong csr
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: manjian2006 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Index: lib/CodeGen/ShrinkWrap.cpp
===================================================================
--- lib/CodeGen/ShrinkWrap.cpp  (revision 359070)
+++ lib/CodeGen/ShrinkWrap.cpp  (working copy)
@@ -280,8 +280,8 @@
       // separately. An SP mentioned by a call instruction, we can ignore,
       // though, as it's harmless and we do not want to effectively disable
tail
       // calls by forcing the restore point to post-dominate them.
-      UseOrDefCSR = (!MI.isCall() && PhysReg == SP) ||
-                    RCI.getLastCalleeSavedAlias(PhysReg);
+      UseOrDefCSR =
+          (!MI.isCall() && PhysReg == SP) ||
getCurrentCSRs(RS).count(PhysReg);
     } else if (MO.isRegMask()) {
       // Check if this regmask clobbers any of the CSRs.
       for (unsigned Reg : getCurrentCSRs(RS)) {

RCI.getLastCalleeSavedAlias(PhysReg) may work on many cases, but one target may
specify other CSRs in its frame lowering implementation. For example,
ARMFrameLowering.cpp has the following code:
  if (STI.isTargetWindows() &&
      WindowsRequiresStackProbe(MF, MFI.estimateStackSize(MF))) {
    SavedRegs.set(ARM::R4);
    SavedRegs.set(ARM::LR);
  }

It add R4 to CSR set. So I suggest ShrinkWrap should use the patch above, which
uses getCurrentCSRs to determine CSRs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190815/30bf9926/attachment.html>


More information about the llvm-bugs mailing list