Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 634b8b0

Browse files
committed
ARM: tweak WoA frame lowering
Accept r11 when targeting Windows on ARM rather than just low registers. Because we are in a thumb-2 only mode, this may be slightly more expensive in code size, but results in better code for the environment since it spills the frame register, which is generally desired for fast stack walking as per the ABI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249804 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7875288 commit 634b8b0

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,13 +1605,11 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
16051605
// FIXME: We could add logic to be more precise about negative offsets
16061606
// and which instructions will need a scratch register for them. Is it
16071607
// worth the effort and added fragility?
1608-
bool BigStack =
1609-
(RS &&
1610-
(MFI->estimateStackSize(MF) +
1611-
((hasFP(MF) && AFI->hasStackFrame()) ? 4:0) >=
1612-
estimateRSStackSizeLimit(MF, this)))
1613-
|| MFI->hasVarSizedObjects()
1614-
|| (MFI->adjustsStack() && !canSimplifyCallFramePseudos(MF));
1608+
bool BigStack = (RS && (MFI->estimateStackSize(MF) +
1609+
((hasFP(MF) && AFI->hasStackFrame()) ? 4 : 0) >=
1610+
estimateRSStackSizeLimit(MF, this))) ||
1611+
MFI->hasVarSizedObjects() ||
1612+
(MFI->adjustsStack() && !canSimplifyCallFramePseudos(MF));
16151613

16161614
bool ExtraCSSpill = false;
16171615
if (BigStack || !CanEliminateFrame || RegInfo->cannotEliminateFrame(MF)) {
@@ -1649,8 +1647,10 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
16491647
if (CS1Spilled && !UnspilledCS1GPRs.empty()) {
16501648
for (unsigned i = 0, e = UnspilledCS1GPRs.size(); i != e; ++i) {
16511649
unsigned Reg = UnspilledCS1GPRs[i];
1652-
// Don't spill high register if the function is thumb
1650+
// Don't spill high register if the function is thumb. In the case of
1651+
// Windows on ARM, accept R11 (frame pointer)
16531652
if (!AFI->isThumbFunction() ||
1653+
(STI.isTargetWindows() && Reg == ARM::R11) ||
16541654
isARMLowRegister(Reg) || Reg == ARM::LR) {
16551655
SavedRegs.set(Reg);
16561656
if (!MRI.isReserved(Reg))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -mtriple thumbv7-windows -filetype asm -o - %s | FileCheck %s
2+
3+
declare void @callee(i32)
4+
5+
define i32 @calleer(i32 %i) {
6+
entry:
7+
%i.addr = alloca i32, align 4
8+
%j = alloca i32, align 4
9+
store i32 %i, i32* %i.addr, align 4
10+
%0 = load i32, i32* %i.addr, align 4
11+
%add = add nsw i32 %0, 1
12+
store i32 %add, i32* %j, align 4
13+
%1 = load i32, i32* %j, align 4
14+
call void @callee(i32 %1)
15+
%2 = load i32, i32* %j, align 4
16+
%add1 = add nsw i32 %2, 1
17+
ret i32 %add1
18+
}
19+
20+
; CHECK-NOT: push.w {r7, lr}
21+
; CHECK: push.w {r11, lr}
22+

0 commit comments

Comments
 (0)