diff options
author | Richard Biener <rguenther@suse.de> | 2018-09-27 14:10:45 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-09-27 14:10:45 +0000 |
commit | ac02e5b75451cc3c6ae9028338183bcdcb056ea2 (patch) | |
tree | c7fd269bf115c497c78df6904016cfb257f1da20 /gcc/dwarf2out.c | |
parent | 19ef5a8fd5710a197ddeaafc2c69ff77217fece5 (diff) | |
download | gcc-ac02e5b75451cc3c6ae9028338183bcdcb056ea2.zip gcc-ac02e5b75451cc3c6ae9028338183bcdcb056ea2.tar.gz gcc-ac02e5b75451cc3c6ae9028338183bcdcb056ea2.tar.bz2 |
re PR debug/37801 (DWARF output for inlined functions doesn't always use DW_TAG_inlined_subroutine)
2018-09-27 Richard Biener <rguenther@suse.de>
PR debug/37801
PR debug/87440
* dwarf2out.c (set_block_origin_self): Do not mark outermost
block as we do not output that.
(gen_inlined_subroutine_die): Elide the originally outermost
block, matching what we do for concrete instances.
(decls_for_scope): Add parameter specifying whether to recurse
to subblocks.
* gcc.dg/debug/dwarf2/inline2.c: Adjust.
* gcc.dg/debug/dwarf2/inline4.c: New testcase.
From-SVN: r264667
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r-- | gcc/dwarf2out.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index b0c5c4f..a63a645 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -3867,7 +3867,7 @@ static void gen_subroutine_type_die (tree, dw_die_ref); static void gen_typedef_die (tree, dw_die_ref); static void gen_type_die (tree, dw_die_ref); static void gen_block_die (tree, dw_die_ref); -static void decls_for_scope (tree, dw_die_ref); +static void decls_for_scope (tree, dw_die_ref, bool = true); static bool is_naming_typedef_decl (const_tree); static inline dw_die_ref get_context_die (tree); static void gen_namespace_die (tree, dw_die_ref); @@ -24147,7 +24147,23 @@ gen_inlined_subroutine_die (tree stmt, dw_die_ref context_die) add_high_low_attributes (stmt, subr_die); add_call_src_coords_attributes (stmt, subr_die); - decls_for_scope (stmt, subr_die); + /* The inliner creates an extra BLOCK for the parameter setup, + we want to merge that with the actual outermost BLOCK of the + inlined function to avoid duplicate locals in consumers. + Do that by doing the recursion to subblocks on the single subblock + of STMT. */ + bool unwrap_one = false; + if (BLOCK_SUBBLOCKS (stmt) && !BLOCK_CHAIN (BLOCK_SUBBLOCKS (stmt))) + { + tree origin = block_ultimate_origin (BLOCK_SUBBLOCKS (stmt)); + if (origin + && TREE_CODE (origin) == BLOCK + && BLOCK_SUPERCONTEXT (origin) == decl) + unwrap_one = true; + } + decls_for_scope (stmt, subr_die, !unwrap_one); + if (unwrap_one) + decls_for_scope (BLOCK_SUBBLOCKS (stmt), subr_die); } } @@ -25775,7 +25791,7 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die) all of its sub-blocks. */ static void -decls_for_scope (tree stmt, dw_die_ref context_die) +decls_for_scope (tree stmt, dw_die_ref context_die, bool recurse) { tree decl; unsigned int i; @@ -25818,10 +25834,11 @@ decls_for_scope (tree stmt, dw_die_ref context_die) /* Output the DIEs to represent all sub-blocks (and the items declared therein) of this block. */ - for (subblocks = BLOCK_SUBBLOCKS (stmt); - subblocks != NULL; - subblocks = BLOCK_CHAIN (subblocks)) - gen_block_die (subblocks, context_die); + if (recurse) + for (subblocks = BLOCK_SUBBLOCKS (stmt); + subblocks != NULL; + subblocks = BLOCK_CHAIN (subblocks)) + gen_block_die (subblocks, context_die); } /* Is this a typedef we can avoid emitting? */ |