This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Mark calls to objc_autorelease as tail
ClosedPublic

Authored by ahatanak on Nov 9 2020, 5:07 PM.

Details

Summary

This enables a method sending an autorelease message to an object and returning the object in MRR to avoid adding the object to an autorelease pool if a call to objc_retainAutoreleasedReturnValue in the caller function accepts the hand off of the retain count.

This patch assumes that methods overriding autorelease do not touch anything on the stack. I think it's safe to make this assumption since ARC optimizer marks calls to objc_autoreleaseReturnValue as tail, which wouldn't be correct if an overriding method did access something on the stack.

https://github.com/llvm/llvm-project/blob/0ca90eb3350b9e8c606fdf1ca0496e0bf3e330ec/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp#L1035

rdar://problem/50678052

Diff Detail

Event Timeline

ahatanak created this revision.Nov 9 2020, 5:07 PM
ahatanak requested review of this revision.Nov 9 2020, 5:07 PM
rjmccall accepted this revision.Nov 9 2020, 11:22 PM
This revision is now accepted and ready to land.Nov 9 2020, 11:22 PM
This revision was landed with ongoing or failed builds.Nov 10 2020, 1:48 PM
This revision was automatically updated to reflect the committed changes.