Page MenuHomePhabricator

[ObjC][ARC] Upgrade calls to ARC runtime functions to intrinsic calls if the bitcode has the arm64 retainAutoreleasedReturnValue marker
ClosedPublic

Authored by ahatanak on Aug 7 2019, 1:48 PM.

Details

Summary

The ARC middle-end passes stopped optimizing or transforming bitcode that has been compiled with old compilers after we started emitting calls to ARC runtime functions as intrinsic calls instead of normal function calls in the front-end and made changes to teach the ARC middle-end passes about those intrinsics (see r349534). This patch converts calls to ARC runtime functions that are not intrinsic functions to intrinsic function calls if the bitcode has the arm64 retainAutoreleasedReturnValue marker. Checking for the presence of the marker is necessary to make sure we aren't changing ARC function calls that were originally MRR message sends (see r349952).

rdar://problem/53280660

Diff Detail

Repository
rL LLVM

Event Timeline

ahatanak created this revision.Aug 7 2019, 1:48 PM
pete accepted this revision.Aug 7 2019, 1:53 PM

Looks like the tests are extremely comprehensive. LGTM.

This revision is now accepted and ready to land.Aug 7 2019, 1:53 PM

From my previous change, we dropped clang.arc.used from the old bitcode. Should we upgrade clang.arc.used instead of dropping them?

Since ARC optimizer needs clang.arc.use to correctly move or remove retain/release pairs (see the comment in TopDownPtrState::HandlePotentialAlterRefCount), I think we should unconditionally upgrade the intrinsic calls instead of removing them even when the bitcode doesn't have the arm64 marker. I'll update the patch to convert clang.arc.use to llvm.objc.clang.arc.use.

ahatanak updated this revision to Diff 214027.Aug 7 2019, 4:17 PM

Upgrade clang.arc.use to llvm.objc.clang.arc.use.

ahatanak updated this revision to Diff 214028.Aug 7 2019, 4:21 PM

Initialize variable Changed with the return value of the call to UpgradeToIntrinsic.

This revision was automatically updated to reflect the committed changes.