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, PR 40570] Do not create cycles of inlined nodes when inlining functions called once


On Wed, Jul 29, 2009 at 12:31:24PM +0200, Martin Jambor wrote:
> Hi,
> 
> 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.
> 

I missed the case when a node is being inlined into itself directly
and not through another inlined function.  The patch below takes care
of that (I discovered this while investigating a testcase failure of
my ipa-cp stuff so I don't have a new testcase - there will be one
once advanced cloning gets in).

> 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.
> 

I'm about to bootstrap and the new patch but I do expect it to pass.
The request for confirmation still applies.

Thanks,

Martin


2009-07-30  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.


Index: icln/gcc/ipa-inline.c
===================================================================
--- icln.orig/gcc/ipa-inline.c
+++ icln/gcc/ipa-inline.c
@@ -1227,6 +1227,8 @@ cgraph_decide_inlining (void)
 	      && !node->needed
 	      && node->local.inlinable
 	      && node->callers->inline_failed
+	      && node->callers->caller != node
+	      && 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);
+  return bar(i);
+}
+
+int baz()
+{
+  foo(0);
+  if (baz())
+    return 1;
+  return 0;
+}


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