[PATCH] D46777: [ARM] Back up R4 and LR if calling the stack probe function

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 14 14:36:50 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL332298: [ARM] Back up R4 and LR if calling the stack probe function (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46777?vs=146551&id=146691#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46777

Files:
  llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp
  llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll


Index: llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll
===================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll
+++ llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll
@@ -18,7 +18,7 @@
 }
 
 ; CHECK-LABEL: isel
-; CHECK: push {r4, r5}
+; CHECK: push {r4, r5, r6, lr}
 ; CHECK: movw r12, #0
 ; CHECK: movt r12, #0
 ; CHECK: movw r4, #{{\d*}}
Index: llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp
+++ llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp
@@ -1620,6 +1620,17 @@
       (MFI.hasVarSizedObjects() || RegInfo->needsStackRealignment(MF)))
     SavedRegs.set(ARM::R4);
 
+  // If a stack probe will be emitted, spill R4 and LR, since they are
+  // clobbered by the stack probe call.
+  // This estimate should be a safe, conservative estimate. The actual
+  // stack probe is enabled based on the size of the local objects;
+  // this estimate also includes the varargs store size.
+  if (STI.isTargetWindows() &&
+      WindowsRequiresStackProbe(MF, MFI.estimateStackSize(MF))) {
+    SavedRegs.set(ARM::R4);
+    SavedRegs.set(ARM::LR);
+  }
+
   if (AFI->isThumb1OnlyFunction()) {
     // Spill LR if Thumb1 function uses variable length argument lists.
     if (AFI->getArgRegsSaveSize() > 0)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46777.146691.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180514/e41b4a95/attachment.bin>


More information about the llvm-commits mailing list