2019-08-14 01:37:09 +08:00
|
|
|
// KEEP-ALL-NOT: warning:
|
2019-07-21 06:50:50 +08:00
|
|
|
// KEEP-ALL: "-mframe-pointer=all"
|
2019-08-14 01:37:09 +08:00
|
|
|
// KEEP-NON-LEAF-NOT: warning:
|
2019-07-21 06:50:50 +08:00
|
|
|
// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
|
2019-08-14 01:37:09 +08:00
|
|
|
// KEEP-NONE-NOT: warning:
|
2019-07-21 06:50:50 +08:00
|
|
|
// KEEP-NONE: "-mframe-pointer=none"
|
2019-07-12 10:01:51 +08:00
|
|
|
|
|
|
|
// On Linux x86, omit frame pointer when optimization is enabled.
|
|
|
|
// RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
|
|
|
|
// -fno-omit-frame-pointer or -pg disables frame pointer omission.
|
|
|
|
// RUN: %clang -### -target i386-linux -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 -pg %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
|
|
|
|
// -momit-leaf-frame-pointer omits leaf frame pointer.
|
|
|
|
// -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
|
|
|
|
// RUN: %clang -### -target i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 -momit-leaf-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
|
2019-08-14 01:37:09 +08:00
|
|
|
// fno-omit-frame-pointer -momit-leaf-frame-pointer can be overwritten by
|
|
|
|
// fomit-frame-pointer later on the command without warning
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer -fomit-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
|
|
|
|
// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2019-07-12 10:01:51 +08:00
|
|
|
// Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
|
|
|
|
// RUN: %clang -### -target i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
// RUN: %clang -### -target i386-linux -S %s -O1 -mno-omit-leaf-frame-pointer 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
|
|
|
|
// -pg -fomit-frame-pointer => error.
|
|
|
|
// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
|
|
|
|
// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
|
|
|
|
// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
|
|
|
|
// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
|
2016-08-12 03:23:30 +08:00
|
|
|
|
|
|
|
// CloudABI follows the same rules as Linux.
|
|
|
|
// RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
2016-08-12 03:23:30 +08:00
|
|
|
|
|
|
|
// RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
2013-04-03 09:58:53 +08:00
|
|
|
|
2018-07-17 20:38:57 +08:00
|
|
|
// NetBSD follows the same rules as Linux.
|
|
|
|
// RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
2018-07-17 20:38:57 +08:00
|
|
|
|
|
|
|
// RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
2018-07-17 20:38:57 +08:00
|
|
|
|
2013-04-03 09:58:53 +08:00
|
|
|
// Darwin disables omitting the leaf frame pointer even under optimization
|
|
|
|
// unless the command lines are given.
|
|
|
|
// RUN: %clang -### -target i386-apple-darwin -S %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
2010-07-01 09:31:45 +08:00
|
|
|
|
2013-04-03 09:58:53 +08:00
|
|
|
// RUN: %clang -### -target i386-apple-darwin -S -O1 %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
2011-02-02 15:17:02 +08:00
|
|
|
|
2013-04-03 09:58:53 +08:00
|
|
|
// RUN: %clang -### -target i386-darwin -S -fomit-frame-pointer %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
2010-07-01 09:31:45 +08:00
|
|
|
|
2013-04-03 09:58:53 +08:00
|
|
|
// RUN: %clang -### -target i386-darwin -S -momit-leaf-frame-pointer %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2010-07-01 09:31:45 +08:00
|
|
|
|
2016-08-24 02:12:58 +08:00
|
|
|
// RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=WARN-OMIT-7S %s
|
|
|
|
// WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
|
2019-07-21 06:50:50 +08:00
|
|
|
// WARN-OMIT-7S: "-mframe-pointer=all"
|
2016-08-24 02:12:58 +08:00
|
|
|
|
|
|
|
// RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=WARN-OMIT-7K %s
|
|
|
|
// WARN-OMIT-7K: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7k'
|
2019-07-21 06:50:50 +08:00
|
|
|
// WARN-OMIT-7K: "-mframe-pointer=all"
|
2016-08-24 02:12:58 +08:00
|
|
|
|
|
|
|
// RUN: %clang -### -target armv7s-apple-ios8.0 -momit-leaf-frame-pointer %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=WARN-OMIT-LEAF-7S %s
|
2017-01-28 01:53:42 +08:00
|
|
|
// WARN-OMIT-LEAF-7S-NOT: warning: optimization flag '-momit-leaf-frame-pointer' is not supported for target 'armv7s'
|
2019-07-21 06:50:50 +08:00
|
|
|
// WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
|
2016-08-24 02:12:58 +08:00
|
|
|
|
2022-04-29 01:34:57 +08:00
|
|
|
// On AArch64, PS4, PS5, and VE, default to omitting the frame pointer on leaf
|
2021-11-03 14:04:39 +08:00
|
|
|
// functions
|
2019-12-08 02:40:39 +08:00
|
|
|
// RUN: %clang -### -target aarch64 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2015-01-31 02:25:48 +08:00
|
|
|
// RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2016-08-24 10:02:32 +08:00
|
|
|
// RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
|
2019-07-12 10:01:51 +08:00
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2022-04-29 01:34:57 +08:00
|
|
|
// RUN: %clang -### -target x86_64-sie-ps5 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
|
|
|
// RUN: %clang -### -target x86_64-sie-ps5 -S -O2 %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2020-11-10 19:15:08 +08:00
|
|
|
// RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2021-11-03 14:04:39 +08:00
|
|
|
// RUN: %clang -### -target ve-unknown-linux-gnu -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
|
2015-01-31 02:25:48 +08:00
|
|
|
|
2019-07-12 10:14:08 +08:00
|
|
|
// RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target powerpc64 -S -O1 %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
|
[Clang][A32/T32][Linux] -O1 implies -fomit-frame-pointer
Summary:
An upgrade of LLVM for CrOS [0] containing [1] triggered a bunch of
errors related to writing to reserved registers for a Linux kernel's
arm64 compat vdso (which is a aarch32 image).
After a discussion on LKML [2], it was determined that
-f{no-}omit-frame-pointer was not being specified. Comparing GCC and
Clang [3], it becomes apparent that GCC defaults to omitting the frame
pointer implicitly when optimizations are enabled, and Clang does not.
ie. setting -O1 (or above) implies -fomit-frame-pointer. Clang was
defaulting to -fno-omit-frame-pointer implicitly unless -fomit-frame-pointer
was set explicitly.
Why this becomes a problem is that the Linux kernel's arm64 compat vdso
contains code that uses r7. r7 is used sometimes for the frame pointer
(for example, when targeting thumb (-mthumb)). See useR7AsFramePointer()
in llvm/llvm-project/llvm/lib/Target/ARM/ARMSubtarget.h. This is mostly
for legacy/compatibility reasons, and the 2019 Q4 revision of the ARM
AAPCS looks to standardize r11 as the frame pointer for aarch32, though
this is not yet implemented in LLVM.
Users that are reliant on the implicit value if unspecified when
optimizations are enabled should explicitly choose -fomit-frame-pointer
(new behavior) or -fno-omit-frame-pointer (old behavior).
[0] https://bugs.chromium.org/p/chromium/issues/detail?id=1084372
[1] https://reviews.llvm.org/D76848
[2] https://lore.kernel.org/lkml/20200526173117.155339-1-ndesaulniers@google.com/
[3] https://godbolt.org/z/0oY39t
Reviewers: kristof.beyls, psmith, danalbert, srhines, MaskRay, ostannard, efriedma
Reviewed By: psmith, danalbert, srhines, MaskRay, efriedma
Subscribers: efriedma, olista01, MaskRay, vhscampos, cfe-commits, llvm-commits, manojgupta, llozano, glider, hctim, eugenis, pcc, peter.smith, srhines
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D80828
2020-06-03 06:54:09 +08:00
|
|
|
// For AAarch32 (A32, T32) linux targets, default omit frame pointer when
|
|
|
|
// optimizations are enabled.
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -marm -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -marm -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -marm -mbig-endian -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
// RUN: %clang -### -target arm-linux-gnueabihf- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-NONE %s
|
|
|
|
// For Android, keep the framepointers always.
|
|
|
|
// RUN: %clang -### -target armv7a-linux-androideabi- -marm -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target armv7a-linux-androideabi- -marm -mbig-endian -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
// RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
|
|
|
|
// RUN: FileCheck --check-prefix=KEEP-ALL %s
|
|
|
|
|
2010-07-01 09:31:45 +08:00
|
|
|
void f0() {}
|
|
|
|
void f1() { f0(); }
|