public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: [Ada] Fix compilation time explosion due to recursive inlining
Date: Thu, 14 Dec 2017 17:13:00 -0000	[thread overview]
Message-ID: <1588446.7ZH8RZGjbo@polaris> (raw)

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

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.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1077 bytes --]

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

                 reply	other threads:[~2017-12-14 17:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1588446.7ZH8RZGjbo@polaris \
    --to=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).