public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] More early LTO dwarf2out bits
@ 2016-10-13  7:16 Richard Biener
  2017-09-19 13:56 ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Biener @ 2016-10-13  7:16 UTC (permalink / raw)
  To: gcc-patches


This merges a few more bits guarding stuff with ! early_dwarf, mostly
to avoid creating locations that involve addresses of decls early
but also to avoid wasting work for BLOCK_NONLOCALIZED_VARs.

Bootstrapped and tested on x86_64-unknown-linux-gnu, gdb testsuite
tested on the same arch (from the gdb 7.12 branch), applied to trunk.

Richard.

2016-10-13  Richard Biener  <rguenther@suse.de>

	* dwarf2out.c (tree_add_const_value_attribute): Do not try
	rtl_for_decl_init during early phase.
	(gen_variable_die): Do not create locations during early phase.
	(gen_label_die): Likewise.
	(decls_for_scope): Do not waste time handling BLOCK_NONLOCALIZED_VARs
	twice.

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 241022)
+++ gcc/dwarf2out.c	(working copy)
@@ -17958,12 +17958,15 @@ tree_add_const_value_attribute (dw_die_r
   init = t;
   gcc_assert (!DECL_P (init));
 
-  rtl = rtl_for_decl_init (init, type);
-  if (rtl)
-    return add_const_value_attribute (die, rtl);
+  if (! early_dwarf)
+    {
+      rtl = rtl_for_decl_init (init, type);
+      if (rtl)
+	return add_const_value_attribute (die, rtl);
+    }
   /* If the host and target are sane, try harder.  */
-  else if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
-	   && initializer_constant_valid_p (init, type))
+  if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
+      && initializer_constant_valid_p (init, type))
     {
       HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (init));
       if (size > 0 && (int) size == size)
