r292458 - Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 21 10:58:13 PDT 2017


On Fri, Aug 18, 2017 at 5:22 PM, Dehao Chen <dehao at google.com> wrote:
> On Fri, Aug 18, 2017 at 2:46 PM, Hans Wennborg <hans at chromium.org> wrote:
>>
>> Should we mention this in the release notes?
>>
>>
>> Is the flag documented somewhere?
>
>
> It's documented in the Options.td file, do you think there are other
> documents that need to be added/updated?

Maybe https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization
if we think this is something users should be using.

And if it improves things, perhaps its worth mentioning in the release notes?

Thanks,
Hans


>> On Wed, Jan 18, 2017 at 4:44 PM, Dehao Chen via cfe-commits
>> <cfe-commits at lists.llvm.org> wrote:
>> > Author: dehao
>> > Date: Wed Jan 18 18:44:21 2017
>> > New Revision: 292458
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=292458&view=rev
>> > Log:
>> > Add -fdebug-info-for-profiling to emit more debug info for sample pgo
>> > profile collection
>> >
>> > Summary:
>> > SamplePGO uses profile with debug info to collect profile. Unlike the
>> > traditional debugging purpose, sample pgo needs more accurate debug info to
>> > represent the profile. We add -femit-accurate-debug-info for this purpose.
>> > It can be combined with all debugging modes (-g, -gmlt, etc). It makes sure
>> > that the following pieces of info is always emitted:
>> >
>> > * start line of all subprograms
>> > * linkage name of all subprograms
>> > * standalone subprograms (functions that has neither inlined nor been
>> > inlined)
>> >
>> > The impact on speccpu2006 binary size (size increase comparing with -g0
>> > binary, also includes data for -g binary, which does not change with this
>> > patch):
>> >
>> >                -gmlt(orig) -gmlt(patched) -g
>> > 433.milc       4.68%       5.40%          19.73%
>> > 444.namd       8.45%       8.93%          45.99%
>> > 447.dealII     97.43%      115.21%        374.89%
>> > 450.soplex     27.75%      31.88%         126.04%
>> > 453.povray     21.81%      26.16%         92.03%
>> > 470.lbm        0.60%       0.67%          1.96%
>> > 482.sphinx3    5.77%       6.47%          26.17%
>> > 400.perlbench  17.81%      19.43%         73.08%
>> > 401.bzip2      3.73%       3.92%          12.18%
>> > 403.gcc        31.75%      34.48%         122.75%
>> > 429.mcf        0.78%       0.88%          3.89%
>> > 445.gobmk      6.08%       7.92%          42.27%
>> > 456.hmmer      10.36%      11.25%         35.23%
>> > 458.sjeng      5.08%       5.42%          14.36%
>> > 462.libquantum 1.71%       1.96%          6.36%
>> > 464.h264ref    15.61%      16.56%         43.92%
>> > 471.omnetpp    11.93%      15.84%         60.09%
>> > 473.astar      3.11%       3.69%          14.18%
>> > 483.xalancbmk  56.29%      81.63%         353.22%
>> > geomean        15.60%      18.30%         57.81%
>> >
>> > Debug info size change for -gmlt binary with this patch:
>> >
>> > 433.milc       13.46%
>> > 444.namd       5.35%
>> > 447.dealII     18.21%
>> > 450.soplex     14.68%
>> > 453.povray     19.65%
>> > 470.lbm        6.03%
>> > 482.sphinx3    11.21%
>> > 400.perlbench  8.91%
>> > 401.bzip2      4.41%
>> > 403.gcc        8.56%
>> > 429.mcf        8.24%
>> > 445.gobmk      29.47%
>> > 456.hmmer      8.19%
>> > 458.sjeng      6.05%
>> > 462.libquantum 11.23%
>> > 464.h264ref    5.93%
>> > 471.omnetpp    31.89%
>> > 473.astar      16.20%
>> > 483.xalancbmk  44.62%
>> > geomean        16.83%
>> >
>> > Reviewers: davidxl, andreadb, rob.lougher, dblaikie, echristo
>> >
>> > Reviewed By: dblaikie, echristo
>> >
>> > Subscribers: hfinkel, rob.lougher, andreadb, gbedwell, cfe-commits,
>> > probinson, llvm-commits, mehdi_amini
>> >
>> > Differential Revision: https://reviews.llvm.org/D25435
>> >
>> > Modified:
>> >     cfe/trunk/include/clang/Driver/Options.td
>> >     cfe/trunk/include/clang/Frontend/CodeGenOptions.def
>> >     cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> >     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> >     cfe/trunk/lib/Driver/Tools.cpp
>> >     cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> >     cfe/trunk/test/Driver/clang_f_opts.c
>> >
>> > Modified: cfe/trunk/include/clang/Driver/Options.td
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/include/clang/Driver/Options.td (original)
>> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jan 18 18:44:21 2017
>> > @@ -516,6 +516,12 @@ def fprofile_sample_use_EQ : Joined<["-"
>> >      HelpText<"Enable sample-based profile guided optimizations">;
>> >  def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
>> >      Alias<fprofile_sample_use_EQ>;
>> > +def fdebug_info_for_profiling : Flag<["-"],
>> > "fdebug-info-for-profiling">, Group<f_Group>,
>> > +    Flags<[CC1Option]>,
>> > +    HelpText<"Emit extra debug info to make sample profile more
>> > accurate.">;
>> > +def fno_debug_info_for_profiling : Flag<["-"],
>> > "fno-debug-info-for-profiling">, Group<f_Group>,
>> > +    Flags<[DriverOption]>,
>> > +    HelpText<"Do not emit extra debug info for sample profiler.">;
>> >  def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
>> >      Group<f_Group>, Flags<[CoreOption]>,
>> >      HelpText<"Generate instrumented code to collect execution counts
>> > into default.profraw file (overridden by '=' form of option or
>> > LLVM_PROFILE_FILE env var)">;
>> >
>> > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
>> > +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jan 18
>> > 18:44:21 2017
>> > @@ -258,6 +258,9 @@ CODEGENOPT(PIECopyRelocations, 1, 0)
>> >  /// paths that reach the end of a function without executing a required
>> > return.
>> >  CODEGENOPT(StrictReturn, 1, 1)
>> >
>> > +/// Whether emit extra debug info for sample pgo profile collection.
>> > +CODEGENOPT(DebugInfoForProfiling, 1, 0)
>> > +
>> >  #undef CODEGENOPT
>> >  #undef ENUM_CODEGENOPT
>> >  #undef VALUE_CODEGENOPT
>> >
>> > Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
>> > +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jan 18 18:44:21 2017
>> > @@ -573,6 +573,7 @@ void EmitAssemblyHelper::CreateTargetMac
>> >    Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
>> >    Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
>> >    Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
>> > +  Options.DebugInfoForProfiling = CodeGenOpts.DebugInfoForProfiling;
>> >
>> >    // Set EABI version.
>> >    Options.EABIVersion =
>> > llvm::StringSwitch<llvm::EABI>(TargetOpts.EABIVersion)
>> >
>> > Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> > +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jan 18 18:44:21 2017
>> > @@ -2774,9 +2774,10 @@ void CGDebugInfo::collectFunctionDeclPro
>> >    }
>> >    // No need to replicate the linkage name if it isn't different from
>> > the
>> >    // subprogram name, no need to have it at all unless coverage is
>> > enabled or
>> > -  // debug is set to more than just line tables.
>> > +  // debug is set to more than just line tables or extra debug info is
>> > needed.
>> >    if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
>> >                                !CGM.getCodeGenOpts().EmitGcovNotes &&
>> > +
>> > !CGM.getCodeGenOpts().DebugInfoForProfiling &&
>> >                                DebugKind <=
>> > codegenoptions::DebugLineTablesOnly))
>> >      LinkageName = StringRef();
>> >
>> >
>> > Modified: cfe/trunk/lib/Driver/Tools.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> > +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jan 18 18:44:21 2017
>> > @@ -5615,6 +5615,10 @@ void Clang::ConstructJob(Compilation &C,
>> >        A->render(Args, CmdArgs);
>> >    }
>> >
>> > +  if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
>> > +                   options::OPT_fno_debug_info_for_profiling, false))
>> > +    CmdArgs.push_back("-fdebug-info-for-profiling");
>> > +
>> >    // -fbuiltin is default unless -mkernel is used.
>> >    bool UseBuiltins =
>> >        Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin,
>> >
>> > Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>> > +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jan 18 18:44:21
>> > 2017
>> > @@ -544,6 +544,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
>> >    Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
>> >    Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
>> >    Opts.SampleProfileFile =
>> > Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
>> > +  Opts.DebugInfoForProfiling = Args.hasFlag(
>> > +      OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling,
>> > false);
>> >
>> >    setPGOInstrumentor(Opts, Args, Diags);
>> >    Opts.InstrProfileOutput =
>> >
>> > Modified: cfe/trunk/test/Driver/clang_f_opts.c
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=292458&r1=292457&r2=292458&view=diff
>> >
>> > ==============================================================================
>> > --- cfe/trunk/test/Driver/clang_f_opts.c (original)
>> > +++ cfe/trunk/test/Driver/clang_f_opts.c Wed Jan 18 18:44:21 2017
>> > @@ -482,3 +482,8 @@
>> >  // RUN: %clang -### -S -fno-strict-return %s 2>&1 | FileCheck
>> > -check-prefix=CHECK-NO-STRICT-RETURN %s
>> >  // CHECK-STRICT-RETURN-NOT: "-fno-strict-return"
>> >  // CHECK-NO-STRICT-RETURN: "-fno-strict-return"
>> > +
>> > +// RUN: %clang -### -S -fno-debug-info-for-profiling
>> > -fdebug-info-for-profiling %s 2>&1 | FileCheck
>> > -check-prefix=CHECK-PROFILE-DEBUG %s
>> > +// RUN: %clang -### -S -fdebug-info-for-profiling
>> > -fno-debug-info-for-profiling %s 2>&1 | FileCheck
>> > -check-prefix=CHECK-NO-PROFILE-DEBUG %s
>> > +// CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling
>> > +// CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling
>> >
>> >
>> > _______________________________________________
>> > 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