[llvm] r332298 - [ARM] Back up R4 and LR if calling the stack probe function
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Mon May 14 14:32:52 PDT 2018
Author: mstorsjo
Date: Mon May 14 14:32:52 2018
New Revision: 332298
URL: http://llvm.org/viewvc/llvm-project?rev=332298&view=rev
Log:
[ARM] Back up R4 and LR if calling the stack probe function
Differential Revision: https://reviews.llvm.org/D46777
Modified:
llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp
llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll
Modified: llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp?rev=332298&r1=332297&r2=332298&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFrameLowering.cpp Mon May 14 14:32:52 2018
@@ -1620,6 +1620,17 @@ void ARMFrameLowering::determineCalleeSa
(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)
Modified: llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll?rev=332298&r1=332297&r2=332298&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/Windows/chkstk-movw-movt-isel.ll Mon May 14 14:32:52 2018
@@ -18,7 +18,7 @@ entry:
}
; 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*}}
More information about the llvm-commits
mailing list