@@ -21269,13 +21272,13 @@ gen_variable_die (tree decl, tree origin
   if (com_decl)
     {
       dw_die_ref com_die;
-      dw_loc_list_ref loc;
+      dw_loc_list_ref loc = NULL;
       die_node com_die_arg;
 
       var_die = lookup_decl_die (decl_or_origin);
       if (var_die)
 	{
-	  if (get_AT (var_die, DW_AT_location) == NULL)
+	  if (! early_dwarf && get_AT (var_die, DW_AT_location) == NULL)
 	    {
 	      loc = loc_list_from_tree (com_decl, off ? 1 : 2, NULL);
 	      if (loc)
@@ -21309,7 +21312,8 @@ gen_variable_die (tree decl, tree origin
       com_die_arg.decl_id = DECL_UID (com_decl);
       com_die_arg.die_parent = context_die;
       com_die = common_block_die_table->find (&com_die_arg);
-      loc = loc_list_from_tree (com_decl, 2, NULL);
+      if (! early_dwarf)
+	loc = loc_list_from_tree (com_decl, 2, NULL);
       if (com_die == NULL)
 	{
 	  const char *cnam
@@ -21550,7 +21554,7 @@ gen_label_die (tree decl, dw_die_ref con
 
   if (DECL_ABSTRACT_P (decl))
     equate_decl_number_to_die (decl, lbl_die);
-  else
+  else if (! early_dwarf)
     {
       insn = DECL_RTL_IF_SET (decl);
 
@@ -23327,9 +23331,13 @@ decls_for_scope (tree stmt, dw_die_ref c
     {
       for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl))
 	process_scope_var (stmt, decl, NULL_TREE, context_die);
-      for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
-	process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i),
-			   context_die);
+      /* BLOCK_NONLOCALIZED_VARs simply generate DIE stubs with abstract
+	 origin - avoid doing this twice as we have no good way to see
+	 if we've done it once already.  */
+      if (! early_dwarf)
+	for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
+	  process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i),
+			     context_die);
     }
 
   /* Even if we're at -g1, we need to process the subblocks in order to get

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] More early LTO dwarf2out bits
  2016-10-13  7:16 [PATCH] More early LTO dwarf2out bits Richard Biener
@ 2017-09-19 13:56 ` Jakub Jelinek
  2017-09-19 14:09   ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2017-09-19 13:56 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Thu, Oct 13, 2016 at 09:16:07AM +0200, Richard Biener wrote:
> 
> This merges a few more bits guarding stuff with ! early_dwarf, mostly
> to avoid creating locations that involve addresses of decls early
> but also to avoid wasting work for BLOCK_NONLOCALIZED_VARs.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, gdb testsuite
> tested on the same arch (from the gdb 7.12 branch), applied to trunk.
> 
> Richard.
> 
> 2016-10-13  Richard Biener  <rguenther@suse.de>
> 
> 	* dwarf2out.c (tree_add_const_value_attribute): Do not try
> 	rtl_for_decl_init during early phase.
> 	(gen_variable_die): Do not create locations during early phase.
> 	(gen_label_die): Likewise.
> 	(decls_for_scope): Do not waste time handling BLOCK_NONLOCALIZED_VARs
> 	twice.

As Martin reported, this has very undesirable effect on the size of DWARF
debug info.

The problem is that add_const_value_attribute has lots of smarts to handle
various kinds of constants, which the
  if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
      && initializer_constant_valid_p (init, type))
block doesn't implement, it relies on all the smarts to be done earlier.
One option is to duplicate that all on trees, another option is
to use the rtl_for_decl_init + add_const_value_attribute way
even for early_dwarf for constants, something like:

-  if (! early_dwarf)
+  if (! early_dwarf || CONSTANT_CLASS_P (init))
     {
       rtl = rtl_for_decl_init (init, type);
       if (rtl)
 	return add_const_value_attribute (die, rtl);
     }
   if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
       && initializer_constant_valid_p (init, type))

For the duplicate on trees, some cases might not be that hard, like
handling of INTEGER_CSTs, just see if they are negative and fit into shwi,
(then add_AT_int), or fit into uhwi (then add_AT_unsigned); maybe that
would be enough for now.

> --- gcc/dwarf2out.c	(revision 241022)
> +++ gcc/dwarf2out.c	(working copy)
> @@ -17958,12 +17958,15 @@ tree_add_const_value_attribute (dw_die_r
>    init = t;
>    gcc_assert (!DECL_P (init));
>  
> -  rtl = rtl_for_decl_init (init, type);
> -  if (rtl)
> -    return add_const_value_attribute (die, rtl);
> +  if (! early_dwarf)
> +    {
> +      rtl = rtl_for_decl_init (init, type);
> +      if (rtl)
> +	return add_const_value_attribute (die, rtl);
> +    }
>    /* If the host and target are sane, try harder.  */
> -  else if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
> -	   && initializer_constant_valid_p (init, type))
> +  if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
> +      && initializer_constant_valid_p (init, type))
>      {
>        HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (init));
>        if (size > 0 && (int) size == size)

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] More early LTO dwarf2out bits
  2017-09-19 13:56 ` Jakub Jelinek
@ 2017-09-19 14:09   ` Richard Biener
  2017-09-19 14:12     ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Biener @ 2017-09-19 14:09 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 19 Sep 2017, Jakub Jelinek wrote:

> On Thu, Oct 13, 2016 at 09:16:07AM +0200, Richard Biener wrote:
> > 
> > This merges a few more bits guarding stuff with ! early_dwarf, mostly
> > to avoid creating locations that involve addresses of decls early
> > but also to avoid wasting work for BLOCK_NONLOCALIZED_VARs.
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, gdb testsuite
> > tested on the same arch (from the gdb 7.12 branch), applied to trunk.
> > 
> > Richard.
> > 
> > 2016-10-13  Richard Biener  <rguenther@suse.de>
> > 
> > 	* dwarf2out.c (tree_add_const_value_attribute): Do not try
> > 	rtl_for_decl_init during early phase.
> > 	(gen_variable_die): Do not create locations during early phase.
> > 	(gen_label_die): Likewise.
> > 	(decls_for_scope): Do not waste time handling BLOCK_NONLOCALIZED_VARs
> > 	twice.
> 
> As Martin reported, this has very undesirable effect on the size of DWARF
> debug info.
> 
> The problem is that add_const_value_attribute has lots of smarts to handle
> various kinds of constants, which the
>   if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
>       && initializer_constant_valid_p (init, type))
> block doesn't implement, it relies on all the smarts to be done earlier.
> One option is to duplicate that all on trees, another option is
> to use the rtl_for_decl_init + add_const_value_attribute way
> even for early_dwarf for constants, something like:
> 
> -  if (! early_dwarf)
> +  if (! early_dwarf || CONSTANT_CLASS_P (init))
>      {
>        rtl = rtl_for_decl_init (init, type);
>        if (rtl)
>  	return add_const_value_attribute (die, rtl);
>      }
>    if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
>        && initializer_constant_valid_p (init, type))

