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]

PR 38844 (infinite loop processing always_inline recursion)


Hi,
this patch fix infinite recursion on ipa-inline.c when edge it is about to
inline was already inlined.  This means that we entered into inlining the
function itself (because there are no inline clones before early inliner starts
processing the function).

Bootstrapped/regtested i686-linux, I've also tested it on SPEC and
C++benchmarks.  There is difference in leafify tramp3d test only that is
related to this recursive inlining case. I will commit the patch
tomorrow if there are no complains.

The second testcase attached to PR triggers quadratic compilation time in
verify_cgraph, but I don't think this has to be fixed.  It needs about hour to
finish compilation though.

int p(int a)
{
  printf("%i\n",a);
  printf("%i\n",a);
  printf("%i\n",a);
  printf("%i\n",a);
}



int t(int a)
{
  test();
  test();
  test();
  test();
  p(a);
  test();
}

int main()
{
  t(1);
}
	PR tree-optimization/38844
	* ipa-inline.c (try_inline): Stop inlining recursion when edge
	is already inlined.
Index: ipa-inline.c
===================================================================
--- ipa-inline.c	(revision 143680)
+++ ipa-inline.c	(working copy)
@@ -1330,16 +1330,18 @@ try_inline (struct cgraph_edge *e, enum 
 	       cgraph_node_name (e->caller));
     }
   if (e->inline_failed)
-    cgraph_mark_inline (e);
+    {
+      cgraph_mark_inline (e);
 
-  /* In order to fully inline always_inline functions, we need to
-     recurse here, since the inlined functions might not be processed by
-     incremental inlining at all yet.  
+      /* In order to fully inline always_inline functions, we need to
+	 recurse here, since the inlined functions might not be processed by
+	 incremental inlining at all yet.  
 
-     Also flattening needs to be done recursively.  */
+	 Also flattening needs to be done recursively.  */
 
-  if (mode == INLINE_ALL || always_inline)
-    cgraph_decide_inlining_incrementally (e->callee, mode, depth + 1);
+      if (mode == INLINE_ALL || always_inline)
+	cgraph_decide_inlining_incrementally (e->callee, mode, depth + 1);
+    }
   callee->aux = (void *)(size_t) callee_mode;
   return true;
 }


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