llvm.org GIT mirror llvm / f245ae5
Replace the "NoFramePointerElimNonLeaf" target option with a function attribute. There's no need to specify a flag to omit frame pointer elimination on non-leaf nodes...(Honestly, I can't parse that option out.) Use the function attribute stuff instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187093 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 6 years ago
11 changed file(s) with 56 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
109109 cl::init(false));
110110
111111 cl::opt
112 DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
113 cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
114 cl::init(false));
115
116 cl::opt
117112 EnableUnsafeFPMath("enable-unsafe-fp-math",
118113 cl::desc("Enable optimizations that may decrease FP precision"),
119114 cl::init(false));
4141 public:
4242 TargetOptions()
4343 : PrintMachineCode(false), NoFramePointerElim(false),
44 NoFramePointerElimNonLeaf(false), LessPreciseFPMADOption(false),
44 LessPreciseFPMADOption(false),
4545 UnsafeFPMath(false), NoInfsFPMath(false),
4646 NoNaNsFPMath(false), HonorSignDependentRoundingFPMathOption(false),
4747 UseSoftFloat(false), NoZerosInBSS(false),
6262 /// specified on the command line. If the target supports the frame pointer
6363 /// elimination optimization, this option should disable it.
6464 unsigned NoFramePointerElim : 1;
65
66 /// NoFramePointerElimNonLeaf - This flag is enabled when the
67 /// -disable-non-leaf-fp-elim is specified on the command line. If the
68 /// target supports the frame pointer elimination optimization, this option
69 /// should disable it for non-leaf functions.
70 unsigned NoFramePointerElimNonLeaf : 1;
7165
7266 /// DisableFramePointerElim - This returns true if frame pointer elimination
7367 /// optimization should be disabled for the given machine function.
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/IR/Function.h"
1314 #include "llvm/CodeGen/MachineFunction.h"
1415 #include "llvm/CodeGen/MachineFrameInfo.h"
1516 #include "llvm/Target/TargetOptions.h"
2021 bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
2122 // Check to see if we should eliminate non-leaf frame pointers and then
2223 // check to see if we should eliminate all frame pointers.
24 bool NoFramePointerElimNonLeaf =
25 MF.getFunction()->getFnAttribute("no-frame-pointer-elim-non-leaf")
26 .getValueAsString() == "true";
2327 if (NoFramePointerElimNonLeaf && !NoFramePointerElim) {
2428 const MachineFrameInfo *MFI = MF.getFrameInfo();
2529 return MFI->hasCalls();
103103 }
104104
105105 Attribute::AttrKind Attribute::getKindAsEnum() const {
106 if (!pImpl) return None;
106107 assert((isEnumAttribute() || isAlignAttribute()) &&
107108 "Invalid attribute type to get the kind as an enum!");
108109 return pImpl ? pImpl->getKindAsEnum() : None;
109110 }
110111
111112 uint64_t Attribute::getValueAsInt() const {
113 if (!pImpl) return 0;
112114 assert(isAlignAttribute() &&
113115 "Expected the attribute to be an alignment attribute!");
114116 return pImpl ? pImpl->getValueAsInt() : 0;
115117 }
116118
117119 StringRef Attribute::getKindAsString() const {
120 if (!pImpl) return StringRef();
118121 assert(isStringAttribute() &&
119122 "Invalid attribute type to get the kind as a string!");
120123 return pImpl ? pImpl->getKindAsString() : StringRef();
121124 }
122125
123126 StringRef Attribute::getValueAsString() const {
127 if (!pImpl) return StringRef();
124128 assert(isStringAttribute() &&
125129 "Invalid attribute type to get the value as a string!");
126130 return pImpl ? pImpl->getValueAsString() : StringRef();
7777 } while (0)
7878
7979 RESET_OPTION(NoFramePointerElim, "no-frame-pointer-elim");
80 RESET_OPTION(NoFramePointerElimNonLeaf, "no-frame-pointer-elim-non-leaf");
8180 RESET_OPTION(LessPreciseFPMADOption, "less-precise-fpmad");
8281 RESET_OPTION(UnsafeFPMath, "unsafe-fp-math");
8382 RESET_OPTION(NoInfsFPMath, "no-infs-fp-math");
0 ; RUN: llc < %s -march=x86 -asm-verbose=false | FileCheck %s -check-prefix=FP-ELIM
11 ; RUN: llc < %s -march=x86 -asm-verbose=false -disable-fp-elim | FileCheck %s -check-prefix=NO-ELIM
2 ; RUN: llc < %s -march=x86 -asm-verbose=false -disable-non-leaf-fp-elim | FileCheck %s -check-prefix=NON-LEAF
32
43 ; Implement -momit-leaf-frame-pointer
54 ; rdar://7886181
65
7 define i32 @t1() nounwind readnone {
6 define i32 @t1() "no-frame-pointer-elim-non-leaf"="false" nounwind readnone {
87 entry:
9 ; FP-ELIM-LABEL: t1:
10 ; FP-ELIM-NEXT: movl
11 ; FP-ELIM-NEXT: ret
8 ; FP-ELIM-LABEL: t1:
9 ; FP-ELIM-NEXT: movl
10 ; FP-ELIM-NEXT: ret
1211
13 ; NO-ELIM-LABEL: t1:
14 ; NO-ELIM-NEXT: pushl %ebp
15 ; NO-ELIM: popl %ebp
16 ; NO-ELIM-NEXT: ret
17
18 ; NON-LEAF-LABEL: t1:
19 ; NON-LEAF-NEXT: movl
20 ; NON-LEAF-NEXT: ret
12 ; NO-ELIM-LABEL: t1:
13 ; NO-ELIM-NEXT: pushl %ebp
14 ; NO-ELIM: popl %ebp
15 ; NO-ELIM-NEXT: ret
2116 ret i32 10
2217 }
2318
24 define void @t2() nounwind {
19 define void @t2() "no-frame-pointer-elim-non-leaf"="false" nounwind {
2520 entry:
26 ; FP-ELIM-LABEL: t2:
27 ; FP-ELIM-NOT: pushl %ebp
28 ; FP-ELIM: ret
21 ; FP-ELIM-LABEL: t2:
22 ; FP-ELIM-NOT: pushl %ebp
23 ; FP-ELIM: ret
2924
30 ; NO-ELIM-LABEL: t2:
31 ; NO-ELIM-NEXT: pushl %ebp
32 ; NO-ELIM: popl %ebp
33 ; NO-ELIM-NEXT: ret
25 ; NO-ELIM-LABEL: t2:
26 ; NO-ELIM-NEXT: pushl %ebp
27 ; NO-ELIM: popl %ebp
28 ; NO-ELIM-NEXT: ret
29 tail call void @foo(i32 0) nounwind
30 ret void
31 }
3432
35 ; NON-LEAF-LABEL: t2:
36 ; NON-LEAF-NEXT: pushl %ebp
37 ; NON-LEAF: popl %ebp
38 ; NON-LEAF-NEXT: ret
33 define i32 @t3() "no-frame-pointer-elim-non-leaf"="true" nounwind readnone {
34 entry:
35 ; FP-ELIM-LABEL: t3:
36 ; FP-ELIM-NEXT: movl
37 ; FP-ELIM-NEXT: ret
38
39 ; NO-ELIM-LABEL: t3:
40 ; NO-ELIM-NEXT: pushl %ebp
41 ; NO-ELIM: popl %ebp
42 ; NO-ELIM-NEXT: ret
43 ret i32 10
44 }
45
46 define void @t4() "no-frame-pointer-elim-non-leaf"="true" nounwind {
47 entry:
48 ; FP-ELIM-LABEL: t4:
49 ; FP-ELIM-NEXT: pushl %ebp
50 ; FP-ELIM: popl %ebp
51 ; FP-ELIM-NEXT: ret
52
53 ; NO-ELIM-LABEL: t4:
54 ; NO-ELIM-NEXT: pushl %ebp
55 ; NO-ELIM: popl %ebp
56 ; NO-ELIM-NEXT: ret
3957 tail call void @foo(i32 0) nounwind
4058 ret void
4159 }
None ; RUN: llc < %s -disable-non-leaf-fp-elim -relocation-model=pic -mtriple=x86_64-apple-darwin | FileCheck %s
0 ; RUN: llc < %s -relocation-model=pic -mtriple=x86_64-apple-darwin | FileCheck %s
11 ;
22 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
33 target triple = "x86_64-apple-darwin11.0"
55 @msg = internal global i8* null ; [#uses=1]
66 @.str = private constant [2 x i8] c"x\00", align 1 ; <[2 x i8]*> [#uses=1]
77
8 define void @test(i8* %p) nounwind optsize ssp {
8 define void @test(i8* %p) "no-frame-pointer-elim-non-leaf"="true" nounwind optsize ssp {
99
1010 ; No stack frame, please.
1111 ; CHECK: _test
None ; RUN: llc -o /dev/null -disable-non-leaf-fp-elim < %s
0 ; RUN: llc -o /dev/null < %s
11 ; Radar 7937664
22 %struct.AppleEvent = type opaque
33
4 define void @DisposeDMNotificationUPP(void (%struct.AppleEvent*)* %userUPP) nounwind ssp {
4 define void @DisposeDMNotificationUPP(void (%struct.AppleEvent*)* %userUPP) "no-frame-pointer-elim-non-leaf"="true" nounwind ssp {
55 entry:
66 %userUPP_addr = alloca void (%struct.AppleEvent*)* ; [#uses=1]
77 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
261261 TargetOptions Options;
262262 Options.LessPreciseFPMADOption = EnableFPMAD;
263263 Options.NoFramePointerElim = DisableFPElim;
264 Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
265264 Options.AllowFPOpFusion = FuseFPOps;
266265 Options.UnsafeFPMath = EnableUnsafeFPMath;
267266 Options.NoInfsFPMath = EnableNoInfsFPMath;
4949 cl::init(false));
5050
5151 static cl::opt
52 DisableFPElimNonLeaf("disable-non-leaf-fp-elim",
53 cl::desc("Disable frame pointer elimination optimization for non-leaf funcs"),
54 cl::init(false));
55
56 static cl::opt
5752 EnableUnsafeFPMath("enable-unsafe-fp-math",
5853 cl::desc("Enable optimizations that may decrease FP precision"),
5954 cl::init(false));
235230 void LTOModule::getTargetOptions(TargetOptions &Options) {
236231 Options.LessPreciseFPMADOption = EnableFPMAD;
237232 Options.NoFramePointerElim = DisableFPElim;
238 Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
239233 Options.AllowFPOpFusion = FuseFPOps;
240234 Options.UnsafeFPMath = EnableUnsafeFPMath;
241235 Options.NoInfsFPMath = EnableNoInfsFPMath;
490490 TargetOptions Options;
491491 Options.LessPreciseFPMADOption = EnableFPMAD;
492492 Options.NoFramePointerElim = DisableFPElim;
493 Options.NoFramePointerElimNonLeaf = DisableFPElimNonLeaf;
494493 Options.AllowFPOpFusion = FuseFPOps;
495494 Options.UnsafeFPMath = EnableUnsafeFPMath;
496495 Options.NoInfsFPMath = EnableNoInfsFPMath;