Page MenuHomePhabricator

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

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

Details

Summary

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

Repository
rL LLVM

Event Timeline

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

LGTM

lib/Transforms/ObjCARC/ObjCARCOpts.cpp
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.Wed, Jan 2, 5:32 PM
This revision is now accepted and ready to land.Wed, Jan 2, 5:32 PM
pete marked 3 inline comments as done.Wed, Jan 2, 5:42 PM

Thanks for the review. Submitted as r350284.

lib/Transforms/ObjCARC/ObjCARCOpts.cpp
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.