* [Ada] Do not generate useless temporary for allocator
@ 2017-09-05 8:31 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2017-09-05 8:31 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 433 bytes --]
This is a regression present on the mainline, 7 and 6 branches: the compiler
generates an useless temporary for an allocator.
Tested on x86_64-suse-linux, applied on mainline, 7 and 6 branches.
2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Call_to_gnu): If this is a function call and
there is no target, do not create a temporary for the return value for
an allocator either.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1638 bytes --]
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 251691)
+++ gcc-interface/trans.c (working copy)
@@ -4338,11 +4338,11 @@ Call_to_gnu (Node_Id gnat_node, tree *gn
parameters.
2. There is no target and the call is made for neither an object nor a
- renaming declaration, nor a return statement, and the return type has
- variable size, because in this case the gimplifier cannot create the
- temporary, or more generally is simply an aggregate type, because the
- gimplifier would create the temporary in the outermost scope instead
- of locally.
+ renaming declaration, nor a return statement, nor an allocator, and
+ the return type has variable size because in this case the gimplifier
+ cannot create the temporary, or more generally is simply an aggregate
+ type, because the gimplifier would then create the temporary in the
+ outermost scope instead of locally.
3. There is a target and it is a slice or an array with fixed size,
and the return type has variable size, because the gimplifier
@@ -4361,6 +4361,8 @@ Call_to_gnu (Node_Id gnat_node, tree *gn
&& Nkind (Parent (gnat_node)) != N_Object_Declaration
&& Nkind (Parent (gnat_node)) != N_Object_Renaming_Declaration
&& Nkind (Parent (gnat_node)) != N_Simple_Return_Statement
+ && !(Nkind (Parent (gnat_node)) == N_Qualified_Expression
+ && Nkind (Parent (Parent (gnat_node))) == N_Allocator)
&& AGGREGATE_TYPE_P (gnu_result_type)
&& !TYPE_IS_FAT_POINTER_P (gnu_result_type))
|| (gnu_target
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-05 8:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 8:31 [Ada] Do not generate useless temporary for allocator Eric Botcazou
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).