diff mbox

Avoid emitting "sizetype" type names into .debug_info (PR debug/80263)

Message ID 20170401122737.GV17461@tucnak
State New
Headers show

Commit Message

Jakub Jelinek April 1, 2017, 12:27 p.m. UTC
Hi!

This PR is about debug info containing the artificial "sizetype" type
as name of a DW_TAG_base_type, which can clash with user sizetype
identifiers etc.

Apparently we already have code that attempts to not expose that type,
but only do that if sizetype has TYPE_DECL as TYPE_NAME and that denotes
some other, standard, type.

The following patch extends it to attempt to emit size_type_node name
instead of "sizetype" if both sizetype and size_type_node have the
same precision and signedness.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-04-01  Jakub Jelinek  <jakub@redhat.com>

	PR debug/80263
	* dwarf2out.c (modified_type_die): Try harder not to emit internal
	sizetype type into debug info.

	* gcc.dg/debug/dwarf2/pr80263.c: New test.


	Jakub

Comments

Pedro Alves April 3, 2017, 11:11 a.m. UTC | #1
Hi Jakub,

On 04/01/2017 01:27 PM, Jakub Jelinek wrote:

> 2017-04-01  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR debug/80263
> 	* dwarf2out.c (modified_type_die): Try harder not to emit internal
> 	sizetype type into debug info.
> 
> 	* gcc.dg/debug/dwarf2/pr80263.c: New test.

Thanks much for the fix.

I've run gdb's testsuite against GCC trunk with this patch,
and found no regressions.

Thanks,
Pedro Alves
Pedro Alves April 3, 2017, 11:31 a.m. UTC | #2
On 04/03/2017 12:11 PM, Pedro Alves wrote:
> Hi Jakub,
> 
> On 04/01/2017 01:27 PM, Jakub Jelinek wrote:
> 
>> 2017-04-01  Jakub Jelinek  <jakub@redhat.com>
>>
>> 	PR debug/80263
>> 	* dwarf2out.c (modified_type_die): Try harder not to emit internal
>> 	sizetype type into debug info.
>>
>> 	* gcc.dg/debug/dwarf2/pr80263.c: New test.
> 
> Thanks much for the fix.
> 
> I've run gdb's testsuite against GCC trunk with this patch,
> and found no regressions.

Oh, and I forgot to mention for the archives that I had
confirmed that the testcase at:

 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80263#c1

starts working correctly with this patch too.

Thanks,
Pedro Alves
diff mbox

Patch

--- gcc/dwarf2out.c.jj	2017-03-31 20:39:54.000000000 +0200
+++ gcc/dwarf2out.c	2017-04-01 11:24:50.319288819 +0200
@@ -12464,20 +12464,29 @@  modified_type_die (tree type, int cv_qua
      this type.  */
   qualified_type = get_qualified_type (type, cv_quals);
 
-  if (qualified_type == sizetype
-      && TYPE_NAME (qualified_type)
-      && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)
+  if (qualified_type == sizetype)
     {
-      tree t = TREE_TYPE (TYPE_NAME (qualified_type));
+      /* Try not to expose the internal sizetype type's name.  */
+      if (TYPE_NAME (qualified_type)
+	  && TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL)
+	{
+	  tree t = TREE_TYPE (TYPE_NAME (qualified_type));
 
-      gcc_checking_assert (TREE_CODE (t) == INTEGER_TYPE
-			   && TYPE_PRECISION (t)
-			   == TYPE_PRECISION (qualified_type)
-			   && TYPE_UNSIGNED (t)
-			   == TYPE_UNSIGNED (qualified_type));
-      qualified_type = t;
+	  gcc_checking_assert (TREE_CODE (t) == INTEGER_TYPE
+			       && (TYPE_PRECISION (t)
+				   == TYPE_PRECISION (qualified_type))
+			       && (TYPE_UNSIGNED (t)
+				   == TYPE_UNSIGNED (qualified_type)));
+	  qualified_type = t;
+	}
+      else if (qualified_type == sizetype
+	       && TREE_CODE (sizetype) == TREE_CODE (size_type_node)
+	       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (size_type_node)
+	       && TYPE_UNSIGNED (sizetype) == TYPE_UNSIGNED (size_type_node))
+	qualified_type = size_type_node;
     }
 
+
   /* If we do, then we can just use its DIE, if it exists.  */
   if (qualified_type)
     {
--- gcc/testsuite/gcc.dg/debug/dwarf2/pr80263.c.jj	2017-04-01 11:29:32.648668616 +0200
+++ gcc/testsuite/gcc.dg/debug/dwarf2/pr80263.c	2017-04-01 11:31:42.954996922 +0200
@@ -0,0 +1,7 @@ 
+/* PR debug/80263 */
+/* { dg-do compile } */
+/* { dg-options "-g -dA" } */
+
+char array[1];
+
+/* { dg-final { scan-assembler-not {\msizetype} } } */