If we are sure that rtl_for_decl_init will never create symbol references
for CONSTANT_CLASS_P (init) that's fine, but yes, in the end it would be
nice to not have overlapping rtl/tree handling and have all constants
handled in the tree path...

Richard.

> For the duplicate on trees, some cases might not be that hard, like
> handling of INTEGER_CSTs, just see if they are negative and fit into shwi,
> (then add_AT_int), or fit into uhwi (then add_AT_unsigned); maybe that
> would be enough for now.
> 
> > --- gcc/dwarf2out.c	(revision 241022)
> > +++ gcc/dwarf2out.c	(working copy)
> > @@ -17958,12 +17958,15 @@ tree_add_const_value_attribute (dw_die_r
> >    init = t;
> >    gcc_assert (!DECL_P (init));
> >  
> > -  rtl = rtl_for_decl_init (init, type);
> > -  if (rtl)
> > -    return add_const_value_attribute (die, rtl);
> > +  if (! early_dwarf)
> > +    {
> > +      rtl = rtl_for_decl_init (init, type);
> > +      if (rtl)
> > +	return add_const_value_attribute (die, rtl);
> > +    }
> >    /* If the host and target are sane, try harder.  */
> > -  else if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
> > -	   && initializer_constant_valid_p (init, type))
> > +  if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
> > +      && initializer_constant_valid_p (init, type))
> >      {
> >        HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (init));
> >        if (size > 0 && (int) size == size)
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] More early LTO dwarf2out bits
  2017-09-19 14:09   ` Richard Biener
@ 2017-09-19 14:12     ` Jakub Jelinek
  2017-09-19 21:20       ` [PATCH] Improve DW_AT_const_value with early_dwarf Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2017-09-19 14:12 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Tue, Sep 19, 2017 at 04:09:20PM +0200, Richard Biener wrote:
> > The problem is that add_const_value_attribute has lots of smarts to handle
> > various kinds of constants, which the
> >   if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
> >       && initializer_constant_valid_p (init, type))
> > block doesn't implement, it relies on all the smarts to be done earlier.
> > One option is to duplicate that all on trees, another option is
> > to use the rtl_for_decl_init + add_const_value_attribute way
> > even for early_dwarf for constants, something like:
> > 
> > -  if (! early_dwarf)
> > +  if (! early_dwarf || CONSTANT_CLASS_P (init))
> >      {
> >        rtl = rtl_for_decl_init (init, type);
> >        if (rtl)
> >  	return add_const_value_attribute (die, rtl);
> >      }
> >    if (CHAR_BIT == 8 && BITS_PER_UNIT == 8
> >        && initializer_constant_valid_p (init, type))
> 
> If we are sure that rtl_for_decl_init will never create symbol references
> for CONSTANT_CLASS_P (init) that's fine, but yes, in the end it would be
> nice to not have overlapping rtl/tree handling and have all constants
> handled in the tree path...

Will try now following plus testcase, the rest of constants I believe end up
being DW_FORM_block encoded and so is pretty much what we emit even for the
initializer_constant_valid_p tree fallback case.

--- gcc/dwarf2out.c.jj	2017-09-15 18:11:03.000000000 +0200
+++ gcc/dwarf2out.c	2017-09-19 16:03:27.678337475 +0200
@@ -19440,6 +19440,19 @@ tree_add_const_value_attribute (dw_die_r
   init = t;
   gcc_assert (!DECL_P (init));
 
+  if (TREE_CODE (init) == INTEGER_CST)
+    {
+      if (tree_fits_uhwi_p (init))
+	{
+	  add_AT_unsigned (die, DW_AT_const_value, tree_to_uhwi (init));
+          return true;
+	}
+      if (tree_fits_shwi_p (init))
+	{
+	  add_AT_int (die, DW_AT_const_value, tree_to_shwi (init));
+	  return true;
+	}
+    }
   if (! early_dwarf)
     {
       rtl = rtl_for_decl_init (init, type);


	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Improve DW_AT_const_value with early_dwarf
  2017-09-19 14:12     ` Jakub Jelinek
