comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: renames usage
Date: Tue, 5 Jan 2021 20:49:34 -0600	[thread overview]
Message-ID: <rt38fv$isj$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: rss4sk$oqt$1@dont-email.me

"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:rss4sk$oqt$1@dont-email.me...
> On 1/3/21 4:19 AM, Randy Brukardt wrote:
>>
>> In this case (a scalar return), the "copy" is a register, and it would be
>> hard (and pointless) to eliminate that.
>
> Thanks for the clarification. I'm not sure I understand what you mean by 
> "the 'copy' is a register". Do you mean
>
> 1. The return value has to be copied into a register
>
> or
>
> 2. The return value is in a register and has to be copied elsewhere
>
> ?

The latter: on every machine on which I'm familar, scalar function results 
are returned in a register. That serves as the "return object", and there's 
not really any way to eliminate that short of inlining the entire call. To 
"rename" the result, one has to copy the register somewhere (unless of 
course the renaming lives a short time with no subprogram calls), and that 
is effectively the same as the constant object declaration.

OTOH, a composite object is typically returned with a reference in a 
register to memory allocated somewhere else (it might be passed in, it might 
be on a "secondary stack", it might be allocated, etc.), and one can rename 
rather than copy that memory.

Of course, if the type requires "build-in-place", then a renames and an 
object are essentially the same again, as no temporary is allowed and the 
memory has to be passed into the function; either for the constant or for 
the renamed temporary.

Which mainly goes to show that nothing is simple... :-)

                                 Randy.


  reply	other threads:[~2021-01-06  2:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-31 11:48 renames usage DrPi
2020-12-31 12:10 ` John Perry
2020-12-31 13:31   ` DrPi
2020-12-31 12:33 ` Gautier write-only address
2020-12-31 14:49 ` Jeffrey R. Carter
2020-12-31 15:55   ` DrPi
2020-12-31 18:48     ` Dmitry A. Kazakov
2021-01-01 12:39       ` DrPi
2021-01-01 13:20         ` Dmitry A. Kazakov
2021-01-02 11:53           ` DrPi
2021-01-01 14:46         ` Jeffrey R. Carter
2021-01-02 11:55           ` DrPi
2021-01-03  3:19           ` Randy Brukardt
2021-01-03 10:05             ` Jeffrey R. Carter
2021-01-06  2:49               ` Randy Brukardt [this message]
2021-01-02 16:00         ` G.B.
2021-01-02 17:22           ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox