Skip to content

Commit 7a58b41

Browse files
authored
Add FramePointerKind::NonLeafNoReserve (#163775)
This patch adds a new `FramePointerKind::NonLeafNoReserve` and makes it the default for `-momit-leaf-frame-pointer`. It also adds a new commandline option `-m[no-]reserve-frame-pointer-reg`. This should fix #154379, the main impact of this patch can be found in `clang/lib/Driver/ToolChains/CommonArgs.cpp`.
1 parent 1a88d04 commit 7a58b41

File tree

20 files changed

+908
-60
lines changed

20 files changed

+908
-60
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CODEGENOPT(SeparateNamedSections, 1, 0, Benign) ///< Set for -fseparate-named-se
5454
CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0, Benign) ///< Set for -mabi=vec-extabi. Enables the extended Altivec ABI on AIX.
5555
CODEGENOPT(XCOFFReadOnlyPointers, 1, 0, Benign) ///< Set for -mxcoff-roptr.
5656
CODEGENOPT(AllTocData, 1, 0, Benign) ///< AIX -mtocdata
57-
ENUM_CODEGENOPT(FramePointer, FramePointerKind, 2, FramePointerKind::None, Benign) /// frame-pointer: all,non-leaf,reserved,none
57+
ENUM_CODEGENOPT(FramePointer, FramePointerKind, 3, FramePointerKind::None, Benign) /// frame-pointer: all,non-leaf,non-leaf-no-reserve,reserved,none
5858

