Skip to content

Commit b9ea528

Browse files
committed
fix issues 108019
1 parent f5a65d8 commit b9ea528

22 files changed

+66
-37
lines changed

Diff for: llvm/include/llvm/Target/TargetOptions.h

+5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ namespace llvm {
161161
/// DisableFramePointerElim - This returns true if frame pointer elimination
162162
/// optimization should be disabled for the given machine function.
163163
bool DisableFramePointerElim(const MachineFunction &MF) const;
164+
165+
/// DisableLeafFramePointerElim - This returns true if leaf frame pointer
166+
/// elimination optimization should be disabled for the given machine
167+
/// function.
168+
bool DisableLeafFramePointerElim(const MachineFunction &MF) const;
164169

165170
/// FramePointerIsReserved - This returns true if the frame pointer must
166171
/// always either point to a new frame record or be un-modified in the given

Diff for: llvm/lib/CodeGen/TargetOptionsImpl.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
4040
llvm_unreachable("unknown frame pointer flag");
4141
}
4242

43+
/// DisableLeafFramePointerElim - This returns true if leaf frame pointer
44+
/// elimination optimization should be disabled for the given machine function.
45+
bool TargetOptions::DisableLeafFramePointerElim(
46+
const MachineFunction &MF) const {
47+
const Function &F = MF.getFunction();
48+
49+
if (!F.hasFnAttribute("frame-pointer"))
50+
return false;
51+
StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString();
52+
if (FP == "all")
53+
return true;
54+
return false;
55+
}
56+
4357
bool TargetOptions::FramePointerIsReserved(const MachineFunction &MF) const {
4458
// Check to see if the target want to forcibly keep frame pointer.
4559
if (MF.getSubtarget().getFrameLowering()->keepFramePointer(MF))

Diff for: llvm/lib/Target/ARM/ARMFrameLowering.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,8 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
22712271
// is spilled in the order specified by getCalleeSavedRegs() to make it easier
22722272
// to combine multiple loads / stores.
22732273
bool CanEliminateFrame = !(requiresAAPCSFrameRecord(MF) && hasFP(MF));
2274+
bool CanEliminateLeafFrame =
2275+
!MF.getTarget().Options.DisableLeafFramePointerElim(MF);
22742276
bool CS1Spilled = false;
22752277
bool LRSpilled = false;
22762278
unsigned NumGPRSpills = 0;
@@ -2512,8 +2514,8 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
25122514
<< "; EstimatedStack: " << EstimatedStackSize
25132515
<< "; EstimatedFPStack: " << MaxFixedOffset - MaxFPOffset
25142516
<< "; BigFrameOffsets: " << BigFrameOffsets << "\n");
2515-
if (BigFrameOffsets ||
2516-
!CanEliminateFrame || RegInfo->cannotEliminateFrame(MF)) {
2517+
if (BigFrameOffsets || !CanEliminateFrame ||
2518+
RegInfo->cannotEliminateFrame(MF) || !CanEliminateLeafFrame) {
25172519
AFI->setHasStackFrame(true);
25182520

25192521
if (HasFP) {

Diff for: llvm/test/CodeGen/ARM/2011-03-15-LdStMultipleBug.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@oStruct = external global %struct.Outer, align 4
1111

12-
define void @main(i8 %val8) nounwind {
12+
define void @main(i8 %val8) nounwind "frame-pointer"="none" {
1313
; CHECK-LABEL: main:
1414
; CHECK: @ %bb.0: @ %for.body.lr.ph
1515
; CHECK-NEXT: movw r0, :lower16:(L_oStruct$non_lazy_ptr-(LPC0_0+4))

Diff for: llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ if.end:
17321732
; Another infinite loop test this time with two nested infinite loop.
17331733
; infiniteloop3
17341734
; bx lr
1735-
define void @infiniteloop3() "frame-pointer"="all" {
1735+
define void @infiniteloop3() "frame-pointer"="none" {
17361736
; ARM-LABEL: infiniteloop3:
17371737
; ARM: @ %bb.0: @ %entry
17381738
; ARM-NEXT: mov r0, #0

Diff for: llvm/test/CodeGen/ARM/call-tc.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ define void @t1() "frame-pointer"="all" {
1717
ret void
1818
}
1919

20-
define void @t2() "frame-pointer"="all" {
20+
define void @t2() "frame-pointer"="none" {
2121
; CHECKV6-LABEL: t2:
2222
; CHECKV6: bx r0
2323
; CHECKT2D-LABEL: t2:
@@ -102,7 +102,7 @@ bb:
102102

103103
; Make sure codegenprep is duplicating ret instructions to enable tail calls.
104104
; rdar://11140249
105-
define i32 @t8(i32 %x) nounwind ssp "frame-pointer"="all" {
105+
define i32 @t8(i32 %x) nounwind ssp "frame-pointer"="none" {
106106
entry:
107107
; CHECKT2D-LABEL: t8:
108108
; CHECKT2D-NOT: push

Diff for: llvm/test/CodeGen/ARM/debug-frame.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ entry:
526526
; Test 4
527527
;-------------------------------------------------------------------------------
528528

529-
define void @test4() nounwind {
529+
define void @test4() nounwind "frame-pointer"="none" {
530530
entry:
531531
ret void
532532
}

Diff for: llvm/test/CodeGen/ARM/ehabi.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ entry:
575575
; Test 4
576576
;-------------------------------------------------------------------------------
577577

578-
define void @test4() nounwind {
578+
define void @test4() nounwind "frame-pointer"="none" {
579579
entry:
580580
ret void
581581
}

Diff for: llvm/test/CodeGen/ARM/frame-chain.ll

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
define dso_local noundef i32 @leaf(i32 noundef %0) {
1111
; LEAF-FP-LABEL: leaf:
1212
; LEAF-FP: @ %bb.0:
13-
; LEAF-FP-NEXT: .pad #4
14-
; LEAF-FP-NEXT: sub sp, sp, #4
15-
; LEAF-FP-NEXT: str r0, [sp]
13+
; LEAF-FP-NEXT: .save {r11, lr}
14+
; LEAF-FP-NEXT: push {r11, lr}
15+
; LEAF-FP-NEXT: .setfp r11, sp
16+
; LEAF-FP-NEXT: mov r11, sp
17+
; LEAF-FP-NEXT: push {r0}
1618
; LEAF-FP-NEXT: add r0, r0, #4
17-
; LEAF-FP-NEXT: add sp, sp, #4
19+
; LEAF-FP-NEXT: mov sp, r11
20+
; LEAF-FP-NEXT: pop {r11, lr}
1821
; LEAF-FP-NEXT: mov pc, lr
1922
;
2023
; LEAF-FP-AAPCS-LABEL: leaf:

Diff for: llvm/test/CodeGen/ARM/ifcvt5.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@x = external global ptr ; <ptr> [#uses=1]
77

8-
define void @foo(i32 %a) "frame-pointer"="all" {
8+
define void @foo(i32 %a) "frame-pointer"="none" {
99
; A8-LABEL: foo:
1010
; A8: @ %bb.0: @ %entry
1111
; A8-NEXT: movw r1, :lower16:(L_x$non_lazy_ptr-(LPC0_0+8))

Diff for: llvm/test/CodeGen/ARM/ldrd.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ define void @ldrd_postupdate_inc(ptr %p0) "frame-pointer"="all" {
168168
; NORMAL: strd r1, r2, [r0], #-8
169169
; CONSERVATIVE-NOT: strd
170170
; CHECK: bx lr
171-
define ptr @strd_postupdate_dec(ptr %p0, i32 %v0, i32 %v1) "frame-pointer"="all" {
171+
define ptr @strd_postupdate_dec(ptr %p0, i32 %v0, i32 %v1) "frame-pointer"="none" {
172172
%p0.1 = getelementptr i32, ptr %p0, i32 1
173173
store i32 %v0, ptr %p0
174174
store i32 %v1, ptr %p0.1
@@ -180,7 +180,7 @@ define ptr @strd_postupdate_dec(ptr %p0, i32 %v0, i32 %v1) "frame-pointer"="all"
180180
; NORMAL: strd r1, r2, [r0], #8
181181
; CONSERVATIVE-NOT: strd
182182
; CHECK: bx lr
183-
define ptr @strd_postupdate_inc(ptr %p0, i32 %v0, i32 %v1) "frame-pointer"="all" {
183+
define ptr @strd_postupdate_inc(ptr %p0, i32 %v0, i32 %v1) "frame-pointer"="none" {
184184
%p0.1 = getelementptr i32, ptr %p0, i32 1
185185
store i32 %v0, ptr %p0
186186
store i32 %v1, ptr %p0.1

Diff for: llvm/test/CodeGen/ARM/stack-frame-layout-remarks.ll

+5-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
5151
; BOTH: [SP-8]{{.+}}8{{.+}}4
5252
; DEBUG: a @ dot.c:13
5353
; STRIPPED-NOT: a @ dot.c:13
54-
define void @cleanup_array(ptr %0) #1 {
54+
define void @cleanup_array(ptr %0) #3 {
5555
%2 = alloca ptr, align 8
5656
store ptr %0, ptr %2, align 8
5757
call void @llvm.dbg.declare(metadata ptr %2, metadata !41, metadata !DIExpression()), !dbg !46
@@ -62,7 +62,7 @@ define void @cleanup_array(ptr %0) #1 {
6262
; BOTH: [SP-8]{{.+}}8{{.+}}4
6363
; DEBUG: res @ dot.c:21
6464
; STRIPPED-NOT: res @ dot.c:21
65-
define void @cleanup_result(ptr %0) #1 {
65+
define void @cleanup_result(ptr %0) #3 {
6666
%2 = alloca ptr, align 8
6767
store ptr %0, ptr %2, align 8
6868
call void @llvm.dbg.declare(metadata ptr %2, metadata !47, metadata !DIExpression()), !dbg !51
@@ -92,7 +92,7 @@ define void @cleanup_result(ptr %0) #1 {
9292
; BOTH: [SP-40]{{.+}}4{{.+}}4
9393
; DEBUG: i @ dot.c:55
9494
; STRIPPED-NOT: i @ dot.c:55
95-
define i32 @do_work(ptr %0, ptr %1, ptr %2) #1 {
95+
define i32 @do_work(ptr %0, ptr %1, ptr %2) #3 {
9696
%4 = alloca i32, align 4
9797
%5 = alloca ptr, align 8
9898
%6 = alloca ptr, align 8
@@ -144,7 +144,7 @@ define i32 @do_work(ptr %0, ptr %1, ptr %2) #1 {
144144
; BOTH: [SP-20]{{.+}}4{{.*}}4
145145
; DEBUG: i @ dot.c:69
146146
; STRIPPED-NOT: i @ dot.c:69
147-
define ptr @gen_array(i32 %0) #1 {
147+
define ptr @gen_array(i32 %0) #3 {
148148
%2 = alloca ptr, align 8
149149
%3 = alloca i32, align 4
150150
%4 = alloca ptr, align 8
@@ -227,6 +227,7 @@ uselistorder ptr @llvm.dbg.declare, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
227227
attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
228228
attributes #1 = { "frame-pointer"="all" }
229229
attributes #2 = { ssp "stack-protector-buffer-size"="5" "frame-pointer"="all" }
230+
attributes #3 = { "frame-pointer"="none" }
230231

231232
!llvm.dbg.cu = !{!0, !2}
232233
!llvm.module.flags = !{!18, !19, !20, !21, !22, !23, !24}

Diff for: llvm/test/CodeGen/ARM/stack-size-section.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ define void @dynalloc(i32 %N) #0 {
2929
ret void
3030
}
3131

32-
attributes #0 = { "frame-pointer"="all" }
32+
attributes #0 = { "frame-pointer"="none" }

Diff for: llvm/test/CodeGen/ARM/v7k-abi-align.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ define void @test_dpr_unwind_align_no_dprs() "frame-pointer"="all" {
117117

118118
; 128-bit vectors should use 128-bit (i.e. correctly aligned) slots on
119119
; the stack.
120-
define <4 x float> @test_v128_stack_pass([8 x double], float, <4 x float> %in) "frame-pointer"="all" {
120+
define <4 x float> @test_v128_stack_pass([8 x double], float, <4 x float> %in) "frame-pointer"="none" {
121121
; CHECK-LABEL: test_v128_stack_pass:
122122
; CHECK: add r[[ADDR:[0-9]+]], sp, #16
123123
; CHECK: vld1.64 {d0, d1}, [r[[ADDR]]:128]
@@ -140,7 +140,7 @@ define void @test_v128_stack_pass_varargs(<4 x float> %in) "frame-pointer"="all"
140140

141141
; To be compatible with AAPCS's va_start model (store r0-r3 at incoming SP, give
142142
; a single pointer), 64-bit quantities must be pass
143-
define i64 @test_64bit_gpr_align(i32, i64 %r2_r3, i32 %sp) "frame-pointer"="all" {
143+
define i64 @test_64bit_gpr_align(i32, i64 %r2_r3, i32 %sp) "frame-pointer"="none" {
144144
; CHECK-LABEL: test_64bit_gpr_align:
145145
; CHECK: ldr [[RHS:r[0-9]+]], [sp]
146146
; CHECK: adds r0, [[RHS]], r2

Diff for: llvm/test/CodeGen/Thumb/frame-chain.ll

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
define dso_local noundef i32 @leaf(i32 noundef %0) {
99
; LEAF-FP-LABEL: leaf:
1010
; LEAF-FP: @ %bb.0:
11-
; LEAF-FP-NEXT: .pad #4
12-
; LEAF-FP-NEXT: sub sp, #4
13-
; LEAF-FP-NEXT: str r0, [sp]
14-
; LEAF-FP-NEXT: adds r0, r0, #4
15-
; LEAF-FP-NEXT: add sp, #4
16-
; LEAF-FP-NEXT: bx lr
11+
; LEAF-FP-NEXT: .save {r7, lr}
12+
; LEAF-FP-NEXT: push {r7, lr}
13+
; LEAF-FP-NEXT: .setfp r7, sp
14+
; LEAF-FP-NEXT: add r7, sp, #0
15+
; LEAF-FP-NEXT: .pad #4
16+
; LEAF-FP-NEXT: sub sp, #4
17+
; LEAF-FP-NEXT: str r0, [sp]
18+
; LEAF-FP-NEXT: adds r0, r0, #4
19+
; LEAF-FP-NEXT: add sp, #4
20+
; LEAF-FP-NEXT: pop {r7, pc}
1721
;
1822
; LEAF-FP-AAPCS-LABEL: leaf:
1923
; LEAF-FP-AAPCS: @ %bb.0:

Diff for: llvm/test/CodeGen/Thumb2/frame-pointer.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define void @leaf() {
1414

1515
; Leaf function, frame pointer is requested but we don't need any stack frame,
1616
; so don't create a frame pointer.
17-
define void @leaf_nofpelim() "frame-pointer"="all" {
17+
define void @leaf_nofpelim() "frame-pointer"="none" {
1818
; CHECK-LABEL: leaf_nofpelim:
1919
; CHECK-NOT: push
2020
; CHECK-NOT: sp

Diff for: llvm/test/CodeGen/Thumb2/frameless.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -frame-pointer=all | not grep mov
2-
; RUN: llc < %s -mtriple=thumbv7-linux -frame-pointer=all | not grep mov
1+
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -frame-pointer=none | not grep mov
2+
; RUN: llc < %s -mtriple=thumbv7-linux -frame-pointer=none | not grep mov
33

44
define void @t() nounwind readnone {
55
ret void

Diff for: llvm/test/CodeGen/Thumb2/frameless2.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -frame-pointer=all | not grep r7
1+
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -frame-pointer=none | not grep r7
22

33
%struct.noise3 = type { [3 x [17 x i32]] }
44
%struct.noiseguard = type { i32, i32, i32 }

Diff for: llvm/test/CodeGen/Thumb2/machine-licm.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -frame-pointer=all | FileCheck %s
2-
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -frame-pointer=all | FileCheck %s --check-prefix=PIC
1+
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -frame-pointer=none | FileCheck %s
2+
; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -frame-pointer=none | FileCheck %s --check-prefix=PIC
33
; rdar://7353541
44
; rdar://7354376
55

Diff for: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/arm_generated_funcs.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ define dso_local i32 @main() #0 {
6060
ret i32 0
6161
}
6262

63-
attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
63+
attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="none" }

Diff for: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/arm_generated_funcs.ll.generated.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define dso_local i32 @main() #0 {
6161
ret i32 0
6262
}
6363

64-
attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
64+
attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="none" }
6565
; CHECK-LABEL: check_boundaries:
6666
; CHECK: @ %bb.0:
6767
; CHECK-NEXT: sub sp, sp, #20

Diff for: llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/arm_generated_funcs.ll.nogenerated.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ define dso_local i32 @main() #0 {
121121
ret i32 0
122122
}
123123

124-
attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
124+
attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="none" }

0 commit comments

Comments
 (0)