r253846 - Disable frame pointer elimination when using -pg
Xinliang David Li via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 22 21:09:10 PST 2015
Author: davidxl
Date: Sun Nov 22 23:09:10 2015
New Revision: 253846
URL: http://llvm.org/viewvc/llvm-project?rev=253846&view=rev
Log:
Disable frame pointer elimination when using -pg
This diff makes sure that the driver does not pass
-fomit-frame-pointer or -momit-leaf-frame-pointer to
the frontend when -pg is used. Currently, clang gives
an error if -fomit-frame-pointer is used in combination
with -pg, but -momit-leaf-frame-pointer was forgotten.
Also, disable frame pointer elimination in the frontend
when -pg is set.
Patch by Stefan Kempf.
Added:
cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253846&r1=253845&r2=253846&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Nov 22 23:09:10 2015
@@ -2794,6 +2794,8 @@ static bool shouldUseFramePointer(const
if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
return A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+ if (Args.hasArg(options::OPT_pg))
+ return true;
return shouldUseFramePointerForTarget(Args, Triple);
}
@@ -2803,6 +2805,8 @@ static bool shouldUseLeafFramePointer(co
if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer))
return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
+ if (Args.hasArg(options::OPT_pg))
+ return true;
if (Triple.isPS4CPU())
return false;
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=253846&r1=253845&r2=253846&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sun Nov 22 23:09:10 2015
@@ -453,7 +453,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
Opts.CXXCtorDtorAliases = Args.hasArg(OPT_mconstructor_aliases);
Opts.CodeModel = getCodeModel(Args, Diags);
Opts.DebugPass = Args.getLastArgValue(OPT_mdebug_pass);
- Opts.DisableFPElim = Args.hasArg(OPT_mdisable_fp_elim);
+ Opts.DisableFPElim =
+ (Args.hasArg(OPT_mdisable_fp_elim) || Args.hasArg(OPT_pg));
Opts.DisableFree = Args.hasArg(OPT_disable_free);
Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
Added: cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c?rev=253846&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c (added)
+++ cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c Sun Nov 22 23:09:10 2015
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -pg -S -o - %s | \
+// RUN: FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -momit-leaf-frame-pointer -pg -S -o - %s | \
+// RUN: FileCheck %s
+
+// Test that the frame pointer is kept when compiling with
+// profiling.
+
+//CHECK: pushq %rbp
+int main(void)
+{
+ return 0;
+}
More information about the cfe-commits
mailing list