On Tue, Mar 3, 2015 at 11:25 AM, Cary Coutant <ccout...@google.com> wrote: > This patch is for the google/gcc-4_9 branch. > > With this patch, we output an empty name for non-inlined functions, > and change the -ftwo-level-all-subprogs option to override this > behavior to output linkage names instead. The consumer can obtain > the linkage name for non-inlined functions from the ELF symbol table, > so we can save quite a bit of space in the line tables by omitting > those names. > > This patch also fixes a case where we output the linkage name for > a clone rather than for the ultimate origin. > > OK for google/gcc-4_9? > > -cary > > > 2015-03-03 Cary Coutant <ccout...@google.com> > > * common.opt (ftwo-level-all-subprogs): Default to off; > update help text. > * dwarf2out.c (add_subprog_entry): Clear subprog_num if the > subprogram is inlined, but was already output as non-inlined. > (out_subprog_directive): Get name from decl_ultimate_origin. > Output empty name for non-inlined subprograms. > (out_logical_entry): Output subprog entries for all subprograms. > > Index: common.opt > =================================================================== > --- common.opt (revision 221069) > +++ common.opt (working copy) > @@ -1214,9 +1214,9 @@ Common Report Var(flag_dwarf2_cfi_asm) I > Enable CFI tables via GAS assembler directives. > > ftwo-level-all-subprogs > -Common Report Var(flag_two_level_all_subprogs) Init(1) > +Common Report Var(flag_two_level_all_subprogs) Init(0) > When generating two-level line tables in DWARF (experimental), > -generate subprogram table entries for all functions. > +add linkage names for all functions (not just inlined functions). > > ftwo-level-line-tables > Common Report Var(flag_two_level_line_tables) Init(0) > Index: dwarf2out.c > =================================================================== > --- dwarf2out.c (revision 221069) > +++ dwarf2out.c (working copy) > @@ -21506,8 +21506,14 @@ add_subprog_entry (tree decl, bool is_in > entry->subprog_num = 0; > *slot = entry; > } > - else if (is_inlined) > - (*slot)->is_inlined = true; > + else if (is_inlined && !(*slot)->is_inlined) > + { > + /* If we've already output this subprogram entry as a non-inlined > + subprogram, make sure it gets output again, so that we include > + its linkage name. */ > + (*slot)->is_inlined = true; > + (*slot)->subprog_num = 0; > + } > return *slot; > } > > @@ -21817,22 +21823,39 @@ out_subprog_directive (subprog_entry *su > { > tree decl = subprog->decl; > tree decl_name = DECL_NAME (decl); > - const char *name; > + tree origin;
Explicitly initialize origin to NULL_TREE; > + const char *name = NULL; > unsigned int file_num = 0; > unsigned int line_num = 0; > > if (decl_name == NULL || IDENTIFIER_POINTER (decl_name) == NULL) > return; > > - /* For inlined subroutines, use the linkage name. */ > - if (subprog->is_inlined && DECL_ASSEMBLER_NAME (decl)) > + origin = decl_ultimate_origin (decl); > + if (origin == NULL_TREE) > + origin = decl; > + > + /* For inlined subroutines, use the linkage name. > + If -ftwo-level-all-subprogs is set, use the linkage name > + for all subroutines. */ > + if (subprog->is_inlined || flag_two_level_all_subprogs) > { > - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); > - if (name[0] == '*') > - name++; > + if (DECL_ASSEMBLER_NAME (origin)) > + { > + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (origin)); > + if (name[0] == '*') > + name++; > + } > + else > + name = dwarf2_name (origin, 0); > } > else > - name = dwarf2_name (decl, 0); > + { > + /* To save space, we don't emit the name for non-inlined > + subroutines, whose linkage names are available from the > + object file's symbol table. */ flag_two_level_all_subprogs will be 1 by default. This mean "else" branch is not the default behavior? Dehao > + name = ""; > + } > > if (LOCATION_LOCUS (DECL_SOURCE_LOCATION (decl)) != UNKNOWN_LOCATION) > { > @@ -21881,8 +21904,7 @@ 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 || flag_two_level_all_subprogs)) > + if (subprog != NULL && subprog->subprog_num == 0) > out_subprog_directive (subprog); > if (subprog != NULL) > subprog_num = subprog->subprog_num;