diff mbox

[google] Add option to emit mapping between module/function id and function name (issue8211043)

Message ID 20130331064414.0F4C2807B2@tjsboxrox.mtv.corp.google.com
State New
Headers show

Commit Message

Teresa Johnson March 31, 2013, 6:44 a.m. UTC
This patch restores part of r196176, which was subsequently reverted
due to issues with the other part of that patch that dealt with
module info updates. This patch restores the option -femit-function-names
to emit to stderr the mapping from module name/function id to function
assembler name. This enables mapping the function ids in the gcda
dump files to the symbolic function name. This will work for LIPO builds
without the other part of that patch, which was needed for FDO builds,
and which needs to be revisited and fixed.

Tested by bootstrap and regression testing. Ok for google-4_7?

2013-03-30  Teresa Johnson  <tejohnson@google.com>

	* tree-profile.c (tree_profiling): Optionally call
        new function emit_function_name.
	* common.opt (flag_emit_function_names): New flag.
	* coverage.c (emit_function_name): New function.
	* coverage.h: Ditto.


--
This patch is available for review at http://codereview.appspot.com/8211043

Comments

Xinliang David Li March 31, 2013, 4:18 p.m. UTC | #1
ok.

thanks,

David

On Sat, Mar 30, 2013 at 11:44 PM, Teresa Johnson <tejohnson@google.com> wrote:
> This patch restores part of r196176, which was subsequently reverted
> due to issues with the other part of that patch that dealt with
> module info updates. This patch restores the option -femit-function-names
> to emit to stderr the mapping from module name/function id to function
> assembler name. This enables mapping the function ids in the gcda
> dump files to the symbolic function name. This will work for LIPO builds
> without the other part of that patch, which was needed for FDO builds,
> and which needs to be revisited and fixed.
>
> Tested by bootstrap and regression testing. Ok for google-4_7?
>
> 2013-03-30  Teresa Johnson  <tejohnson@google.com>
>
>         * tree-profile.c (tree_profiling): Optionally call
>         new function emit_function_name.
>         * common.opt (flag_emit_function_names): New flag.
>         * coverage.c (emit_function_name): New function.
>         * coverage.h: Ditto.
>
> Index: tree-profile.c
> ===================================================================
> --- tree-profile.c      (revision 197266)
> +++ tree-profile.c      (working copy)
> @@ -1557,6 +1557,9 @@ tree_profiling (void)
>        /* Re-set global shared temporary variable for edge-counters.  */
>        gcov_type_tmp_var = NULL_TREE;
>
> +      if (flag_emit_function_names)
> +        emit_function_name ();
> +
>        /* Local pure-const may imply need to fixup the cfg.  */
>        if (execute_fixup_cfg () & TODO_cleanup_cfg)
>         cleanup_tree_cfg ();
> Index: common.opt
> ===================================================================
> --- common.opt  (revision 197266)
> +++ common.opt  (working copy)
> @@ -1775,6 +1775,13 @@ fprofile-generate-sampling
>  Common Var(flag_profile_generate_sampling)
>  Turn on instrumentation sampling with -fprofile-generate with rate set by --param profile-generate-sampling-rate or environment variable GCOV_SAMPLING_RATE
>
> +femit-function-names
> +Common Var(flag_emit_function_names)
> +Print to stderr the mapping from module name and function id to assembler
> +function name when -ftest-coverage, -fprofile-generate or -fprofile-use are
> +active, for use in correlating function ids in gcda files with the function
> +name.
> +
>  fprofile-strip=
>  Common Joined RejectNegative Var(profile_base_name_suffix_to_strip)
>  Specify a substring to be stripped from the profile base file name
> Index: coverage.c
> ===================================================================
> --- coverage.c  (revision 197266)
> +++ coverage.c  (working copy)
> @@ -2085,6 +2085,19 @@ build_cl_args_array_value (tree string_type, VEC(c
>    return;
>  }
>
> +/* Emit mapping between module name and function id to the function's
> +   assembler name, for use in correlating function idents in the gcda file
> +   with the function name.  */
> +
> +void
> +emit_function_name (void)
> +{
> +  fprintf (stderr, "Module %s FuncId %u Name %s\n",
> +           main_input_file_name,
> +           FUNC_DECL_FUNC_ID (cfun),
> +           IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)));
> +}
> +
>  /* Returns the type of the module info associated with the
>     current source module being compiled.  */
>
> Index: coverage.h
> ===================================================================
> --- coverage.h  (revision 197266)
> +++ coverage.h  (working copy)
> @@ -75,6 +75,8 @@ extern void coverage_dc_end_function (void);
>     is present in the coverage internal data structures.  */
>  extern bool coverage_function_present (unsigned fn_ident);
>
> +extern void emit_function_name (void);
> +
>  /* True if there is PMU data present in this compilation. */
>  extern bool pmu_data_present (void);
>
>
> --
> This patch is available for review at http://codereview.appspot.com/8211043
diff mbox

Patch

Index: tree-profile.c
===================================================================
--- tree-profile.c	(revision 197266)
+++ tree-profile.c	(working copy)
@@ -1557,6 +1557,9 @@  tree_profiling (void)
       /* Re-set global shared temporary variable for edge-counters.  */
       gcov_type_tmp_var = NULL_TREE;
 
+      if (flag_emit_function_names)
+        emit_function_name ();
+
       /* Local pure-const may imply need to fixup the cfg.  */
       if (execute_fixup_cfg () & TODO_cleanup_cfg)
 	cleanup_tree_cfg ();
Index: common.opt
===================================================================
--- common.opt	(revision 197266)
+++ common.opt	(working copy)
@@ -1775,6 +1775,13 @@  fprofile-generate-sampling
 Common Var(flag_profile_generate_sampling)
 Turn on instrumentation sampling with -fprofile-generate with rate set by --param profile-generate-sampling-rate or environment variable GCOV_SAMPLING_RATE
 
+femit-function-names
+Common Var(flag_emit_function_names)
+Print to stderr the mapping from module name and function id to assembler
+function name when -ftest-coverage, -fprofile-generate or -fprofile-use are
+active, for use in correlating function ids in gcda files with the function
+name.
+
 fprofile-strip=
 Common Joined RejectNegative Var(profile_base_name_suffix_to_strip)
 Specify a substring to be stripped from the profile base file name
Index: coverage.c
===================================================================
--- coverage.c	(revision 197266)
+++ coverage.c	(working copy)
@@ -2085,6 +2085,19 @@  build_cl_args_array_value (tree string_type, VEC(c
   return;
 }
 
+/* Emit mapping between module name and function id to the function's
+   assembler name, for use in correlating function idents in the gcda file
+   with the function name.  */
+
+void
+emit_function_name (void)
+{
+  fprintf (stderr, "Module %s FuncId %u Name %s\n",
+           main_input_file_name,
+           FUNC_DECL_FUNC_ID (cfun),
+           IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)));
+}
+
 /* Returns the type of the module info associated with the
    current source module being compiled.  */
 
Index: coverage.h
===================================================================
--- coverage.h	(revision 197266)
+++ coverage.h	(working copy)
@@ -75,6 +75,8 @@  extern void coverage_dc_end_function (void);
    is present in the coverage internal data structures.  */
 extern bool coverage_function_present (unsigned fn_ident);
 
+extern void emit_function_name (void);
+
 /* True if there is PMU data present in this compilation. */
 extern bool pmu_data_present (void);