This is an archive of the discontinued LLVM Phabricator instance.

[ObjC][ARC] Ignore lifetime markers between *ReturnValue calls
ClosedPublic

Authored by thegameg on Nov 4 2019, 4:59 PM.

Details

Summary

When eliminating a pair of

llvm.objc.autoreleaseReturnValue

followed by

llvm.objc.retainAutoreleasedReturnValue

we need to make sure that the instructions in between are safe to ignore.

Other than bitcasts and useless GEPs, it's also safe to ignore lifetime markers for both static allocas (lifetime.start/lifetime.end) and dynamic allocas (stacksave/stackrestore).

These get added by the inliner as part of the return sequence and can prevent the transformation from happening in practice.

Diff Detail

Event Timeline

thegameg created this revision.Nov 4 2019, 4:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2019, 4:59 PM

Generally LGTM, but one minor thing.

llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
664

isSafeBetweenRVCalls also checks IsNoopInstruction.

thegameg updated this revision to Diff 227805.Nov 4 2019, 5:59 PM

Remove the double check for IsNoopInstruction.

thegameg marked an inline comment as done.Nov 4 2019, 5:59 PM
rjmccall accepted this revision.Nov 4 2019, 8:31 PM

LGTM, thanks!

This revision is now accepted and ready to land.Nov 4 2019, 8:31 PM
This revision was automatically updated to reflect the committed changes.