5959
ENUM_CODEGENOPT(ExceptionHandling, ExceptionHandlingKind, 3, ExceptionHandlingKind::None, NotCompatible)
6060

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ class CodeGenOptions : public CodeGenOptionsBase {
155155
std::string BinutilsVersion;
156156

157157
enum class FramePointerKind {
158-
None, // Omit all frame pointers.
159-
Reserved, // Maintain valid frame pointer chain.
160-
NonLeaf, // Keep non-leaf frame pointers.
161-
All, // Keep all frame pointers.
158+
NonLeafNoReserve, // Keep non-leaf frame pointers, allow the FP to be used
159+
// as a GPR in leaf functions.
160+
None, // Omit all frame pointers.
161+
Reserved, // Maintain valid frame pointer chain.
162+
NonLeaf, // Keep non-leaf frame pointers, don't allow the FP to be used as a
163+
// GPR in leaf functions.
164+
All, // Keep all frame pointers.
162165
};
163166

164167
static StringRef getFramePointerKindName(FramePointerKind Kind) {
@@ -167,6 +170,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
167170
return "none";
168171
case FramePointerKind::Reserved:
169172
return "reserved";
173+
case FramePointerKind::NonLeafNoReserve:
174+
return "non-leaf-no-reserve";
170175
case FramePointerKind::NonLeaf:
171176
return "non-leaf";
172177
case FramePointerKind::All:

clang/include/clang/Options/Options.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5666,6 +5666,9 @@ def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings
56665666
def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group<m_Group>;
56675667
def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group<m_Group>,
56685668
HelpText<"Omit frame pointer setup for leaf functions">;
5669+
def mno_reserve_frame_pointer_reg : Flag<["-"], "mno-reserve-frame-pointer-reg">, Group<m_Group>;
5670+
def mreserve_frame_pointer_reg : Flag<["-"], "mreserve-frame-pointer-reg">, Group<m_Group>,
5671+
HelpText<"Reserve the frame pointer register even if the function doesn't have a frame">;
56695672
def moslib_EQ : Joined<["-"], "moslib=">, Group<m_Group>;
56705673
def mpascal_strings : Flag<["-"], "mpascal-strings">, Alias<fpascal_strings>;
56715674
def mred_zone : Flag<["-"], "mred-zone">, Group<m_Group>;
@@ -8494,8 +8497,8 @@ def pic_is_pie : Flag<["-"], "pic-is-pie">,
84948497
MarshallingInfoFlag<LangOpts<"PIE">>;
84958498

84968499
def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">,
8497-
HelpText<"Specify which frame pointers to retain.">, Values<"all,non-leaf,reserved,none">,
8498-
NormalizedValuesScope<"CodeGenOptions::FramePointerKind">, NormalizedValues<["All", "NonLeaf", "Reserved", "None"]>,
8500+
HelpText<"Specify which frame pointers to retain.">, Values<"all,non-leaf,non-leaf-no-reserve,reserved,none">,
8501+
NormalizedValuesScope<"CodeGenOptions::FramePointerKind">, NormalizedValues<["All", "NonLeaf", "NonLeafNoReserve", "Reserved", "None"]>,
84998502
MarshallingInfoEnum<CodeGenOpts<"FramePointer">, "None">;
85008503

85018504

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,7 @@ static void getTrivialDefaultFunctionAttributes(
19911991
// This is the default behavior.
19921992
break;
19931993
case CodeGenOptions::FramePointerKind::Reserved:
1994+
case CodeGenOptions::FramePointerKind::NonLeafNoReserve:
19941995
case CodeGenOptions::FramePointerKind::NonLeaf:
19951996
case CodeGenOptions::FramePointerKind::All:
19961997
FuncAttrs.addAttribute("frame-pointer",

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,9 @@ void CodeGenModule::Release() {
15121512
case CodeGenOptions::FramePointerKind::Reserved:
15131513
getModule().setFramePointer(llvm::FramePointerKind::Reserved);
15141514
break;
1515+
case CodeGenOptions::FramePointerKind::NonLeafNoReserve:
1516+
getModule().setFramePointer(llvm::FramePointerKind::NonLeafNoReserve);
1517+
break;
15151518
case CodeGenOptions::FramePointerKind::NonLeaf:
15161519
getModule().setFramePointer(llvm::FramePointerKind::NonLeaf);
15171520
break;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5704,6 +5704,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
57045704
case CodeGenOptions::FramePointerKind::Reserved:
57055705
FPKeepKindStr = "-mframe-pointer=reserved";
57065706
break;
5707+
case CodeGenOptions::FramePointerKind::NonLeafNoReserve:
5708+
FPKeepKindStr = "-mframe-pointer=non-leaf-no-reserve";
5709+
break;
57075710
case CodeGenOptions::FramePointerKind::NonLeaf:
57085711
FPKeepKindStr = "-mframe-pointer=non-leaf";
57095712
break;

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,26 +221,39 @@ static bool framePointerImpliesLeafFramePointer(const llvm::opt::ArgList &Args,
221221
clang::CodeGenOptions::FramePointerKind
222222
getFramePointerKind(const llvm::opt::ArgList &Args,
223223
const llvm::Triple &Triple) {
224-
// There are three things to consider here:
224+
// There are four things to consider here:
225225
// * Should a frame record be created for non-leaf functions?
226226
// * Should a frame record be created for leaf functions?
227-
// * Is the frame pointer register reserved, i.e. must it always point to
228-
// either a new, valid frame record or be un-modified?
227+
// * Is the frame pointer register reserved in non-leaf functions?
228+
// i.e. must it always point to either a new, valid frame record or be
229+
// un-modified?
230+
// * Is the frame pointer register reserved in leaf functions?
229231
//
230232
// Not all combinations of these are valid:
231233
// * It's not useful to have leaf frame records without non-leaf ones.
232234
// * It's not useful to have frame records without reserving the frame
233235
// pointer.
234236
//
235-
// | Non-leaf | Leaf | Reserved |
236-
// | N | N | N | FramePointerKind::None
237-
// | N | N | Y | FramePointerKind::Reserved
238-
// | N | Y | N | Invalid
239-
// | N | Y | Y | Invalid
240-
// | Y | N | N | Invalid
241-
// | Y | N | Y | FramePointerKind::NonLeaf
242-
// | Y | Y | N | Invalid
243-
// | Y | Y | Y | FramePointerKind::All
237+
// | Frame Setup | Reg Reserved |
238+
// |-----------------|-----------------|
239+
// | Non-leaf | Leaf | Non-Leaf | Leaf |
240+
// |----------|------|----------|------|
241+
// | N | N | N | N | FramePointerKind::None
242+
// | N | N | N | Y | Invalid
243+
// | N | N | Y | N | Invalid
244+
// | N | N | Y | Y | FramePointerKind::Reserved
245+
// | N | Y | N | N | Invalid
246+
// | N | Y | N | Y | Invalid
247+
// | N | Y | Y | N | Invalid
248+
// | N | Y | Y | Y | Invalid
249+
// | Y | N | N | N | Invalid
250+
// | Y | N | N | Y | Invalid
251+
// | Y | N | Y | N | FramePointerKind::NonLeafNoReserve
252+
// | Y | N | Y | Y | FramePointerKind::NonLeaf
253+
// | Y | Y | N | N | Invalid
254+
// | Y | Y | N | Y | Invalid
255+
// | Y | Y | Y | N | Invalid
256+
// | Y | Y | Y | Y | FramePointerKind::All
244257
//
245258
// The FramePointerKind::Reserved case is currently only reachable for Arm,
246259
// which has the -mframe-chain= option which can (in combination with
@@ -259,12 +272,18 @@ getFramePointerKind(const llvm::opt::ArgList &Args,
259272
Args.hasFlag(options::OPT_mno_omit_leaf_frame_pointer,
260273
options::OPT_momit_leaf_frame_pointer, DefaultLeafFP);
261274

262-
bool FPRegReserved = EnableFP || mustMaintainValidFrameChain(Args, Triple);
275+
bool FPRegReserved = Args.hasFlag(options::OPT_mreserve_frame_pointer_reg,
276+
options::OPT_mno_reserve_frame_pointer_reg,
277+
mustMaintainValidFrameChain(Args, Triple));
263278

264279
if (EnableFP) {
265280
if (EnableLeafFP)
266281
return clang::CodeGenOptions::FramePointerKind::All;
267-
return clang::CodeGenOptions::FramePointerKind::NonLeaf;
282+
283+
if (FPRegReserved)
284+
return clang::CodeGenOptions::FramePointerKind::NonLeaf;
285+
286+
return clang::CodeGenOptions::FramePointerKind::NonLeafNoReserve;
268287
}
269288
if (FPRegReserved)
270289
return clang::CodeGenOptions::FramePointerKind::Reserved;

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,9 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
10711071
case CodeGenOptions::FramePointerKind::Reserved:
10721072
FPKeepKindStr = "-mframe-pointer=reserved";
10731073
break;
1074+
case CodeGenOptions::FramePointerKind::NonLeafNoReserve:
1075+
FPKeepKindStr = "-mframe-pointer=non-leaf-no-reserve";
1076+
break;
10741077
case CodeGenOptions::FramePointerKind::NonLeaf:
10751078
FPKeepKindStr = "-mframe-pointer=non-leaf";
10761079
break;

clang/test/Driver/frame-pointer-elim.c

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// KEEP-ALL: "-mframe-pointer=all"
33
// KEEP-NON-LEAF-NOT: warning: argument unused
44
// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
5+
// KEEP-NON-LEAF-NO-RESERVE-NOT: warning: argument unused
6+
// KEEP-NON-LEAF-NO-RESERVE: "-mframe-pointer=non-leaf-no-reserve"
57
// KEEP-NONE-NOT: warning: argument unused
68
// KEEP-NONE: "-mframe-pointer=none"
79
// KEEP-RESERVED-NOT: warning: argument unused
@@ -24,19 +26,27 @@
2426
// -momit-leaf-frame-pointer omits leaf frame pointer.
2527
// -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
2628
// RUN: %clang -### --target=i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
27-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
29+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
2830
// RUN: %clang -### --target=i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
29-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
31+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
3032
// RUN: %clang -### --target=i386-linux -S -O1 -momit-leaf-frame-pointer %s 2>&1 | \
3133
// RUN: FileCheck --check-prefix=KEEP-NONE %s
3234

35+
// -momit-leaf-frame-pointer -mreserve-frame-pointer-reg results in the frame pointer reg being reserved
36+
// RUN: %clang -### --target=i386 -S -momit-leaf-frame-pointer -mreserve-frame-pointer-reg %s 2>&1 | \
37+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
38+
39+
// -fomit-frame-pointer -mreserve-frame-pointer-reg results in the frame pointer reg being reserved
40+
// RUN: %clang -### --target=i386 -S -fomit-frame-pointer -mreserve-frame-pointer-reg %s 2>&1 | \
41+
// RUN: FileCheck --check-prefix=KEEP-RESERVED %s
42+
3343
// fno-omit-frame-pointer -momit-leaf-frame-pointer can be overwritten by
3444
// fomit-frame-pointer later on the command without warning
3545
// RUN: %clang -### --target=i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer -fomit-frame-pointer %s 2>&1 | \
3646
// RUN: FileCheck --check-prefix=KEEP-NONE %s
3747

3848
// RUN: %clang -### --target=i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
39-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
49+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
4050
// Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
4151
// RUN: %clang -### --target=i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
4252
// RUN: FileCheck --check-prefix=KEEP-NONE %s
@@ -68,45 +78,45 @@
6878
// RUN: FileCheck --check-prefix=KEEP-NONE %s
6979

7080
// RUN: %clang -### --target=i386-darwin -S -momit-leaf-frame-pointer %s 2>&1 | \
71-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
81+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
7282

7383
// RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
7484
// RUN: FileCheck --check-prefix=WARN-OMIT-7S %s
7585
// WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
76-
// WARN-OMIT-7S: "-mframe-pointer=non-leaf"
86+
// WARN-OMIT-7S: "-mframe-pointer=non-leaf-no-reserve"
7787

7888
// RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
7989
// RUN: FileCheck --check-prefix=WARN-OMIT-7K %s
8090
// WARN-OMIT-7K: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7k'
81-
// WARN-OMIT-7K: "-mframe-pointer=non-leaf"
91+
// WARN-OMIT-7K: "-mframe-pointer=non-leaf-no-reserve"
8292

8393
// RUN: %clang -### -target armv7s-apple-ios8.0 -momit-leaf-frame-pointer %s 2>&1 | \
8494
// RUN: FileCheck --check-prefix=WARN-OMIT-LEAF-7S %s
8595
// WARN-OMIT-LEAF-7S-NOT: warning: optimization flag '-momit-leaf-frame-pointer' is not supported for target 'armv7s'
86-
// WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
96+
// WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf-no-reserve"
8797

8898
// On AArch64, PS4, PS5, and VE, default to omitting the frame pointer on leaf
8999
// functions
90100
// RUN: %clang -### --target=aarch64 -S %s 2>&1 | \
91-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
101+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
92102
// RUN: %clang -### --target=x86_64-scei-ps4 -S %s 2>&1 | \
93-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
103+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
94104
// RUN: %clang -### --target=x86_64-scei-ps4 -S -O2 %s 2>&1 | \
95-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
105+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
96106
// RUN: %clang -### --target=x86_64-sie-ps5 -S %s 2>&1 | \
97-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
107+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
98108
// RUN: %clang -### --target=x86_64-sie-ps5 -S -O2 %s 2>&1 | \
99-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
109+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
100110
// RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
101-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
111+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
102112
// RUN: %clang -### --target=ve-unknown-linux-gnu -S %s 2>&1 | \
103-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
113+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
104114
// RUN: %clang -### --target=aarch64-linux-android -S %s 2>&1 | \
105-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
115+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
106116
// RUN: %clang -### --target=aarch64-linux-android -S -O2 %s 2>&1 | \
107-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
117+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
108118
// RUN: %clang -### --target=aarch64-linux-android -S -Os %s 2>&1 | \
109-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
119+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
110120

111121
// RUN: %clang -### --target=powerpc64 -S %s 2>&1 | \
112122
// RUN: FileCheck --check-prefix=KEEP-ALL %s
@@ -161,9 +171,9 @@
161171
// RUN: %clang -### --target=armv7a-linux-androideabi- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
162172
// RUN: FileCheck --check-prefix=KEEP-ALL %s
163173
// RUN: %clang -### --target=riscv64-linux-android -O1 -S %s 2>&1 | \
164-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
174+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
165175
// RUN: %clang -### --target=riscv64-linux-android -mbig-endian -O1 -S %s 2>&1 | \
166-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
176+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
167177

168178
// On ARM backend bare metal targets, frame pointer is omitted
169179
// RUN: %clang -### --target=arm-arm-none-eabi -S %s 2>&1 | \
@@ -191,21 +201,21 @@
191201

192202
// Check that for Apple bare metal targets, we're keeping frame pointers by default
193203
// RUN: %clang -### --target=armv6m-apple-none-macho -S %s 2>&1 | \
194-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
204+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
195205
// RUN: %clang -### --target=armv6m-apple-none-macho -S -fno-omit-frame-pointer %s 2>&1 | \
196-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
206+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
197207
// RUN: %clang -### --target=arm-apple-none-macho -S %s 2>&1 | \
198-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
208+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
199209
// RUN: %clang -### --target=arm-apple-none-macho -S -fno-omit-frame-pointer %s 2>&1 | \
200-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
210+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
201211
// RUN: %clang -### --target=armv6m-apple-none-macho -S -O1 %s 2>&1 | \
202-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
212+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
203213
// RUN: %clang -### --target=armv6m-apple-none-macho -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
204-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
214+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
205215
// RUN: %clang -### --target=arm-apple-none-macho -S -O1 %s 2>&1 | \
206-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
216+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
207217
// RUN: %clang -### --target=arm-apple-none-macho -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
208-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
218+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
209219

210220
// RUN: %clang --target=armv7-apple-macho -### -S %s 2>&1 \
211221
// RUN: -fomit-frame-pointer \
@@ -221,17 +231,22 @@
221231

222232
// AArch64 bare metal targets behave like hosted targets
223233
// RUN: %clang -### --target=aarch64-none-elf -S %s 2>&1 | \
224-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
234+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
225235
// RUN: %clang -### --target=aarch64-none-elf -S -O1 %s 2>&1 | \
226-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
236+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
227237
// RUN: %clang -### --target=aarch64-none-elf -S -fno-omit-frame-pointer %s 2>&1 | \
228-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
238+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
229239
// RUN: %clang -### --target=aarch64-none-elf -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
230-
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
240+
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF-NO-RESERVE %s
231241

232242
// AArch64 Windows requires that the frame pointer be reserved
233243
// RUN: %clang -### --target=aarch64-pc-windows-msvc -S -fomit-frame-pointer %s 2>&1 | \
234244
// RUN: FileCheck --check-prefix=KEEP-RESERVED %s
235245

246+
// -mno-reserve-frame-pointer-reg overrides platform defaults
247+
// But -mno-reserve-frame-pointer-reg should override the target platform default
248+
// RUN: %clang -### --target=aarch64-pc-windows-msvc -S -fomit-frame-pointer -mno-reserve-frame-pointer-reg %s 2>&1 | \
249+
// RUN: FileCheck --check-prefix=KEEP-NONE %s
250+
236251
void f0() {}
237252
void f1() { f0(); }

clang/test/Driver/fuchsia.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
// RUN: %clang -### %s --target=aarch64-unknown-fuchsia -O3 2>&1 \
7878
// RUN: | FileCheck %s -check-prefix=CHECK-FP-NONE
7979
// CHECK-FP-ALL: "-mframe-pointer=all"
80-
// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf"
80+
// CHECK-FP-NONLEAF: "-mframe-pointer=non-leaf-no-reserve"
8181
// CHECK-FP-NONE: "-mframe-pointer=none"
8282

8383
// RUN: not %clang -### %s --target=x86_64-unknown-fuchsia -rtlib=libgcc 2>&1 \

0 commit comments

Comments
 (0)