[PATCH] Add target independent attribute for ObjCARC

John McCall rjmccall at apple.com
Mon May 20 13:56:07 PDT 2013


On May 20, 2013, at 1:46 PM, Eric Christopher <echristo at gmail.com> wrote:
> On Mon, May 20, 2013 at 1:39 PM, John McCall <rjmccall at apple.com> wrote:
>>> Though it is unfortunate that the same
>>> functions have different meanings in arc and non-arc mode.
>> 
>> They don't;  it's just that nothing outside of ARC permits the compiler
>> to transform calls to those functions, and doing so anyway can really
>> screw things up.
>> 
> 
> Ah, this wasn't clear from Bob's mail.

Several of the ARC entrypoints are defined in terms of others;  for
example, this is a valid implementation:

  id objc_retainAutoreleaseReturnValue(id value) {
    return objc_autoreleaseReturnValue(objc_retain(value));
  }

But of course, there's also an ARC code-size optimization that turns
  %1 = call i8* @objc_retain(i8* %0)
  %2 = call i8* @objc_autoreleaseReturnValue(i8* %1)
into
  %2 = call i8* @objc_retainAutoreleaseReturnValue(i8* %0)

So guess what we really need to make sure the optimizer doesn't do? :)

(There would be other ways to fix this particular issue, of course.)

>> Moreover, ARC's ability to transform calls to those functions is tied to
>> their use to implement the lifetime rules;  if you somehow constructed
>> a C call to one of these functions (which it's probably possible to do in
>> various clever ways), then ARC wouldn't really have license to
>> optimize that.
>> 
> 
> Agreed, though this seems like a good occasion for caveat emptor
> (caveat hacker?).

Yeah, a bug about that would probably not be given the highest possible
priority.

John.



More information about the llvm-commits mailing list