[PATCH] D71167: [Driver] Default to -momit-leaf-frame-pointer for AArch64

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 7 11:10:13 PST 2019


MaskRay created this revision.
MaskRay added reviewers: c-rhodes, efriedma, rengolin, sdesmalen.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

This matches https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html

> -momit-leaf-frame-pointer
> -mno-omit-leaf-frame-pointer
> 
>   Omit or keep the frame pointer in leaf functions. The former behavior is the default.

-mno-omit-leaf-frame-pointer is currently a no-op because
TargetOptions::DisableFramePointerElim is only considered for non-leaf
functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71167

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/frame-pointer-elim.c


Index: clang/test/Driver/frame-pointer-elim.c
===================================================================
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -90,7 +90,9 @@
 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag '-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
 
-// On the PS4, we default to omitting the frame pointer on leaf functions
+// On AArch64 and PS4, default to omitting the frame pointer on leaf functions
+// RUN: %clang -### -target aarch64 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -603,9 +603,9 @@
   bool OmitFP = A && A->getOption().matches(options::OPT_fomit_frame_pointer);
   bool NoOmitFP =
       A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
-  bool KeepLeaf =
-      Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
-                   options::OPT_mno_omit_leaf_frame_pointer, Triple.isPS4CPU());
+  bool KeepLeaf = Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
+                               options::OPT_mno_omit_leaf_frame_pointer,
+                               Triple.isAArch64() || Triple.isPS4CPU());
   if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
       (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
     if (KeepLeaf)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71167.232714.patch
Type: text/x-patch
Size: 1750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191207/4f601768/attachment.bin>


More information about the cfe-commits mailing list