Patchwork Do not generate debug info for compiler generated VLAs

login
register
mail settings
Submitter Eric Botcazou
Date Oct. 13, 2010, 11:16 p.m.
Message ID <201010140116.06349.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/67750/
State New
Headers show

Comments

Eric Botcazou - Oct. 13, 2010, 11:16 p.m.
Hi,

in February Jakub made a change to the gimplifier in order to generate debug 
info for bounds of VLAs.  This has a significant impact on the code itself in 
Ada (typically +2% code size and +1% compilation time at -O0) because the Ada 
compiler itself generates a lot of VLAs for various constructs; now gigi puts 
DECL_IGNORED_P on these VLAs so the gimplifier shouldn't overrule it.

Bootstrapped/regtested on x86_64-suse-linux, OK for mainline?  What about the 
4.5 branch?


2010-10-13  Eric Botcazou  <ebotcazou@adacore.com>

	* gimplify.c (gimplify_type_sizes) <ARRAY_TYPE>: If the type is to be
	ignored for debug info purposes, do not clear the DECL_IGNORED_P flag
	on the bounds of its domain.
Richard Guenther - Oct. 14, 2010, 8:58 a.m.
On Thu, Oct 14, 2010 at 1:16 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> in February Jakub made a change to the gimplifier in order to generate debug
> info for bounds of VLAs.  This has a significant impact on the code itself in
> Ada (typically +2% code size and +1% compilation time at -O0) because the Ada
> compiler itself generates a lot of VLAs for various constructs; now gigi puts
> DECL_IGNORED_P on these VLAs so the gimplifier shouldn't overrule it.
>
> Bootstrapped/regtested on x86_64-suse-linux, OK for mainline?  What about the
> 4.5 branch?

Hm, it looks sensible, but it's of course odd that if we don't have an
explicit DECL_IGNORED_P flag (like for a non-type-decl TYPE_NAME
or for a NULL TYPE_NAME) that we still emit the info.  In fact it's odd
that the Ada frontend creates a TYPE_DECL for the artificial VLAs
at all (does it do so only to make this flag available?).

I don't see any better way to deal with this though (other than stealing
a bit for all types and making sure we do not unify them).  I suppose
it's not enough to set DECL_IGNORED_P on the VLAs itself?

Anyway, I think that the DECL_IGNORED_P doucmentation in tree.h
needs to be amended for this special case (like, "For a TYPE_DECL,
debug information for its type will be as simple as possible." or a
better wording that I can't come up with right now).

So I'd say, ok for trunk and the branch with the tree.h change.

Thanks,
Richard.

> 2010-10-13  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * gimplify.c (gimplify_type_sizes) <ARRAY_TYPE>: If the type is to be
>        ignored for debug info purposes, do not clear the DECL_IGNORED_P flag
>        on the bounds of its domain.
>
> --
> Eric Botcazou
>
Eric Botcazou - Oct. 15, 2010, 9 a.m.
> Hm, it looks sensible, but it's of course odd that if we don't have an
> explicit DECL_IGNORED_P flag (like for a non-type-decl TYPE_NAME
> or for a NULL TYPE_NAME) that we still emit the info.

The C testcase doesn't pass if you don't clear the flag for unnamed types.

> In fact it's odd that the Ada frontend creates a TYPE_DECL for the
> artificial VLAs at all (does it do so only to make this flag available?).

gigi creates a TYPE_DECL for almost every type for internal reasons that are 
related to the global unsharing thing.  Then it uses (an extended version of) 
the TYPE_DECL_IS_STUB trick in dwarf2out.c to avoid emitting DW_TAG_typedef.

> I don't see any better way to deal with this though (other than stealing
> a bit for all types and making sure we do not unify them).  I suppose
> it's not enough to set DECL_IGNORED_P on the VLAs itself?

The check is already for DECL_IGNORED_P on the VLA, not on its TYPE_DOMAIN.

> Anyway, I think that the DECL_IGNORED_P doucmentation in tree.h
> needs to be amended for this special case (like, "For a TYPE_DECL,
> debug information for its type will be as simple as possible." or a
> better wording that I can't come up with right now).

We want no debug info at all for the type though; I think that dwarf2out.c 
already ensures that.

Patch

Index: gimplify.c
===================================================================
--- gimplify.c	(revision 165411)
+++ gimplify.c	(working copy)
@@ -7535,7 +7535,10 @@  gimplify_type_sizes (tree type, gimple_s
       /* Ensure VLA bounds aren't removed, for -O0 they should be variables
 	 with assigned stack slots, for -O1+ -g they should be tracked
 	 by VTA.  */
-      if (TYPE_DOMAIN (type)
+      if (!(TYPE_NAME (type)
+	    && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+	    && DECL_IGNORED_P (TYPE_NAME (type)))
+	  && TYPE_DOMAIN (type)
 	  && INTEGRAL_TYPE_P (TYPE_DOMAIN (type)))
 	{
 	  t = TYPE_MIN_VALUE (TYPE_DOMAIN (type));