[cfe-commits] r107367 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.h lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/frame-pointer-elim.c

Daniel Dunbar daniel at zuster.org
Wed Jun 30 18:31:45 PDT 2010


Author: ddunbar
Date: Wed Jun 30 20:31:45 2010
New Revision: 107367

URL: http://llvm.org/viewvc/llvm-project?rev=107367&view=rev
Log:
Driver/IRgen: Add support for -momit-leaf-frame-pointer.

Added:
    cfe/trunk/test/CodeGen/frame-pointer-elim.c
Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/include/clang/Frontend/CodeGenOptions.h
    cfe/trunk/lib/CodeGen/BackendUtil.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=107367&r1=107366&r2=107367&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Jun 30 20:31:45 2010
@@ -149,6 +149,8 @@
   HelpText<"Limit float precision to the given value">;
 def mno_zero_initialized_in_bss : Flag<"-mno-zero-initialized-in-bss">,
   HelpText<"Do not put zero initialized data in the BSS">;
+def momit_leaf_frame_pointer : Flag<"-momit-leaf-frame-pointer">,
+  HelpText<"Omit frame pointer setup for leaf functions.">;
 def msoft_float : Flag<"-msoft-float">,
   HelpText<"Use software floating point">;
 def mrelax_all : Flag<"-mrelax-all">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=107367&r1=107366&r2=107367&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jun 30 20:31:45 2010
@@ -462,6 +462,8 @@
 def marm : Flag<"-marm">, Alias<mno_thumb>;
 
 def mno_warn_nonportable_cfstrings : Flag<"-mno-warn-nonportable-cfstrings">, Group<m_Group>;
+def mno_omit_leaf_frame_pointer : Flag<"-mno-omit-leaf-frame-pointer">, Group<f_Group>;
+def momit_leaf_frame_pointer : Flag<"-momit-leaf-frame-pointer">, Group<f_Group>;
 def mpascal_strings : Flag<"-mpascal-strings">, Group<m_Group>;
 def mred_zone : Flag<"-mred-zone">, Group<m_Group>;
 def mrelax_all : Flag<"-mrelax-all">, Group<m_Group>;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=107367&r1=107366&r2=107367&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Wed Jun 30 20:31:45 2010
@@ -53,6 +53,8 @@
   unsigned NoImplicitFloat   : 1; /// Set when -mno-implicit-float is enabled.
   unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
   unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
+  unsigned OmitLeafFramePointer : 1; /// Set when -momit-leaf-frame-pointer is
+                                     /// enabled.
   unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
   unsigned OptimizeSize      : 1; /// If -Os is specified.
   unsigned RelaxAll          : 1; /// Relax all machine code instructions.
@@ -109,6 +111,7 @@
     NoImplicitFloat = 0;
     NoZeroInitializedInBSS = 0;
     ObjCDispatchMethod = Legacy;
+    OmitLeafFramePointer = 0;
     OptimizationLevel = 0;
     OptimizeSize = 0;
     RelaxAll = 0;

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=107367&r1=107366&r2=107367&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jun 30 20:31:45 2010
@@ -160,7 +160,20 @@
   // FIXME: Expose these capabilities via actual APIs!!!! Aside from just
   // being gross, this is also totally broken if we ever care about
   // concurrency.
-  llvm::NoFramePointerElim = CodeGenOpts.DisableFPElim;
+
+  // Set frame pointer elimination mode.
+  if (!CodeGenOpts.DisableFPElim) {
+    llvm::NoFramePointerElim = false;
+    llvm::NoFramePointerElimNonLeaf = false;
+  } else if (CodeGenOpts.OmitLeafFramePointer) {
+    llvm::NoFramePointerElim = false;
+    llvm::NoFramePointerElimNonLeaf = true;
+  } else {
+    llvm::NoFramePointerElim = true;
+    llvm::NoFramePointerElimNonLeaf = true;
+  }
+
+  // Set float ABI type.
   if (CodeGenOpts.FloatABI == "soft")
     llvm::FloatABIType = llvm::FloatABI::Soft;
   else if (CodeGenOpts.FloatABI == "hard")
@@ -169,6 +182,7 @@
     assert(CodeGenOpts.FloatABI.empty() && "Invalid float abi!");
     llvm::FloatABIType = llvm::FloatABI::Default;
   }
+
   NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
   llvm::UseSoftFloat = CodeGenOpts.SoftFloat;
   UnwindTablesMandatory = CodeGenOpts.UnwindTables;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=107367&r1=107366&r2=107367&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jun 30 20:31:45 2010
@@ -999,6 +999,11 @@
     break;
   }
 
+  // -mno-omit-leaf-frame-pointer is default.
+  if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
+                   options::OPT_mno_omit_leaf_frame_pointer, false))
+    CmdArgs.push_back("-momit-leaf-frame-pointer");
+
   // -fno-math-errno is default.
   if (Args.hasFlag(options::OPT_fmath_errno,
                    options::OPT_fno_math_errno,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=107367&r1=107366&r2=107367&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jun 30 20:31:45 2010
@@ -132,6 +132,8 @@
     Res.push_back("-fno-common");
   if (Opts.NoImplicitFloat)
     Res.push_back("-no-implicit-float");
+  if (Opts.OmitLeafFramePointer)
+    Res.push_back("-momit-leaf-frame-pointer");
   if (Opts.OptimizeSize) {
     assert(Opts.OptimizationLevel == 2 && "Invalid options!");
     Res.push_back("-Os");
@@ -833,6 +835,7 @@
   Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
+  Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
   Opts.SoftFloat = Args.hasArg(OPT_msoft_float);
   Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
   Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");

Added: cfe/trunk/test/CodeGen/frame-pointer-elim.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/frame-pointer-elim.c?rev=107367&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/frame-pointer-elim.c (added)
+++ cfe/trunk/test/CodeGen/frame-pointer-elim.c Wed Jun 30 20:31:45 2010
@@ -0,0 +1,29 @@
+// RUN: %clang -ccc-host-triple i386 -S -o - %s | \
+// RUN:   FileCheck --check-prefix=DEFAULT %s
+// DEFAULT: f0:
+// DEFAULT: pushl %ebp
+// DEFAULT: ret
+// DEFAULT: f1:
+// DEFAULT: pushl %ebp
+// DEFAULT: ret
+
+// RUN: %clang -ccc-host-triple i386 -S -o - -fomit-frame-pointer %s | \
+// RUN:   FileCheck --check-prefix=OMIT_ALL %s
+// OMIT_ALL: f0:
+// OMIT_ALL-NOT: pushl %ebp
+// OMIT_ALL: ret
+// OMIT_ALL: f1:
+// OMIT_ALL-NOT: pushl %ebp
+// OMIT_ALL: ret
+
+// RUN: %clang -ccc-host-triple i386 -S -o - -momit-leaf-frame-pointer %s | \
+// RUN:   FileCheck --check-prefix=OMIT_LEAF %s
+// OMIT_LEAF: f0:
+// OMIT_LEAF-NOT: pushl %ebp
+// OMIT_LEAF: ret
+// OMIT_LEAF: f1:
+// OMIT_LEAF: pushl %ebp
+// OMIT_LEAF: ret
+
+void f0() {}
+void f1() { f0(); }





More information about the cfe-commits mailing list