public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8508] Tame fix for PR ipa/99122
Date: Thu,  3 Jun 2021 10:49:40 +0000 (GMT)	[thread overview]
Message-ID: <20210603104940.EEC60398B82C@sourceware.org> (raw)

https://gcc.gnu.org/g:8b1190d527d01dc74ee53e47b0366d01270c330c

commit r11-8508-g8b1190d527d01dc74ee53e47b0366d01270c330c
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Jun 3 12:39:39 2021 +0200

    Tame fix for PR ipa/99122
    
    The return part has a major performance impact in Ada where variable-sized
    types are first-class citizens, but it turns out that it is not exercized
    in the testsuite yet, so back it out for now.
    
    gcc/
            PR ipa/99122
            * tree-inline.c (inline_forbidden_p): Remove test on return type.
    gcc/testsuite/
            * gnat.dg/inline22.adb: New test.

Diff:
---
 gcc/testsuite/gnat.dg/inline22.adb | 19 +++++++++++++++++++
 gcc/tree-inline.c                  | 15 ++++-----------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/gcc/testsuite/gnat.dg/inline22.adb b/gcc/testsuite/gnat.dg/inline22.adb
new file mode 100644
index 00000000000..5812c2f04df
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/inline22.adb
@@ -0,0 +1,19 @@
+-- { dg-compile }
+
+procedure Inline22 (L, U : Integer) is
+
+  type Arr is array (Integer range L .. U) of Boolean;
+
+  function Get_Zero return Arr;
+  pragma Inline_Always (Get_Zero);
+
+  function Get_Zero return Arr is
+  begin
+    return (others => False);
+  end;
+
+  A : Arr;
+
+begin
+  A := Get_Zero;
+end;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 1dcb31c0267..0ef80c93fc4 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4022,17 +4022,10 @@ inline_forbidden_p (tree fndecl)
   wi.info = (void *) fndecl;
   wi.pset = &visited_nodes;
 
-  /* We cannot inline a function with a VLA typed argument or result since
-     we have no implementation materializing a variable of such type in
-     the caller.  */
-  if (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl)))
-      && !poly_int_tree_p (TYPE_SIZE (TREE_TYPE (TREE_TYPE (fndecl)))))
-    {
-      inline_forbidden_reason
-	= G_("function %q+F can never be inlined because "
-	     "it has a VLA return argument");
-      return true;
-    }
+  /* We cannot inline a function with a variable-sized parameter because we
+     cannot materialize a temporary of such a type in the caller if need be.
+     Note that the return case is not symmetrical because we can guarantee
+     that a temporary is not needed by means of CALL_EXPR_RETURN_SLOT_OPT.  */
   for (tree parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
     if (!poly_int_tree_p (DECL_SIZE (parm)))
       {


                 reply	other threads:[~2021-06-03 10:49 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=20210603104940.EEC60398B82C@sourceware.org \
    --to=ebotcazou@gcc.gnu.org \
    --cc=gcc-cvs@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).