Page MenuHomePhabricator

Teach ObjCARC optimizer about equivalent PHIs when eliminating autoreleaseRV/retainRV pairs

Authored by pete on Jan 2 2019, 4:54 PM.



OptimizeAutoreleaseRVCall skips optimizing llvm.objc.autoreleaseReturnValue if it sees a user which is llvm.objc.retainAutoreleasedReturnValue, and if they have equivalent arguments (either identical or equivalent PHIs). It then assumes that ObjCARCOpt::OptimizeRetainRVCall will optimize the pair instead.

Trouble is, ObjCARCOpt::OptimizeRetainRVCall doesn't know about equivalent PHIs so optimizes in a different way and we are left with an unoptimized llvm.objc.autoreleaseReturnValue.

This patch teaches ObjCARCOpt::OptimizeRetainRVCall to also understand PHI equivalence.

Diff Detail


Event Timeline

pete created this revision.Jan 2 2019, 4:54 PM


613 ↗(On Diff #179971)

If you'd like, you can use the insert method that takes the begin and end iterators instead of writing a loop.

625 ↗(On Diff #179971)

You can reduce indentation if you use && instead of introducing an if statement here.

ahatanak accepted this revision.Jan 2 2019, 5:32 PM
This revision is now accepted and ready to land.Jan 2 2019, 5:32 PM
pete marked 3 inline comments as done.Jan 2 2019, 5:42 PM

Thanks for the review. Submitted as r350284.

625 ↗(On Diff #179971)

Good point. I don't know why I changed that in the first place. Much smaller patch now.

This revision was automatically updated to reflect the committed changes.
pete marked an inline comment as done.