This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [google/gcc-4_9] Fix -ftwo-level-line-tables to output non-inlined subprogram info


ok.

Dehao

On Mon, Feb 23, 2015 at 11:02 AM, Cary Coutant <ccoutant@google.com> wrote:
> Minor changes to -ftwo-level-line-tables.
>
> This patch is for the google/gcc-4_9 branch.
>
> Originally, -ftwo-level-line-tables would output .subprog directives
> only for inlined subprograms, and not for non-inlined ones. This was
> to save space, on the assumption that the subprogram name for
> non-inlined subprograms is available from the symbol table, and line
> info can be reconstructed using the address obtained from there.
> Unfortunately, the decl_line attribute from the subprogram DIE cannot
> be reconstructed reliably, so if -gline-tables-only is given, and the
> subprogram DIE is not available, we have no way of getting the decl_line
> attribute for non-inlined subprograms.
>
> This patch changes -ftwo-level-line-tables to output .subprog directives
> for all subprograms, unless the new -fno-two-level-all-subprogs flag is
> used to revert to the old behavior (this is meant to be temporary flag
> while we're still experimenting with two-level line tables).
>
> The cost is about 7.5% additional space in -gline-tables-only output
> (after compression), or about 2 percentage points in a typical binary.
>
> This patch also clears the logicals table at the beginning of each
> function, to prevent reusing a logical from a previous function (which
> could happen when compiling both C1 and C2 constructors, for example).
>
> OK for google/gcc-4_9?
>
> -cary
>
>
> 2015-02-23  Cary Coutant  <ccoutant@google.com>
>
>         * common.opt (ftwo-level-all-subprogs): New option.
>         * dwarf2out.c (scan_blocks_for_inlined_calls): Add more info to
>         debugging output.
>         (dwarf2out_begin_function): Empty logicals table at start of
>         each function.
>         (out_logical_entry): Output subprogram directives for non-inlined
>         subprograms unless -fno-two-level-all-subprogs.
>
> Index: common.opt
> ===================================================================
> --- common.opt  (revision 220880)
> +++ common.opt  (working copy)
> @@ -1213,6 +1213,11 @@ fdwarf2-cfi-asm
>  Common Report Var(flag_dwarf2_cfi_asm) Init(HAVE_GAS_CFI_DIRECTIVE)
>  Enable CFI tables via GAS assembler directives.
>
> +ftwo-level-all-subprogs
> +Common Report Var(flag_two_level_all_subprogs) Init(1)
> +When generating two-level line tables in DWARF (experimental),
> +generate subprogram table entries for all functions.
> +
>  ftwo-level-line-tables
>  Common Report Var(flag_two_level_line_tables) Init(0)
>  Use two-level line tables in DWARF (experimental).
> Index: dwarf2out.c
> ===================================================================
> --- dwarf2out.c (revision 220880)
> +++ dwarf2out.c (working copy)
> @@ -21617,7 +21617,10 @@ scan_blocks_for_inlined_calls (tree bloc
>
>        for (i = 0; i < level; i++)
>         fprintf(stderr, "  ");
> -      fprintf (stderr, "SCAN: block %d, subprog %s", BLOCK_NUMBER (block), dwarf2_name (subprog->decl, 0));
> +      fprintf (stderr, "SCAN: [%p] block %d, subprog %s",
> +              (void *) block,
> +              BLOCK_NUMBER (block),
> +              dwarf2_name (subprog->decl, 0));
>        if (caller != NULL)
>         {
>           expanded_location loc = expand_location (caller_loc);
> @@ -21670,6 +21673,21 @@ scan_blocks_for_inlined_calls (tree bloc
>         subblock != NULL;
>         subblock = BLOCK_FRAGMENT_CHAIN (subblock))
>      {
> +#ifdef DEBUG_TWO_LEVEL
> +      if (level < 6)
> +       {
> +         unsigned int i;
> +
> +         for (i = 0; i < level; i++)
> +           fprintf(stderr, "  ");
> +         fprintf (stderr, "SCAN: [%p] block frag %d, origin %d\n",
> +                  (void *) subblock,
> +                  BLOCK_NUMBER (subblock),
> +                  (BLOCK_FRAGMENT_ORIGIN (subblock)
> +                   ? BLOCK_NUMBER (BLOCK_FRAGMENT_ORIGIN (subblock))
> +                   : -1));
> +       }
> +#endif
>        block_num = BLOCK_NUMBER (subblock);
>        slot = block_table->find_slot_with_hash (&block_num, (hashval_t) block_num, INSERT);
>        if (*slot == HTAB_EMPTY_ENTRY)
> @@ -21717,6 +21735,7 @@ dwarf2out_begin_function (tree fun)
>        subprog_entry *subprog;
>
>        block_table->empty ();
> +      logical_table->empty ();
>  #ifdef DEBUG_TWO_LEVEL
>        fprintf (stderr, "Begin function %s\n", dwarf2_name (fun, 0));
>  #endif
> @@ -21862,7 +21881,8 @@ out_logical_entry (dw_line_info_table *t
>    /* Declare the subprogram if it hasn't already been declared.  */
>    if (block != NULL)
>      subprog = block->subprog;
> -  if (subprog != NULL && subprog->subprog_num == 0 && context != NULL)
> +  if (subprog != NULL && subprog->subprog_num == 0
> +      && (context != NULL || flag_two_level_all_subprogs))
>      out_subprog_directive (subprog);
>    if (subprog != NULL)
>      subprog_num = subprog->subprog_num;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]