This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR 40570] Do not create cycles of inlined nodes when inlining functions called once
Hi,
On Wed, Jul 29, 2009 at 06:50:26AM -0700, H.J. Lu wrote:
> 2009/7/29 Martin Jambor <mjambor@suse.cz>:
> > I guess the subject says it all. This fixes PR 40570 by not inlining
> > a function into itself, even when it is its own only caller.
> >
> > Bootstrapped and tested on x86_64-linux but apart from an approval in
> > general, I would still like Honza to confirm this is indeed a correct
> > fix before committing.
> >
> > Thanks,
> >
> > Martin
> >
> >
> >
> > 2009-07-28 Martin Jambor <mjambor@suse.cz>
> >
> > * ipa-inline.c (cgraph_decide_inlining): Watch out for dead single
> > use inlining loops.
> >
> > * testsuite/gcc.c-torture/compile/pr40570.c: New test.
> >
>
> You should mention PR 40570 in both ChangeLog entries.
OK, I've added it to my copy of the patch.
>
> > Index: icln/gcc/ipa-inline.c
> > ===================================================================
> > --- icln.orig/gcc/ipa-inline.c
> > +++ icln/gcc/ipa-inline.c
> > @@ -1227,6 +1227,7 @@ cgraph_decide_inlining (void)
> > && !node->needed
> > && node->local.inlinable
> > && node->callers->inline_failed
> > + && node->callers->caller->global.inlined_to != node
> > && !gimple_call_cannot_inline_p (node->callers->call_stmt)
> > && !DECL_EXTERNAL (node->decl)
> > && !DECL_COMDAT (node->decl))
> > Index: icln/gcc/testsuite/gcc.c-torture/compile/pr40570.c
> > ===================================================================
> > --- /dev/null
> > +++ icln/gcc/testsuite/gcc.c-torture/compile/pr40570.c
> > @@ -0,0 +1,19 @@
> > +static int foo(int i);
> > +
> > +static int bar(int i) { foo(i); }
> > +
> > +static int foo(int i)
> > +{
> > + int j;
> > + if (j)
> > + FOO(j);
>
> Does it have to be FOO, which is undeclared?
Well, I just copied the testcase from bugzilla. Apparently it has to
be something different from the other three functions (foo, bar, baz).
But I guess the following testcase is a bit nicer and also works so
I'll use that one.
Thanks,
Martin
extern void anything(int);
static int foo(int i);
static int bar(int i) { foo(i); }
extern int j;
static int foo(int i)
{
if (j)
anything(j);
return bar(i);
}
int baz()
{
foo(0);
if (baz())
return 1;
return 0;
}