This is an archive of the discontinued LLVM Phabricator instance.

[ObjC][ARC] Handle operand bundle "clang.arc.attachedcall" on targets that don't use the inline asm marker
ClosedPublic

Authored by ahatanak on Oct 7 2021, 12:04 PM.

Details

Summary

https://reviews.llvm.org/D111331 makes clang use operand bundle "clang.arc.attachedcall" on x86-64, which, unlike arm, doesn't use the inline asm marker for the retainRV/autoreleaseRV handshake. This patch makes the changes to the ARC middle-end passes that are needed to handle the operand bundle on targets that don't use the marker.

Note that anyone who wants to use the operand bundle on their target has to teach their backend to handle the operand bundle. The x86-64 backend already knows about the operand bundle (see https://reviews.llvm.org/D94597).

Diff Detail

Event Timeline

ahatanak created this revision.Oct 7 2021, 12:04 PM
ahatanak requested review of this revision.Oct 7 2021, 12:04 PM

Okay, so does this mean that this works on arbitrary targets now? If so, should Clang be using it unconditionally?

No, only arm64 and x86-64 can correctly handle the operand bundle in the backend. I should mention that this only changes the middle-end passes and we still need to make changes to the backend to handle arbitrary targets.

ahatanak edited the summary of this revision. (Show Details)Oct 11 2021, 9:13 PM

Ok. I'm not an expert in this code, but it seems fine to me.

fhahn accepted this revision.Nov 7 2021, 1:26 AM

LGTM, thanks! I left 2 small suggestions that can directly be addressed before committing.

llvm/lib/Transforms/ObjCARC/ObjCARC.h
159

It might be worth adding a quick comment here, to explain what UseMarker indicates here.

llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
437–442

nit: When I first read the code without looking at the precise definition I thought this is a bundle instruction, rather than whether the instruction is contained in a bundle. Perhaps the name could be improved slightly, e.g. IsInstContainedInBundle

This revision is now accepted and ready to land.Nov 7 2021, 1:26 AM
This revision was landed with ongoing or failed builds.Nov 8 2021, 6:40 PM
This revision was automatically updated to reflect the committed changes.
ahatanak marked 2 inline comments as done.