This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82054] [8 Regression] ICE in add_dwarf_attr with -fopenmp and -g
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 31 Aug 2017 08:32:11 +0000
- Subject: [Bug c++/82054] [8 Regression] ICE in add_dwarf_attr with -fopenmp and -g
- Auto-submitted: auto-generated
- References: <bug-82054-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82054
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmpf, that DW_AT_object_pointer thing is tricky ;) Ah... first generated by
#6 0x000000000101629a in expand_omp_taskreg (region=0x2c19ab0)
at /tmp/trunk2/gcc/omp-expand.c:1313
1313 (*debug_hooks->early_global_decl) (cfun->decl);
(gdb) l
1308 block = gimple_block (entry_stmt);
1309
1310 /* Make sure to generate early debug for the function before
1311 outlining anything. */
1312 if (! gimple_in_ssa_p (cfun))
1313 (*debug_hooks->early_global_decl) (cfun->decl);
and then again via
#6 0x0000000000c72825 in symbol_table::finalize_compilation_unit (
this=0x7ffff6895100) at /tmp/trunk2/gcc/cgraphunit.c:2623
2623 (*debug_hooks->early_global_decl) (cnode->decl);
(gdb) l
2618 {
2619 /* Emit early debug for reachable functions, and by consequence,
2620 locally scoped symbols. */
2621 struct cgraph_node *cnode;
2622 FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
2623 (*debug_hooks->early_global_decl) (cnode->decl);
The following resolves this, testing in progress.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 251553)
+++ gcc/dwarf2out.c (working copy)
@@ -25492,9 +25492,10 @@ dwarf2out_early_global_decl (tree decl)
if (TREE_CODE (decl) != TYPE_DECL
&& TREE_CODE (decl) != PARM_DECL)
{
- tree save_fndecl = current_function_decl;
if (TREE_CODE (decl) == FUNCTION_DECL)
{
+ tree save_fndecl = current_function_decl;
+
/* For nested functions, make sure we have DIEs for the parents first
so that all nested DIEs are generated at the proper scope in the
first shot. */
@@ -25521,11 +25522,19 @@ dwarf2out_early_global_decl (tree decl)
dwarf2out_decl (origin);
}
- current_function_decl = decl;
+ /* Emit the DIE for decl but avoid doing that multiple times. */
+ dw_die_ref old_die;
+ if ((old_die = lookup_decl_die (decl)) == NULL
+ || is_declaration_die (old_die))
+ {
+ current_function_decl = decl;
+ dwarf2out_decl (decl);
+ }
+
+ current_function_decl = save_fndecl;
}
- dwarf2out_decl (decl);
- if (TREE_CODE (decl) == FUNCTION_DECL)
- current_function_decl = save_fndecl;
+ else
+ dwarf2out_decl (decl);
}
symtab->global_info_ready = save;
}