@ 2017-09-19 21:20       ` Jakub Jelinek
  2017-09-20  8:21         ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2017-09-19 21:20 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Tue, Sep 19, 2017 at 04:11:52PM +0200, Jakub Jelinek wrote:
> Will try now following plus testcase, the rest of constants I believe end up
> being DW_FORM_block encoded and so is pretty much what we emit even for the
> initializer_constant_valid_p tree fallback case.

I've bootstrapped/regtested this on x86_64-linux and i686-linux, ok for
trunk?  Most of the testcase changes are then to make sure newlines don't
match where they shouldn't, because this regression would be actually caught
by the testsuite otherwise.

.debug_info is ~ 28KB smaller.
On previous bootstrap from earlier today I saw:
readelf -wa obj96/gcc/cc1plus | grep DW_AT_const_value | sort | uniq -c | sort -n
      1     DW_AT_const_value  DW_FORM_block2
      3     DW_AT_const_value  DW_FORM_data8
     71     DW_AT_const_value  DW_FORM_string
    311     DW_AT_const_value  DW_FORM_strp
    472     DW_AT_const_value  DW_FORM_sdata
    656     DW_AT_const_value  DW_FORM_data4
    787     DW_AT_const_value  DW_FORM_data2
   2182     DW_AT_const_value  DW_FORM_block1
   2598     DW_AT_const_value  DW_FORM_data1
and with this patch:
readelf -wa obj98/gcc/cc1plus | grep DW_AT_const_value | sort | uniq -c | sort -n
      1     DW_AT_const_value  DW_FORM_block2
     71     DW_AT_const_value  DW_FORM_string
    311     DW_AT_const_value  DW_FORM_strp
    346     DW_AT_const_value  DW_FORM_data8
    478     DW_AT_const_value  DW_FORM_block1
    495     DW_AT_const_value  DW_FORM_sdata
   1123     DW_AT_const_value  DW_FORM_data2
   1362     DW_AT_const_value  DW_FORM_data4
   4089     DW_AT_const_value  DW_FORM_data1
so the number of these attributes with constant class significantly increased
over block class and the number of attributes increased too.

2017-09-19  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST
	that fits into uhwi or shwi, add DW_AT_const_value regardless
	of early_dwarf without going through RTL, using add_AT_unsigned
	or add_AT_int.

	* g++.dg/debug/dwarf2/template-params-13.C: New test.
	* g++.dg/debug/dwarf2/template-params-5.C: Adjust regexps so that
	it doesn't match newlines.
	* g++.dg/debug/dwarf2/template-params-3.C: Likewise.
	* g++.dg/debug/dwarf2/template-func-params-3.C: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.
	* g++.dg/debug/dwarf2/template-func-params-2.C: Likewise.
	* g++.dg/debug/dwarf2/template-func-params-1.C: Likewise.
	* g++.dg/debug/dwarf2/template-func-params-5.C: Likewise.
	* g++.dg/debug/dwarf2/template-params-1.C: Likewise.
	* g++.dg/debug/dwarf2/template-params-2.C: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
	* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.

--- gcc/dwarf2out.c.jj	2017-09-15 18:11:03.000000000 +0200
+++ gcc/dwarf2out.c	2017-09-19 16:03:27.678337475 +0200
@@ -19440,6 +19440,19 @@ tree_add_const_value_attribute (dw_die_r
   init = t;
   gcc_assert (!DECL_P (init));
 
+  if (TREE_CODE (init) == INTEGER_CST)
+    {
+      if (tree_fits_uhwi_p (init))
+	{
+	  add_AT_unsigned (die, DW_AT_const_value, tree_to_uhwi (init));
+	  return true;
+	}
+      if (tree_fits_shwi_p (init))
+	{
+	  add_AT_int (die, DW_AT_const_value, tree_to_shwi (init));
+	  return true;
+	}
+    }
   if (! early_dwarf)
     {
       rtl = rtl_for_decl_init (init, type);
--- gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C	2017-09-19 16:29:48.828668182 +0200
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "T.*DW_AT_name" } }
+// { dg-final { scan-assembler "T\[^\n\r]* DW_AT_name" } }
 
 template <class T>
 struct vector
--- gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C	2017-09-19 16:29:33.812855410 +0200
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA -gno-strict-dwarf -fno-merge-debug-strings" }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "f.*DW_AT_name" } }
+// { dg-final { scan-assembler "f\[^\n\r]* DW_AT_name" } }
 // { dg-final { scan-assembler "DW_AT_location\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_addr\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*_Z4blehv\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_stack_value" } } */
 
 typedef void (*func_ptr) ();
--- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C	2017-09-19 16:27:59.886026562 +0200
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA -gno-strict-dwarf -fno-merge-debug-strings" }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "f.*DW_AT_name" } }
+// { dg-final { scan-assembler "f\[^\n\r]* DW_AT_name" } }
 // { dg-final { scan-assembler "DW_AT_location\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_addr\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*_Z4blehv\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_stack_value" } } */
 
 typedef void (*func_ptr)();
--- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C	2017-09-19 16:26:57.169808555 +0200
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-O -std=c++98 -gdwarf-2 -dA" }
 // DW_LANG_C_plus_plus = 0x0004
-// { dg-final { scan-assembler "0x4.*DW_AT_language" } } */
+// { dg-final { scan-assembler "0x4\[^\n\r]* DW_AT_language" } } */
 
 int version;
--- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C	2017-09-19 16:27:40.141272754 +0200
@@ -3,8 +3,8 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "i.*DW_AT_name" } }
-// { dg-final { scan-assembler "3.*DW_AT_const_value" } }
+// { dg-final { scan-assembler "i\[^\n\r]* DW_AT_name" } }
+// { dg-final { scan-assembler "3\[^\n\r]* DW_AT_const_value" } }
 
 
 template <int i>
--- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C	2017-09-19 16:27:29.347407340 +0200
@@ -3,7 +3,7 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "U.*DW_AT_name" } }
+// { dg-final { scan-assembler "U\[^\n\r]* DW_AT_name" } }
 
 template <class U>
 U
--- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C	2017-09-19 16:28:17.138811441 +0200
@@ -2,7 +2,7 @@
 // Origin PR debug/30161
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "T.*DW_AT_name" } }
+// { dg-final { scan-assembler "T\[^\n\r]* DW_AT_name" } }
 
 template <class T>
 struct vector
--- gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C	2017-09-19 16:28:40.967514326 +0200
@@ -3,7 +3,7 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
-// { dg-final { scan-assembler "U.*DW_AT_name" } }
+// { dg-final { scan-assembler "U\[^\n\r]* DW_AT_name" } }
 
 template <class U>
 class A
--- gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C.jj	2015-07-09 11:07:21.000000000 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C	2017-09-19 16:29:21.326011106 +0200
@@ -3,8 +3,8 @@
 // { dg-options "-gdwarf-2 -dA" }
 // { dg-do compile }
 // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
-// { dg-final { scan-assembler "i.*DW_AT_name" } }
-// { dg-final { scan-assembler "3.*DW_AT_const_value" } }
+// { dg-final { scan-assembler "i\[^\n\r]* DW_AT_name" } }
+// { dg-final { scan-assembler "3\[^\n\r]* DW_AT_const_value" } }
 
 template <int i>
 struct A
--- gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C.jj	2017-09-19 16:21:47.069675119 +0200
+++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C	2017-09-19 16:24:54.425339027 +0200
@@ -0,0 +1,10 @@
+// { dg-options "-gdwarf-2 -dA" }
+// { dg-do compile }
+// { dg-final { scan-assembler "DW_TAG_template_value_param" } }
+// { dg-final { scan-assembler "N\[^\n\r]* DW_AT_name" } }
+// { dg-final { scan-assembler "9\[^\n\r]* DW_AT_const_value" } }
+
+template <int N> class C {};
+template <typename T> struct E {};
+E<struct A> f;
+struct A { C<9> g; };
--- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C.jj	2014-11-26 20:35:03.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C	2017-09-19 16:26:49.329906309 +0200
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-O -std=c++14 -gdwarf-5 -dA" }
 // DW_LANG_C_plus_plus_14 = 0x0021
-// { dg-final { scan-assembler "0x21.*DW_AT_language" } } */
+// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */
 
 int version;
--- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C.jj	2014-11-26 20:35:03.000000000 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C	2017-09-19 16:26:40.939010933 +0200
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-O -std=c++11 -gdwarf-5 -dA" }
 // DW_LANG_C_plus_plus_11 = 0x001a
-// { dg-final { scan-assembler "0x1a.*DW_AT_language" } } */
+// { dg-final { scan-assembler "0x1a\[^\n\r]* DW_AT_language" } } */
 
 int version;


	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Improve DW_AT_const_value with early_dwarf
  2017-09-19 21:20       ` [PATCH] Improve DW_AT_const_value with early_dwarf Jakub Jelinek
