Patchwork Stop gengtype from emitting empty loops

login
register
mail settings
Submitter Steven Bosscher
Date July 24, 2012, 10:17 a.m.
Message ID <CABu31nMW3330rZ3WMf3DcuhXCFN+mknHATbem5oY5VUUZugh-A@mail.gmail.com>
Download mbox | patch
Permalink /patch/172817/
State New
Headers show

Comments

Steven Bosscher - July 24, 2012, 10:17 a.m.
On Tue, Jul 24, 2012 at 12:11 PM, Laurynas Biveinis
<laurynas.biveinis@gmail.com> wrote:
>> I think it merely points to a bogus GTY annotation, not sure if we want to
>> gobble this kind of gengtype hacks which only benefit -O0 ...
>>
>> The annotation is libcpp/include/line-map.h
>>
>>      In the example above x1 (for token "+") is going to be the same
>>      as y1.  x0 is the spelling location for the argument token "1",
>>      and x2 is the spelling location for the argument token "2".  */
>>   source_location * GTY((length ("2 * %h.n_tokens"))) macro_locations;
>
> This one indeed looks redundant, are there others?

Yes:
../../trunk/gcc/../libcpp/include/line-map.h:168: option `length' may
not be applied to arrays of scalar types
../../trunk/gcc/emit-rtl.c:5913: option `length' may not be applied to
arrays of scalar types
../../trunk/gcc/java/jcf.h:85: option `length' may not be applied to
arrays of scalar types
../../trunk/gcc/java/jcf.h:94: option `length' may not be applied to
arrays of scalar types

The emit-rtl.c one is for DEF_VEC_O(location_t);


                  && ISDIGIT (opt->name[5])


> I am wondering if
> there is something that would produce an empty loop for GC but not for
> PCH or the other way around.

You're the one who's supposed to understand all of this best ;-)

Ciao!
Steven
Laurynas Biveinis - July 24, 2012, 10:42 a.m.
2012/7/24 Steven Bosscher <stevenb.gcc@gmail.com>:
> On Tue, Jul 24, 2012 at 12:11 PM, Laurynas Biveinis
> <laurynas.biveinis@gmail.com> wrote:
>>> I think it merely points to a bogus GTY annotation, not sure if we want to
>>> gobble this kind of gengtype hacks which only benefit -O0 ...
>> This one indeed looks redundant, are there others?
>
> Yes:
(...)

Thanks, looking into it.

>> I am wondering if
>> there is something that would produce an empty loop for GC but not for
>> PCH or the other way around.
>
> You're the one who's supposed to understand all of this best ;-)

It takes a long time to swap this back in :)

Patch

Index: gengtype.c
===================================================================
--- gengtype.c  (revision 189778)
+++ gengtype.c  (working copy)
@@ -1256,7 +1256,17 @@  adjust_field_type (type_p t, options_p opt)

   for (; opt; opt = opt->next)
     if (strcmp (opt->name, "length") == 0)
-      length_p = 1;
+      {
+       if (length_p)
+         error_at_line (&lexer_line, "duplicate `%s' option", opt->name);
+       if (t->u.p->kind == TYPE_SCALAR && ! t->u.p->u.scalar_is_char)
+         {
+           error_at_line (&lexer_line,
+                          "option `%s' may not be applied to arrays
of scalar types",
+                          opt->name);
+         }
+       length_p = 1;
+      }
     else if ((strcmp (opt->name, "param_is") == 0
              || (strncmp (opt->name, "param", 5) == 0