[PATCH] D61808: [ObjC] Replace uses of the argument of a call to objc_autorelease with the result in MRR

Akira Hatanaka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 15:35:39 PDT 2019


ahatanak added a comment.

In D61808#1505608 <https://reviews.llvm.org/D61808#1505608>, @rjmccall wrote:

> In D61808#1505544 <https://reviews.llvm.org/D61808#1505544>, @ahatanak wrote:
>
> > In D61808#1505023 <https://reviews.llvm.org/D61808#1505023>, @rjmccall wrote:
> >
> > > The assumption that these methods return the receiver is not true without additional semantic assumptions about these methods, so the current behavior of unconditionally turning `[x autorelease]` into `objc_autorelease(x), x` seems quite broken.
> >
> >
> > Because it's possible to override an autorelease method and make the method return something other than the passed argument, for example?
> >
> > If it's not possible to assume that the method returns the passed argument in MRR, the direction of this patch and https://reviews.llvm.org/D61970 is completely wrong.
>
>
> Well, `objc_retain` and `objc_autorelease` (and `objc_release`, trivially) do return the normal return value of the message send in MRR, so assuming that's preserved in the IR, you just need to use that as the expression result.  But if the backend's going to unconditionally optimize the intrinsics based on the assumption that those values are the same, that's problematic, just as it would be problematic for it to do ARC-approved reordering on intrinsics emitted for MRR.


Okay, that means it's not legal to tail-call the call to `objc_autorelease` in function `bar` in the summary since we can't assume `t` is the same as the result of `[t autorelease]`. Also, it's not correct to emit the calls to `objc_autoreleaseReturnValue` and `objc_retainAutoreleasedReturnValue` as intrinsics calls and let the ARC optimizer and ARC contract pass optimize them as if they were compiled in ARC as I did in https://reviews.llvm.org/D61970.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61808/new/

https://reviews.llvm.org/D61808





More information about the llvm-commits mailing list