This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][4.6] Properly inline all always-inline fns during early-inlining w/o iterating


On Sat, 30 Jan 2010, Paolo Bonzini wrote:

> On 01/29/2010 11:52 PM, Richard Guenther wrote:
> > inline-3.c does some indirect inlining if the indirect function is
> > passed directly as parameter (and thus constant propagation done for
> > parameters during inlining resolves the indirect call).  Lame.  And
> > pretty artificial.
> 
> Actually, it seems pretty much what happens for std::foreach or other STL
> algorithms:
> 
> inline-3.c:
> 
> void
> inline_through_me (void (*ptr)(void))
> {
>   ptr();
> }
> 
> void
> inline_me (void)
> {
>   blah();
> }
> 
> int main(void)
> {
>   inline_through_me (inline_me);
> }
> 
> 
> sample implementation of foreach:
> 
> /* a real implementation would use template <class T, class F> void
>    inline_through_me (T b, T e, F ptr) but this is what it is lowered
>    to... */
> template <class T, class E> void
> inline_through_me (T b, T e, void (*ptr)(E))
> {
>   for (; b != e; b++)
>     ptr(*b);
> }
> 
> void
> inline_me (char *x)
> {
>   std::puts(x);
> }
> 
> int main(int argc, char **argv)
> {
>   inline_through_me (argv, argv + argc, inline_me);
> }

Do they allow plain function-pointer args?  I thought you have
to use std::function for them in which case the propagation
won't work anymore.

Anyway - a real C++ testcase would be nice to have in the
testsuite then.

And we can still stop iterating when not optimizing (we even
run both early and IPA inline when not optimizing ...).

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]