public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use default lower bound for vector types in debug info
@ 2022-07-04  7:52 Eric Botcazou
  2022-07-04  8:18 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2022-07-04  7:52 UTC (permalink / raw)
  To: gcc-patches

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

Hi,

vector types are represented as array types with DW_AT_GNU_vector attribute in 
the debug info and a range [0 .. TYPE_VECTOR_SUBPARTS - 1].  That's obviously 
skewed toward the C family of languages, therefore the attached patch changes 
the lower bound to the default for the language of the CU, if any.

Tested on x86-64/Linux, OK for the mainline?


gcc/
	* dwarf2out.cc (gen_array_type_die): Use the default lower bound of
	the language for vector types.

-- 
Eric Botcazou

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

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index b468a4b9c0f..149aeaf1a55 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -22539,11 +22539,14 @@ gen_array_type_die (tree type, dw_die_ref context_die)
 
   if (TREE_CODE (type) == VECTOR_TYPE)
     {
-      /* For VECTOR_TYPEs we use an array die with appropriate bounds.  */
+      /* For VECTOR_TYPEs we use an array DIE with appropriate bounds.  */
+      int lb = lower_bound_default ();
+      if (lb == -1)
+	lb = 0;
       dw_die_ref subrange_die = new_die (DW_TAG_subrange_type, array_die, NULL);
-      add_bound_info (subrange_die, DW_AT_lower_bound, size_zero_node, NULL);
+      add_bound_info (subrange_die, DW_AT_lower_bound, size_int (lb), NULL);
       add_bound_info (subrange_die, DW_AT_upper_bound,
-		      size_int (TYPE_VECTOR_SUBPARTS (type) - 1), NULL);
+		      size_int (lb + TYPE_VECTOR_SUBPARTS (type) - 1), NULL);
     }
   else
     add_subscript_info (array_die, type, collapse_nested_arrays);

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

* Re: [PATCH] Use default lower bound for vector types in debug info
  2022-07-04  7:52 [PATCH] Use default lower bound for vector types in debug info Eric Botcazou
@ 2022-07-04  8:18 ` Richard Biener
  2022-07-04  8:42   ` Eric Botcazou
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2022-07-04  8:18 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches

On Mon, Jul 4, 2022 at 10:03 AM Eric Botcazou via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> vector types are represented as array types with DW_AT_GNU_vector attribute in
> the debug info and a range [0 .. TYPE_VECTOR_SUBPARTS - 1].  That's obviously
> skewed toward the C family of languages, therefore the attached patch changes
> the lower bound to the default for the language of the CU, if any.
>
> Tested on x86-64/Linux, OK for the mainline?

For late generated vector types this might result in inconsistencies with
early (user) generated types when using LTO.  Is there context available
somehow so we can do like the is_<LANG> overloads on a decl and
use a default according to that?

>
> gcc/
>         * dwarf2out.cc (gen_array_type_die): Use the default lower bound of
>         the language for vector types.
>
> --
> Eric Botcazou

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

* Re: [PATCH] Use default lower bound for vector types in debug info
  2022-07-04  8:18 ` Richard Biener
@ 2022-07-04  8:42   ` Eric Botcazou
  2022-07-04  9:08     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2022-07-04  8:42 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

> For late generated vector types this might result in inconsistencies with
> early (user) generated types when using LTO.

Is that a problem?  That's no different with regular array types.

> Is there context available somehow so we can do like the is_<LANG> overloads
> on a decl and use a default according to that?

Not sure, the only safe thing to do would be to return -1 as the default lower 
bound if flag_generate_lto.

-- 
Eric Botcazou



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

* Re: [PATCH] Use default lower bound for vector types in debug info
  2022-07-04  8:42   ` Eric Botcazou
@ 2022-07-04  9:08     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2022-07-04  9:08 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches

On Mon, Jul 4, 2022 at 10:42 AM Eric Botcazou <botcazou@adacore.com> wrote:
>
> > For late generated vector types this might result in inconsistencies with
> > early (user) generated types when using LTO.
>
> Is that a problem?  That's no different with regular array types.

I'm not sure - almost all types the user can actually inspect should have early
debug info.

> > Is there context available somehow so we can do like the is_<LANG> overloads
> > on a decl and use a default according to that?
>
> Not sure, the only safe thing to do would be to return -1 as the default lower
> bound if flag_generate_lto.

Rather if in_lto_p, but yes, this sounds like a good thing to do.  OTOH if
the used language is uniform LTO will pick that, it will "merge" C/C++
and otherwise use C as fallback in a mixed environment.

So the patch is quite likely OK as-is.

Which means .. OK.

Thanks,
Richard.

> --
> Eric Botcazou
>
>

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

end of thread, other threads:[~2022-07-04  9:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04  7:52 [PATCH] Use default lower bound for vector types in debug info Eric Botcazou
2022-07-04  8:18 ` Richard Biener
2022-07-04  8:42   ` Eric Botcazou
2022-07-04  9:08     ` 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).