diff mbox series

[Ada] Fix compilation time explosion due to recursive inlining

Message ID 1588446.7ZH8RZGjbo@polaris
State New
Headers show
Series [Ada] Fix compilation time explosion due to recursive inlining | expand

Commit Message

Eric Botcazou Dec. 14, 2017, 5:13 p.m. UTC
This clears DECL_DISREGARD_INLINE_LIMITS on recursive expression functions.

Tested on x86_64-suse-linux, applied on the mainline.


2017-12-14  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Call_to): Set DECL_DISREGARD_INLINE_LIMITS
	to 0 on the callee if the call is recursive.
diff mbox series

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 255631)
+++ gcc-interface/trans.c	(working copy)
@@ -4306,10 +4306,16 @@  Call_to_gnu (Node_Id gnat_node, tree *gn
       return call_expr;
     }
 
-  /* For a call to a nested function, check the inlining status.  */
-  if (TREE_CODE (gnu_subprog) == FUNCTION_DECL
-      && decl_function_context (gnu_subprog))
-    check_inlining_for_nested_subprog (gnu_subprog);
+  if (TREE_CODE (gnu_subprog) == FUNCTION_DECL)
+    {
+      /* For a call to a nested function, check the inlining status.  */
+      if (decl_function_context (gnu_subprog))
+	check_inlining_for_nested_subprog (gnu_subprog);
+
+      /* For a recursive call, avoid explosion due to recursive inlining.  */
+      if (gnu_subprog == current_function_decl)
+	DECL_DISREGARD_INLINE_LIMITS (gnu_subprog) = 0;
+    }
 
   /* The only way we can be making a call via an access type is if Name is an
      explicit dereference.  In that case, get the list of formal args from the