Patchwork Fix infinite recursion when recursively inlining function with alias

login
register
mail settings
Submitter Jan Hubicka
Date Aug. 5, 2011, 2:45 p.m.
Message ID <20110805144502.GC7642@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/108679/
State New
Headers show

Comments

Jan Hubicka - Aug. 5, 2011, 2:45 p.m.
Hi,
this patch fixes the infinite recursion triggered when buildling MIPS libgcc.
Bootstrapping/regtesting x86_64-linux and will commit it once it passes. Thanks to Richard
for reducing the testcase.

Honza

	PR middle-end/49735
	* gcc.c-torture/compile/pr49735.c: New testcase
	* ipa-inline.c (recursive_inlining): Look through aliases.

Patch

Index: gcc/testsuite/gcc.c-torture/compile/pr49735.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr49735.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr49735.c	(revision 0)
@@ -0,0 +1,4 @@ 
+/* { dg-require-alias "" } */
+void bar (void);
+static void foo (void) { bar (); }
+void bar (void) __attribute__((alias("foo")));
Index: gcc/ipa-inline.c
===================================================================
--- gcc/ipa-inline.c	(revision 177411)
+++ gcc/ipa-inline.c	(working copy)
@@ -1206,8 +1206,9 @@  recursive_inlining (struct cgraph_edge *
       depth = 1;
       for (cnode = curr->caller;
 	   cnode->global.inlined_to; cnode = cnode->callers->caller)
-	if (node->decl == curr->callee->decl)
-	  depth++;
+	if (node->decl
+	    == cgraph_function_or_thunk_node (curr->callee, NULL)->decl)
+          depth++;
 
       if (!want_inline_self_recursive_call_p (curr, node, false, depth))
 	continue;