@ 2017-09-20  8:21         ` Richard Biener
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Biener @ 2017-09-20  8:21 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 19 Sep 2017, Jakub Jelinek wrote:

> On Tue, Sep 19, 2017 at 04:11:52PM +0200, Jakub Jelinek wrote:
> > Will try now following plus testcase, the rest of constants I believe end up
> > being DW_FORM_block encoded and so is pretty much what we emit even for the
> > initializer_constant_valid_p tree fallback case.
> 
> I've bootstrapped/regtested this on x86_64-linux and i686-linux, ok for
> trunk?  Most of the testcase changes are then to make sure newlines don't
> match where they shouldn't, because this regression would be actually caught
> by the testsuite otherwise.
> 
> .debug_info is ~ 28KB smaller.
> On previous bootstrap from earlier today I saw:
> readelf -wa obj96/gcc/cc1plus | grep DW_AT_const_value | sort | uniq -c | sort -n
>       1     DW_AT_const_value  DW_FORM_block2
>       3     DW_AT_const_value  DW_FORM_data8
>      71     DW_AT_const_value  DW_FORM_string
>     311     DW_AT_const_value  DW_FORM_strp
>     472     DW_AT_const_value  DW_FORM_sdata
>     656     DW_AT_const_value  DW_FORM_data4
>     787     DW_AT_const_value  DW_FORM_data2
>    2182     DW_AT_const_value  DW_FORM_block1
>    2598     DW_AT_const_value  DW_FORM_data1
> and with this patch:
> readelf -wa obj98/gcc/cc1plus | grep DW_AT_const_value | sort | uniq -c | sort -n
>       1     DW_AT_const_value  DW_FORM_block2
>      71     DW_AT_const_value  DW_FORM_string
>     311     DW_AT_const_value  DW_FORM_strp
>     346     DW_AT_const_value  DW_FORM_data8
>     478     DW_AT_const_value  DW_FORM_block1
>     495     DW_AT_const_value  DW_FORM_sdata
>    1123     DW_AT_const_value  DW_FORM_data2
>    1362     DW_AT_const_value  DW_FORM_data4
>    4089     DW_AT_const_value  DW_FORM_data1
> so the number of these attributes with constant class significantly increased
> over block class and the number of attributes increased too.

Ok.

Thanks,
Richard.

> 2017-09-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST
> 	that fits into uhwi or shwi, add DW_AT_const_value regardless
> 	of early_dwarf without going through RTL, using add_AT_unsigned
> 	or add_AT_int.
> 
> 	* g++.dg/debug/dwarf2/template-params-13.C: New test.
> 	* g++.dg/debug/dwarf2/template-params-5.C: Adjust regexps so that
> 	it doesn't match newlines.
> 	* g++.dg/debug/dwarf2/template-params-3.C: Likewise.
> 	* g++.dg/debug/dwarf2/template-func-params-3.C: Likewise.
> 	* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.
> 	* g++.dg/debug/dwarf2/template-func-params-2.C: Likewise.
> 	* g++.dg/debug/dwarf2/template-func-params-1.C: Likewise.
> 	* g++.dg/debug/dwarf2/template-func-params-5.C: Likewise.
> 	* g++.dg/debug/dwarf2/template-params-1.C: Likewise.
> 	* g++.dg/debug/dwarf2/template-params-2.C: Likewise.
> 	* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
> 	* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
> 
> --- gcc/dwarf2out.c.jj	2017-09-15 18:11:03.000000000 +0200
> +++ gcc/dwarf2out.c	2017-09-19 16:03:27.678337475 +0200
> @@ -19440,6 +19440,19 @@ tree_add_const_value_attribute (dw_die_r
>    init = t;
>    gcc_assert (!DECL_P (init));
>  
> +  if (TREE_CODE (init) == INTEGER_CST)
> +    {
> +      if (tree_fits_uhwi_p (init))
> +	{
> +	  add_AT_unsigned (die, DW_AT_const_value, tree_to_uhwi (init));
> +	  return true;
> +	}
> +      if (tree_fits_shwi_p (init))
> +	{
> +	  add_AT_int (die, DW_AT_const_value, tree_to_shwi (init));
> +	  return true;
> +	}
> +    }
>    if (! early_dwarf)
>      {
>        rtl = rtl_for_decl_init (init, type);
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-5.C	2017-09-19 16:29:48.828668182 +0200
> @@ -2,7 +2,7 @@
>  // Origin PR debug/30161
>  // { dg-options "-gdwarf-2 -dA" }
>  // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
> -// { dg-final { scan-assembler "T.*DW_AT_name" } }
> +// { dg-final { scan-assembler "T\[^\n\r]* DW_AT_name" } }
>  
>  template <class T>
>  struct vector
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-3.C	2017-09-19 16:29:33.812855410 +0200
> @@ -2,7 +2,7 @@
>  // Origin PR debug/30161
>  // { dg-options "-gdwarf-2 -dA -gno-strict-dwarf -fno-merge-debug-strings" }
>  // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
> -// { dg-final { scan-assembler "f.*DW_AT_name" } }
> +// { dg-final { scan-assembler "f\[^\n\r]* DW_AT_name" } }
>  // { dg-final { scan-assembler "DW_AT_location\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_addr\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*_Z4blehv\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_stack_value" } } */
>  
>  typedef void (*func_ptr) ();
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-3.C	2017-09-19 16:27:59.886026562 +0200
> @@ -2,7 +2,7 @@
>  // Origin PR debug/30161
>  // { dg-options "-gdwarf-2 -dA -gno-strict-dwarf -fno-merge-debug-strings" }
>  // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
> -// { dg-final { scan-assembler "f.*DW_AT_name" } }
> +// { dg-final { scan-assembler "f\[^\n\r]* DW_AT_name" } }
>  // { dg-final { scan-assembler "DW_AT_location\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_addr\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*_Z4blehv\[^\\r\\n\]*\[\\r\\n\]*\[^\\r\\n\]*DW_OP_stack_value" } } */
>  
>  typedef void (*func_ptr)();
> --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C	2017-09-19 16:26:57.169808555 +0200
> @@ -1,6 +1,6 @@
>  // { dg-do compile }
>  // { dg-options "-O -std=c++98 -gdwarf-2 -dA" }
>  // DW_LANG_C_plus_plus = 0x0004
> -// { dg-final { scan-assembler "0x4.*DW_AT_language" } } */
> +// { dg-final { scan-assembler "0x4\[^\n\r]* DW_AT_language" } } */
>  
>  int version;
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-2.C	2017-09-19 16:27:40.141272754 +0200
> @@ -3,8 +3,8 @@
>  // { dg-options "-gdwarf-2 -dA" }
>  // { dg-do compile }
>  // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
> -// { dg-final { scan-assembler "i.*DW_AT_name" } }
> -// { dg-final { scan-assembler "3.*DW_AT_const_value" } }
> +// { dg-final { scan-assembler "i\[^\n\r]* DW_AT_name" } }
> +// { dg-final { scan-assembler "3\[^\n\r]* DW_AT_const_value" } }
>  
>  
>  template <int i>
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-1.C	2017-09-19 16:27:29.347407340 +0200
> @@ -3,7 +3,7 @@
>  // { dg-options "-gdwarf-2 -dA" }
>  // { dg-do compile }
>  // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
> -// { dg-final { scan-assembler "U.*DW_AT_name" } }
> +// { dg-final { scan-assembler "U\[^\n\r]* DW_AT_name" } }
>  
>  template <class U>
>  U
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-func-params-5.C	2017-09-19 16:28:17.138811441 +0200
> @@ -2,7 +2,7 @@
>  // Origin PR debug/30161
>  // { dg-options "-gdwarf-2 -dA" }
>  // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
> -// { dg-final { scan-assembler "T.*DW_AT_name" } }
> +// { dg-final { scan-assembler "T\[^\n\r]* DW_AT_name" } }
>  
>  template <class T>
>  struct vector
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-1.C	2017-09-19 16:28:40.967514326 +0200
> @@ -3,7 +3,7 @@
>  // { dg-options "-gdwarf-2 -dA" }
>  // { dg-do compile }
>  // { dg-final { scan-assembler "DW_TAG_template_type_param" } }
> -// { dg-final { scan-assembler "U.*DW_AT_name" } }
> +// { dg-final { scan-assembler "U\[^\n\r]* DW_AT_name" } }
>  
>  template <class U>
>  class A
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C.jj	2015-07-09 11:07:21.000000000 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-2.C	2017-09-19 16:29:21.326011106 +0200
> @@ -3,8 +3,8 @@
>  // { dg-options "-gdwarf-2 -dA" }
>  // { dg-do compile }
>  // { dg-final { scan-assembler "DW_TAG_template_value_param" } }
> -// { dg-final { scan-assembler "i.*DW_AT_name" } }
> -// { dg-final { scan-assembler "3.*DW_AT_const_value" } }
> +// { dg-final { scan-assembler "i\[^\n\r]* DW_AT_name" } }
> +// { dg-final { scan-assembler "3\[^\n\r]* DW_AT_const_value" } }
>  
>  template <int i>
>  struct A
> --- gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C.jj	2017-09-19 16:21:47.069675119 +0200
> +++ gcc/testsuite/g++.dg/debug/dwarf2/template-params-13.C	2017-09-19 16:24:54.425339027 +0200
> @@ -0,0 +1,10 @@
> +// { dg-options "-gdwarf-2 -dA" }
> +// { dg-do compile }
> +// { dg-final { scan-assembler "DW_TAG_template_value_param" } }
> +// { dg-final { scan-assembler "N\[^\n\r]* DW_AT_name" } }
> +// { dg-final { scan-assembler "9\[^\n\r]* DW_AT_const_value" } }
> +
> +template <int N> class C {};
> +template <typename T> struct E {};
> +E<struct A> f;
> +struct A { C<9> g; };
> --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C.jj	2014-11-26 20:35:03.000000000 +0100
> +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C	2017-09-19 16:26:49.329906309 +0200
> @@ -1,6 +1,6 @@
>  // { dg-do compile }
>  // { dg-options "-O -std=c++14 -gdwarf-5 -dA" }
>  // DW_LANG_C_plus_plus_14 = 0x0021
> -// { dg-final { scan-assembler "0x21.*DW_AT_language" } } */
> +// { dg-final { scan-assembler "0x21\[^\n\r]* DW_AT_language" } } */
>  
>  int version;
> --- gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C.jj	2014-11-26 20:35:03.000000000 +0100
> +++ gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C	2017-09-19 16:26:40.939010933 +0200
> @@ -1,6 +1,6 @@
>  // { dg-do compile }
>  // { dg-options "-O -std=c++11 -gdwarf-5 -dA" }
>  // DW_LANG_C_plus_plus_11 = 0x001a
> -// { dg-final { scan-assembler "0x1a.*DW_AT_language" } } */
> +// { dg-final { scan-assembler "0x1a\[^\n\r]* DW_AT_language" } } */
>  
>  int version;
> 
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-20  8:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-13  7:16 [PATCH] More early LTO dwarf2out bits Richard Biener
2017-09-19 13:56 ` Jakub Jelinek
2017-09-19 14:09   ` Richard Biener
2017-09-19 14:12     ` Jakub Jelinek
2017-09-19 21:20       ` [PATCH] Improve DW_AT_const_value with early_dwarf Jakub Jelinek
2017-09-20  8:21         ` Richard Biener

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).