rjmccall added a comment.

In https://reviews.llvm.org/D41050#952720, @danzimm wrote:

> Or do we need to abide by those semantics strictly here? Could you expand on 
> why that is, if that's the case?


The autoreleased-return-value optimization cannot be understood purely in terms 
of its impact on the retain count; it's a hand-off from the callee to the 
caller the requires a specific code-generation pattern in order to work.

Here, calling retainAutoreleasedRV in the block is necessary in order to 
prevent the return value from the lambda from actually being autoreleased.  The 
block then owns a retain on the return value and must call autoreleaseRV in 
order to balance that out and transfer the object to its caller.  The caller 
will hopefully also call retainAutoreleasedRV, thus completing the transfer of 
the return value all the way to the ultimate caller without actually performing 
any retains or releases.

John.


Repository:
  rC Clang

https://reviews.llvm.org/D41050



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to