On 17/06/2016 16:57, Gerald Squelart wrote:
> From what *I* understand, RVO is guaranteed (or at least supported 
> everywhere?) when there is only one stack variable that is returned, e.g.:
> C foo()
> {
>   C rv;
>   // ... (put stuff in rv)
>   return rv;
> }
> In this case, the caller function stack can host 'rv' directly, no copies 
> needed.

Sounds like the compiler needs visibility into the called function for
this to work so it'll either be limited to functions compiled as part of
the same invocation or when LTO is enabled. Also what about non-leaf
calls? I.e.

C foo()
{
  C rv;
  // ... (put stuff in rv)
  return rv;
}

C bar()
{
  // ...
  return foo();
}

Would it still work? Do we care about it?

> (Any actual expert who knows the truth?)

That's most likely dependent on a combination of the actual code,
compiler, compiler version and flags used when compiling (and possibly
even target dependent if it interacts with other things like register
promotion of stack variables, etc...).

 Gabriele


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to