[PATCH] D118214: [ObjCARC] Require the function argument in the clang.arc.attachedcall bundle.

Ahmed Bougacha via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 21:00:47 PST 2022


ab created this revision.
ab added reviewers: fhahn, ahatanak.
Herald added subscribers: dexonsmith, jdoerfert, pengfei, hiraditya, kristof.beyls.
Herald added a reviewer: apazos.
ab requested review of this revision.
Herald added a project: LLVM.

Currently, the clang.arc.attachedcall bundle takes an optional function
argument.  Depending on whether the argument is present, calls with this
bundle have the following semantics:

- on x86, with the argument present, the call is lowered to: call _target mov rax, rdi call _objc_retainAutoreleasedReturnValue

- on AArch64, without the argument, the call is lowered to: bl _target mov x29, x29

  and the objc runtime call is expected to be emitted separately.

That's because, on x86, the objc runtime checks for both the mov and
the call on x86, and treats the combination as the ARC autorelease elision
marker.

But on AArch64, it only checks for the dedicated NOP marker, as that's
historically been sufficiently unique.  Thanks to that, the runtime call
wasn't required to be adjacent to the NOP marker, so it wasn't emitted
as part of the bundle sequence.

This patch unifies both architectures: on AArch64, we now emit all
3 instructions for the bundle.  This guarantees that the runtime call
is adjacent to the marker in the sequence, and that's information the
runtime can use to further optimize this.

This helps simplify some of the handling, in particular
BundledRetainClaimRVs, which no longer needs to know whether the bundle
is sufficient or not: it now always should be.

Note that this includes an AutoUpgrade that simply drops
clang.arc.attachedcall bundles that don't have an operand: if they
don't, we know that the semantically required call is already a separate
instruction, and the bundle is merely a NOP.
It's not ideal to drop it, but it's okay.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118214

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/ObjCARCUtil.h
  llvm/include/llvm/IR/AutoUpgrade.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/test/Bitcode/upgrade-arc-attachedcall-bundle.ll
  llvm/test/Bitcode/upgrade-arc-attachedcall-bundle.ll.bc
  llvm/test/CodeGen/AArch64/call-rv-marker.ll
  llvm/test/CodeGen/AArch64/expand-blr-rvmarker-pseudo.mir
  llvm/test/CodeGen/AArch64/rvmarker-pseudo-expansion-and-outlining.mir
  llvm/test/CodeGen/X86/call-rv-marker.ll
  llvm/test/Transforms/ObjCARC/contract-marker-funclet.ll
  llvm/test/Transforms/ObjCARC/contract-rv-attr.ll
  llvm/test/Verifier/operand-bundles.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118214.403128.patch
Type: text/x-patch
Size: 33132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220126/5d08c0fc/attachment.bin>


More information about the llvm-commits mailing list