[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 17:40:15 PDT 2019


ahatanak added a comment.

We discussed this before, but we already break the base ObjC rules since the runtime elides the autorelease message send in MRR when it's possible to perform the retainRV/autoreleaseRV optimization, which only happens when the caller (or a caller higher up in the call-chain if it's tail-called) is compiled with ARC. IIUC, the only semantic change we''ll be making if we emit an `objc_autoreleaseReturnValue` call instead of an `objc_autorelease` call is that we no longer guarantee that the message send will happen when the class overrides the autorelease method, which we do guarantee with calls to `objc_autorelease` (see `objc_object::autorelease` and `objc_object::rootAutorelease` in the link below).

https://opensource.apple.com/source/objc4/objc4-750/runtime/objc-object.h.auto.html

If we also emit an `objc_retainAutoreleasedReturnValue` call instead of an `objc_retain` call, the retainRV/autoreleaseRV handshake will happen more frequently since now the caller doesn't have to be compiled in ARC in order for it to happen.


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