public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Fix PR ada/35998
@ 2013-11-11 10:32 Eric Botcazou
  2013-11-11 13:06 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2013-11-11 10:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

Hi,

this is an old bug report from Jan, which was closed, then reopened by Tom at 
some point, but the patch never got reviewed.  The original submission is at:
  http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01857.html

Tested on x86_64-suse-linux, OK for the mainline?


2013-11-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR ada/35998
	* dwarf2out.c (add_byte_size_attribute): Omit attribute for size -1.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 862 bytes --]

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 204444)
+++ dwarf2out.c	(working copy)
@@ -16355,9 +16355,10 @@ add_byte_size_attribute (dw_die_ref die,
 
   /* Note that `size' might be -1 when we get to this point.  If it is, that
      indicates that the byte size of the entity in question is variable.  We
-     have no good way of expressing this fact in Dwarf at the present time,
-     so just let the -1 pass on through.  */
-  add_AT_unsigned (die, DW_AT_byte_size, size);
+     have no good way of expressing this fact in Dwarf at the present time
+     when location description was not used by the caller code instead.  */
+  if (size != (unsigned) -1)
+    add_AT_unsigned (die, DW_AT_byte_size, size);
 }
 
 /* For a FIELD_DECL node which represents a bit-field, output an attribute

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

* Re: [patch] Fix PR ada/35998
  2013-11-11 10:32 [patch] Fix PR ada/35998 Eric Botcazou
@ 2013-11-11 13:06 ` Richard Biener
  2013-11-11 17:59   ` Eric Botcazou
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2013-11-11 13:06 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches, Jason Merrill

On Mon, Nov 11, 2013 at 11:10 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this is an old bug report from Jan, which was closed, then reopened by Tom at
> some point, but the patch never got reviewed.  The original submission is at:
>   http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01857.html
>
> Tested on x86_64-suse-linux, OK for the mainline?

Due to the different interfaces of int_size_in_bytes and
simple_type_size_in_bits (and 'size' in add_byte_size_attribute being
unsigned and not [unsigned] HWI) it would be cleaner to
add an early return after the call to int_size_in_bytes if its
return value is -1 (and make sure the return value doesn't
overflow an unsigned int - likewise for simple_type_size_in_bits,
not sure why that case doesn't use int_size_in_bytes as well ...)?

Can you apply some TLC here?

Thanks,
Richard.

>
> 2013-11-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>         PR ada/35998
>         * dwarf2out.c (add_byte_size_attribute): Omit attribute for size -1.
>
>
> --
> Eric Botcazou

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

* Re: [patch] Fix PR ada/35998
  2013-11-11 13:06 ` Richard Biener
@ 2013-11-11 17:59   ` Eric Botcazou
  2013-11-13 10:21     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2013-11-11 17:59 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

> Due to the different interfaces of int_size_in_bytes and
> simple_type_size_in_bits (and 'size' in add_byte_size_attribute being
> unsigned and not [unsigned] HWI) it would be cleaner to
> add an early return after the call to int_size_in_bytes if its
> return value is -1 (and make sure the return value doesn't
> overflow an unsigned int - likewise for simple_type_size_in_bits,
> not sure why that case doesn't use int_size_in_bytes as well ...)?

Both calls are present in the first version of the function, but I agree that 
the discrepancy looks strange.

Revised version attached, tested {GCC,GDB} on x86_64-suse-linux.


2013-11-11  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/35998
	* dwarf2out.c (add_byte_size_attribute): Use int_size_in_bytes also
	for fields.  Do not add the attribute if the size is negative.


-- 
Eric Botcazou

[-- Attachment #2: p2.diff --]
[-- Type: text/x-patch, Size: 1529 bytes --]

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 204444)
+++ dwarf2out.c	(working copy)
@@ -16319,11 +16319,13 @@ add_subscript_info (dw_die_ref type_die,
     }
 }
 
+/* Add a DW_AT_byte_size attribute to DIE with TREE_NODE's size.  */
+
 static void
 add_byte_size_attribute (dw_die_ref die, tree tree_node)
 {
   dw_die_ref decl_die;
-  unsigned size;
+  HOST_WIDE_INT size;
 
   switch (TREE_CODE (tree_node))
     {
@@ -16347,7 +16349,7 @@ add_byte_size_attribute (dw_die_ref die,
 	 generally given as the number of bytes normally allocated for an
 	 object of the *declared* type of the member itself.  This is true
 	 even for bit-fields.  */
-      size = simple_type_size_in_bits (field_type (tree_node)) / BITS_PER_UNIT;
+      size = int_size_in_bytes (field_type (tree_node));
       break;
     default:
       gcc_unreachable ();
@@ -16356,8 +16358,9 @@ add_byte_size_attribute (dw_die_ref die,
   /* Note that `size' might be -1 when we get to this point.  If it is, that
      indicates that the byte size of the entity in question is variable.  We
      have no good way of expressing this fact in Dwarf at the present time,
-     so just let the -1 pass on through.  */
-  add_AT_unsigned (die, DW_AT_byte_size, size);
+     when location description was not used by the caller code instead.  */
+  if (size >= 0)
+    add_AT_unsigned (die, DW_AT_byte_size, size);
 }
 
 /* For a FIELD_DECL node which represents a bit-field, output an attribute

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

* Re: [patch] Fix PR ada/35998
  2013-11-11 17:59   ` Eric Botcazou
@ 2013-11-13 10:21     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2013-11-13 10:21 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches, Jason Merrill

On Mon, Nov 11, 2013 at 6:06 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Due to the different interfaces of int_size_in_bytes and
>> simple_type_size_in_bits (and 'size' in add_byte_size_attribute being
>> unsigned and not [unsigned] HWI) it would be cleaner to
>> add an early return after the call to int_size_in_bytes if its
>> return value is -1 (and make sure the return value doesn't
>> overflow an unsigned int - likewise for simple_type_size_in_bits,
>> not sure why that case doesn't use int_size_in_bytes as well ...)?
>
> Both calls are present in the first version of the function, but I agree that
> the discrepancy looks strange.
>
> Revised version attached, tested {GCC,GDB} on x86_64-suse-linux.

Ok.

Thanks,
Richard.

> 2013-11-11  Eric Botcazou  <ebotcazou@adacore.com>
>
>         PR ada/35998
>         * dwarf2out.c (add_byte_size_attribute): Use int_size_in_bytes also
>         for fields.  Do not add the attribute if the size is negative.
>
>
> --
> Eric Botcazou

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

end of thread, other threads:[~2013-11-13  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-11 10:32 [patch] Fix PR ada/35998 Eric Botcazou
2013-11-11 13:06 ` Richard Biener
2013-11-11 17:59   ` Eric Botcazou
2013-11-13 10: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).