[PATCH] D25435: Generate more debug info in -gmlt

Robinson, Paul via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 12:39:43 PST 2016


I'm probably okay with anything that has "debug" and prof/profile/profiling in the name.
Definitely not okay with "accurate" which I think implies more about correctness than the degree of detail.
--paulr

From: David Blaikie [mailto:dblaikie at gmail.com]
Sent: Tuesday, November 29, 2016 11:46 AM
To: Dehao Chen
Cc: reviews+D25435+public+b10d8b300f87c722 at reviews.llvm.org; Chen Dehao; echristo at gmail.com; Xinliang David Li; junbuml at codeaurora.org; llvm-commits; Adrian Prantl; Robinson, Paul; Greg Bedwell
Subject: Re: [PATCH] D25435: Generate more debug info in -gmlt

We had a couple of suggestions in the other thread

 -femit-debug-for-profiling (Greg's)
-fprof-debug (mine)

(+ a few debug folks and folks from the other thread, in case they've got ideas)

Any others people want to float/advocate for?
On Tue, Nov 29, 2016 at 11:39 AM Dehao Chen <dehao at google.com<mailto:dehao at google.com>> wrote:
Any recommendation on the flag names?

Thanks,
Dehao

On Tue, Nov 29, 2016 at 11:33 AM, David Blaikie via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
That doesn't seem like the best/most descriptive/most forwards-compatible name for the flag.

This seems like it's specifically about providing more information for profiling, by naming it in such a way that describes that use case it'll hopefully be easier for users to know when to use it and for us to know what should be triggered by that flag and what shouldn't.

- Dave

On Tue, Nov 29, 2016 at 11:21 AM Dehao Chen via Phabricator <reviews at reviews.llvm.org<mailto:reviews at reviews.llvm.org>> wrote:
danielcdh updated this revision to Diff 79609.
danielcdh added a comment.

Add -femit-accurate-debug-info flag to guard the change.


https://reviews.llvm.org/D25435

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===================================================================
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -469,3 +469,8 @@
 // CHECK-WCHAR2: -fshort-wchar
 // CHECK-WCHAR2-NOT: -fno-short-wchar
 // DELIMITERS: {{^ *"}}
+
+// RUN: %clang -### -S -fno-emit-accurate-debug-info -femit-accurate-debug-info %s 2>&1 | FileCheck -check-prefix=CHECK-EMIT-ACCURATE-DEBUG-INFO %s
+// RUN: %clang -### -S -femit-accurate-debug-info -fno-emit-accurate-debug-info %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EMIT-ACCURATE-DEBUG-INFO %s
+// CHECK-EMIT-ACCURATE-DEBUG-INFO: -femit-accurate-debug-info
+// CHECK-NO-EMIT-ACCURATE-DEBUG-INFO-NOT: -femit-accurate-debug-info
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -538,6 +538,8 @@
   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.EmitAccurateDebugInfo = Args.hasFlag(
+      OPT_femit_accurate_debug_info, OPT_fno_emit_accurate_debug_info, false);

   setPGOInstrumentor(Opts, Args, Diags);
   Opts.InstrProfileOutput =
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5508,6 +5508,10 @@
       A->render(Args, CmdArgs);
   }

+  if (Args.hasFlag(options::OPT_femit_accurate_debug_info,
+                   options::OPT_fno_emit_accurate_debug_info, false))
+    CmdArgs.push_back("-femit-accurate-debug-info");
+
   // -fbuiltin is default unless -mkernel is used.
   bool UseBuiltins =
       Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin,
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2739,9 +2739,11 @@
   }
   // 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 accurate debug info is
+  // needed.
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
                               !CGM.getCodeGenOpts().EmitGcovNotes &&
+                              !CGM.getCodeGenOpts().EmitAccurateDebugInfo &&
                               DebugKind <= codegenoptions::DebugLineTablesOnly))
     LinkageName = StringRef();

Index: include/clang/Frontend/CodeGenOptions.def
===================================================================
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -256,6 +256,9 @@
 /// Whether copy relocations support is available when building as PIE.
 CODEGENOPT(PIECopyRelocations, 1, 0)

+/// Whether emit more accurate debug info for sample pgo profile collection.
+CODEGENOPT(EmitAccurateDebugInfo, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -509,6 +509,12 @@
     HelpText<"Enable sample-based profile guided optimizations">;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
     Alias<fprofile_sample_use_EQ>;
+def femit_accurate_debug_info : Flag<["-"], "femit-accurate-debug-info">,
+    Group<f_Group>, Flags<[CC1Option]>,
+    HelpText<"Emit accurate debug info to make sample profile more accurate.">;
+def fno_emit_accurate_debug_info : Flag<["-"], "fno-emit-accurate-debug-info">,
+    Group<f_Group>, Flags<[DriverOption]>,
+    HelpText<"Do not emit accurate debug info.">;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
     Group<f_Group>, Flags<[DriverOption]>,
     HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overriden by '=' form of option or LLVM_PROFILE_FILE env var)">;


_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161129/65423a10/attachment.html>


More information about the llvm-commits mailing list