r253886 - Disable frame pointer elimination when using -pg
Stefan Kempf via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 07:46:53 PST 2015
Hi,
David Blaikie via cfe-commits wrote:
> On Mon, Nov 23, 2015 at 9:30 AM, Xinliang David Li via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
> > Author: davidxl
> > Date: Mon Nov 23 11:30:31 2015
> > New Revision: 253886
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=253886&view=rev
> > Log:
> > Disable frame pointer elimination when using -pg
> >
> > (Re-apply patch after bug fixing)
> >
>
> It's helpful to describe what the bug fixing was (& test changes to ensure
> it's covered (if it fails only on some subset of buildbots usually a test
> case can be added so it would fail on any buildbot/locally, which is a good
> idea to help proactively avoid regressions in the future)) when
> recommitting a patch.
the patch that David initally committed contained a test case that
was x86 specific. Thus it would fail on the AArch64 buildbot, for example.
The bug fix in the re-commited patch was to fix the test case to run
only when clang was configured with the x86 target.
> >
> > 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=253886&r1=253885&r2=253886&view=diff
> >
> > ==============================================================================
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Mon Nov 23 11:30:31 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=253886&r1=253885&r2=253886&view=diff
> >
> > ==============================================================================
> > --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> > +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Nov 23 11:30:31 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=253886&view=auto
> >
> > ==============================================================================
> > --- cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c (added)
> > +++ cfe/trunk/test/CodeGen/x86_64-profiling-keep-fp.c Mon Nov 23 11:30:31
> > 2015
> > @@ -0,0 +1,14 @@
> > +// REQUIRES: x86-registered-target
> > +// 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;
> > +}
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list