aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-01-26 22:44:49 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-01-26 22:44:49 +0100
commitf7c06c0f9955a6d12dd7eaef040de563fe279166 (patch)
tree1f43f54af8acabd8d284a7ddcd24f5708f9f1963 /gcc
parent5d93da1d112c93b38b6c68e3c51e20daefc01423 (diff)
downloadgcc-f7c06c0f9955a6d12dd7eaef040de563fe279166.zip
gcc-f7c06c0f9955a6d12dd7eaef040de563fe279166.tar.gz
gcc-f7c06c0f9955a6d12dd7eaef040de563fe279166.tar.bz2
re PR debug/78835 (ICE with -fdebug-types-section and member function)
PR debug/78835 * dwarf2out.c (prune_unused_types): Mark all functions with DIEs which have direct callers with -fvar-tracking-assignments enabled in the current TU. (resolve_addr): Avoid adding skeleton DIEs for DW_AT_call_origin inside of type units. * g++.dg/debug/dwarf2/pr78835.C: New test. From-SVN: r244954
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/dwarf2out.c50
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/pr78835.C11
4 files changed, 65 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 311e064..553cf5e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2017-01-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/78835
+ * dwarf2out.c (prune_unused_types): Mark all functions with DIEs
+ which have direct callers with -fvar-tracking-assignments enabled
+ in the current TU.
+ (resolve_addr): Avoid adding skeleton DIEs for DW_AT_call_origin
+ inside of type units.
+
2017-01-26 Martin Sebor <msebor@redhat.com>
PR middle-end/78703
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 4656570..f69c588 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -27793,6 +27793,25 @@ prune_unused_types (void)
for (i = 0; base_types.iterate (i, &base_type); i++)
prune_unused_types_mark (base_type, 1);
+ /* For -fvar-tracking-assignments, also set the mark on nodes that could be
+ referenced by DW_TAG_call_site DW_AT_call_origin (i.e. direct call
+ callees). */
+ cgraph_node *cnode;
+ FOR_EACH_FUNCTION (cnode)
+ if (cnode->referred_to_p (false))
+ {
+ dw_die_ref die = lookup_decl_die (cnode->decl);
+ if (die == NULL || die->die_mark)
+ continue;
+ for (cgraph_edge *e = cnode->callers; e; e = e->next_caller)
+ if (e->caller != cnode
+ && opt_for_fn (e->caller->decl, flag_var_tracking_assignments))
+ {
+ prune_unused_types_mark (die, 1);
+ break;
+ }
+ }
+
if (debug_str_hash)
debug_str_hash->empty ();
if (skeleton_debug_str_hash)
@@ -28694,16 +28713,27 @@ resolve_addr (dw_die_ref die)
&& DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE
&& (cdie = lookup_context_die (DECL_CONTEXT (tdecl))))
{
- /* Creating a full DIE for tdecl is overly expensive and
- at this point even wrong when in the LTO phase
- as it can end up generating new type DIEs we didn't
- output and thus optimize_external_refs will crash. */
- tdie = new_die (DW_TAG_subprogram, cdie, NULL_TREE);
- add_AT_flag (tdie, DW_AT_external, 1);
- add_AT_flag (tdie, DW_AT_declaration, 1);
- add_linkage_attr (tdie, tdecl);
- add_name_and_src_coords_attributes (tdie, tdecl);
- equate_decl_number_to_die (tdecl, tdie);
+ dw_die_ref pdie = cdie;
+ /* Make sure we don't add these DIEs into type units.
+ We could emit skeleton DIEs for context (namespaces,
+ outer structs/classes) and a skeleton DIE for the
+ innermost context with DW_AT_signature pointing to the
+ type unit. See PR78835. */
+ while (pdie && pdie->die_tag != DW_TAG_type_unit)
+ pdie = pdie->die_parent;
+ if (pdie == NULL)
+ {
+ /* Creating a full DIE for tdecl is overly expensive and
+ at this point even wrong when in the LTO phase
+ as it can end up generating new type DIEs we didn't
+ output and thus optimize_external_refs will crash. */
+ tdie = new_die (DW_TAG_subprogram, cdie, NULL_TREE);
+ add_AT_flag (tdie, DW_AT_external, 1);
+ add_AT_flag (tdie, DW_AT_declaration, 1);
+ add_linkage_attr (tdie, tdecl);
+ add_name_and_src_coords_attributes (tdie, tdecl);
+ equate_decl_number_to_die (tdecl, tdie);
+ }
}
if (tdie)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a96fb1d..bec6f15 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-01-26 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/78835
+ * g++.dg/debug/dwarf2/pr78835.C: New test.
+
2017-01-26 Martin Sebor <msebor@redhat.com>
PR middle-end/78703
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr78835.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr78835.C
new file mode 100644
index 0000000..0b54639
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr78835.C
@@ -0,0 +1,11 @@
+/* PR debug/78835 */
+/* { dg-do compile } */
+/* { dg-options "-gdwarf-4 -O2 -fdebug-types-section" } */
+
+struct A { void foo (); };
+
+void
+bar (A &x)
+{
+ x.foo ();
+}