diff mbox

Stop gengtype from emitting empty loops

Message ID CABu31nNNGf3cpMiiF8EXuofob_cd2g26ndYuxaVqJS=5WTvw9Q@mail.gmail.com
State New
Headers show

Commit Message

Steven Bosscher July 24, 2012, 9:18 a.m. UTC
Hello,

For scalar fields or skipped fields, gengtype produces empty loops.
This patch checks for that case and breaks out if an empty loop body
is detected:


This probably helps only for -O0 builds, but I do a lot of those.
Compile time for powerpc64-unknown-linux-gnu/bits/extc++.h.gch/O2g.gch
drops from "user 2m29.112s" to "user 0m30.208s" for a -O0 built
cc1plus.

Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK?

Ciao!
Steven

Comments

Laurynas Biveinis July 24, 2012, 9:31 a.m. UTC | #1
> For scalar fields or skipped fields, gengtype produces empty loops.

> This patch checks for that case and breaks out if an empty loop body
> is detected:
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK?
>
> Ciao!
> Steven

OK, thanks!
Richard Biener July 24, 2012, 9:38 a.m. UTC | #2
On Tue, Jul 24, 2012 at 11:31 AM, Laurynas Biveinis
<laurynas.biveinis@gmail.com> wrote:
>> For scalar fields or skipped fields, gengtype produces empty loops.
>
>> This patch checks for that case and breaks out if an empty loop body
>> is detected:
>> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK?
>>
>> Ciao!
>> Steven
>
> OK, thanks!

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;

Richard.

> --
> Laurynas
Steven Bosscher July 24, 2012, 10:03 a.m. UTC | #3
On Tue, Jul 24, 2012 at 11:38 AM, Richard Guenther
<richard.guenther@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;

Right. I'm testing a patch that removes the marker.

Ciao!
Steven
Laurynas Biveinis July 24, 2012, 10:11 a.m. UTC | #4
> 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? I am wondering if
there is something that would produce an empty loop for GC but not for
PCH or the other way around.
diff mbox

Patch

--- gtype-desc.c.orig   2012-07-24 01:57:42.830007515 -0700
+++ gtype-desc.c        2012-07-24 02:10:14.530007515 -0700
@@ -89,6 +89,7 @@ 
         {
           size_t i0;
           for (i0 = 0; i0 != l0; i0++) {
+            break;
           }
         }
       }