* Fix for PR debug/PR46973
@ 2010-12-16 10:30 Dodji Seketeli
2010-12-16 21:49 ` Jason Merrill
0 siblings, 1 reply; 3+ messages in thread
From: Dodji Seketeli @ 2010-12-16 10:30 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches
Hello,
In the example of the patch below the type that is used
Base<long, 47, &a_global, &S::f>::Inner<float> so its
DW_TAG_structure_type is marked as used and is eventually emitted.
The parent DW_TAG_structure_type DIE of Base<long, 47, &a_global,
&S::f> is also rightfully marked as used by
prune_unused_types_mark. The problem is the
DW_TAG_template_type_param and DW_TAG_template_value_param
children DIEs are not marked as used so they are not emitted. As
these DIEs are necessary to fully describe the name of a type, I
think they should be treated by prune_unused_types_mark as it
treats nodes referenced by attributes.
The patch below marks the template parameters and argument related
children DIEs.
Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.
--
Dodji
commit b13e7d25b5f0a7e9fdd587ca2c5a2ca17aae3628
Author: Dodji Seketeli <dodji@redhat.com>
Date: Wed Dec 15 23:30:30 2010 +0100
Fix PR debug/PR46973
gcc/
* dwarf2out.c (prune_unused_types_mark_generic_parms_dies): New
static function.
(prune_unused_types_mark): Use it.
gcc/testsuite/
* g++.dg/debug/dwarf2/template-params-9.C: New test.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c985527..4097358 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -6477,6 +6477,7 @@ static void output_loc_list (dw_loc_list_ref);
static char *gen_internal_sym (const char *);
static void prune_unmark_dies (dw_die_ref);
+static void prune_unused_types_mark_generic_parms_dies (dw_die_ref);
static void prune_unused_types_mark (dw_die_ref, int);
static void prune_unused_types_walk (dw_die_ref);
static void prune_unused_types_walk_attribs (dw_die_ref);
@@ -22126,6 +22127,32 @@ prune_unused_types_walk_attribs (dw_die_ref die)
}
}
+/* Mark the generic parameters and arguments children DIEs of DIE. */
+
+static void
+prune_unused_types_mark_generic_parms_dies (dw_die_ref die)
+{
+ dw_die_ref c;
+
+ if (die == NULL || die->die_child == NULL)
+ return;
+ c = die->die_child;
+ do
+ {
+ switch (c->die_tag)
+ {
+ case DW_TAG_template_type_param:
+ case DW_TAG_template_value_param:
+ case DW_TAG_GNU_template_template_param:
+ case DW_TAG_GNU_template_parameter_pack:
+ prune_unused_types_mark (c, 1);
+ break;
+ default:
+ break;
+ }
+ c = c->die_sib;
+ } while (c && c != die->die_child);
+}
/* Mark DIE as being used. If DOKIDS is true, then walk down
to DIE's children. */
@@ -22139,6 +22166,10 @@ prune_unused_types_mark (dw_die_ref die, int dokids)
{
/* We haven't done this node yet. Mark it as used. */
die->die_mark = 1;
+ /* If this is the DIE of a generic type instantiation,
+ mark the children DIEs that describe its generic parms and
+ args. */
+ prune_unused_types_mark_generic_parms_dies (die);
/* We also have to mark its parents as used.
(But we don't want to mark our parents' kids due to this.) */
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-9.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-9.C
new file mode 100644
index 0000000..7af1d91
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-9.C
@@ -0,0 +1,28 @@
+// Origin PR debug/PR46973
+// { dg-options "-g -dA" }
+// { dg-do compile }
+
+struct S
+{
+ int f;
+};
+
+template<typename T, int I, int *P, int S::*MP>
+struct Base
+{
+ template<typename Z>
+ struct Inner
+ {
+ };
+};
+
+int a_global;
+
+int main ()
+{
+ Base<long, 47, &a_global, &S::f>::Inner<float> inner;
+ return 0;
+}
+
+// { dg-final { scan-assembler-times "DIE \\(\[^\n\r\]*\\) DW_TAG_template_type_param" 2 } }
+// { dg-final { scan-assembler-times "DIE \\(\[^\n\r\]*\\) DW_TAG_template_value_param" 3 } }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix for PR debug/PR46973
2010-12-16 10:30 Fix for PR debug/PR46973 Dodji Seketeli
@ 2010-12-16 21:49 ` Jason Merrill
2011-01-11 22:53 ` Dodji Seketeli
0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2010-12-16 21:49 UTC (permalink / raw)
To: Dodji Seketeli; +Cc: GCC Patches
OK. Do we also need this for function template args?
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fix for PR debug/PR46973
2010-12-16 21:49 ` Jason Merrill
@ 2011-01-11 22:53 ` Dodji Seketeli
0 siblings, 0 replies; 3+ messages in thread
From: Dodji Seketeli @ 2011-01-11 22:53 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches
Jason Merrill <jason@redhat.com> writes:
> OK. Do we also need this for function template args?
As cgraph tells dwarf2out what function to emit, it doesn't have to
prune functions (and their template args) like for types so I believe we
don't have the issue for them.
--
Dodji
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-11 22:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-16 10:30 Fix for PR debug/PR46973 Dodji Seketeli
2010-12-16 21:49 ` Jason Merrill
2011-01-11 22:53 ` Dodji Seketeli
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).