From: Cary Coutant <ccoutant@google.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Jim Wilson <wilson@codesourcery.com>, Jason Merrill <jason@redhat.com>
Subject: [patch] Fix two bugs with -gdwarf-4
Date: Tue, 22 Jun 2010 04:27:00 -0000 [thread overview]
Message-ID: <AANLkTilGVXqJAphOrs7BMfJ1YBgOVq7c5a_BuY4ncR62@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 673 bytes --]
This patch fixes a couple of bugs with -gdwarf-4. One is an ICE that
occurs when there's a particular kind of local typedef in a member
function, and the other caused an unsatisfied reference at link time
caused by moving a locally-scoped type into a type unit.
Bootstrapped and tested on x86_64. OK?
-cary
gcc/ChangeLog:
* dwarf2out.c (is_nested_in_subprogram): New function.
(should_move_die_to_comdat): Use it.
(copy_ancestor_tree): Don't mark DIEs here.
(copy_decls_walk): Start walk from root of newly-added tree;
mark DIEs here instead.
gcc/testsuite/ChangeLog:
* g++.dg/debug/dwarf2/dwarf4-typedef.C: New test.
[-- Attachment #2: gcc-dwarf4-100621-patch.txt --]
[-- Type: text/plain, Size: 2856 bytes --]
Index: testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C
===================================================================
--- testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C (revision 0)
+++ testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C (revision 0)
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-gdwarf-4" } */
+
+/* Regression test for an ICE in output_die when using -gdwarf-4. */
+
+namespace {
+
+struct A {
+ virtual ~A();
+};
+
+struct B : public A {
+ template <typename A>
+ bool foo(A x[2]) { }
+};
+
+template <typename T>
+struct C {
+ T v[2];
+};
+
+template <typename T>
+bool X(T &b) {
+ typedef C<int> D;
+ D x[2];
+ return b.foo(x);
+}
+
+void f() {
+ B b;
+ X<B>(b);
+}
+
+}
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 161107)
+++ dwarf2out.c (working copy)
@@ -9630,6 +9630,18 @@ is_declaration_die (dw_die_ref die)
return 0;
}
+/* Return non-zero if this DIE is nested inside a subprogram. */
+
+static int
+is_nested_in_subprogram (dw_die_ref die)
+{
+ dw_die_ref decl = get_AT_ref (die, DW_AT_specification);
+
+ if (decl == NULL)
+ decl = die;
+ return local_scope_p (decl);
+}
+
/* Return non-zero if this is a type DIE that should be moved to a
COMDAT .debug_types section. */
@@ -9642,8 +9654,11 @@ should_move_die_to_comdat (dw_die_ref di
case DW_TAG_structure_type:
case DW_TAG_enumeration_type:
case DW_TAG_union_type:
- /* Don't move declarations or inlined instances. */
- if (is_declaration_die (die) || get_AT (die, DW_AT_abstract_origin))
+ /* Don't move declarations, inlined instances, or types nested in a
+ subprogram. */
+ if (is_declaration_die (die)
+ || get_AT (die, DW_AT_abstract_origin)
+ || is_nested_in_subprogram (die))
return 0;
return 1;
case DW_TAG_array_type:
@@ -10055,8 +10070,6 @@ copy_ancestor_tree (dw_die_ref unit, dw_
if (decl_table != NULL)
{
- /* Make sure the copy is marked as part of the type unit. */
- copy->die_mark = 1;
/* Record the pointer to the copy. */
entry->copy = copy;
}
@@ -10130,7 +10143,18 @@ copy_decls_walk (dw_die_ref unit, dw_die
installed in a previously-added context, it won't
get visited otherwise. */
if (parent != unit)
- copy_decls_walk (unit, parent, decl_table);
+ {
+ /* Find the highest point of the newly-added tree,
+ mark each node along the way, and walk from there. */
+ parent->die_mark = 1;
+ while (parent->die_parent
+ && parent->die_parent->die_mark == 0)
+ {
+ parent = parent->die_parent;
+ parent->die_mark = 1;
+ }
+ copy_decls_walk (unit, parent, decl_table);
+ }
}
}
}
next reply other threads:[~2010-06-22 0:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-22 4:27 Cary Coutant [this message]
2010-06-22 7:03 ` Jason Merrill
2010-06-22 18:26 ` Cary Coutant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTilGVXqJAphOrs7BMfJ1YBgOVq7c5a_BuY4ncR62@mail.gmail.com \
--to=ccoutant@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=wilson@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).