1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/lib
Akira Hatanaka b1b35f383e [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly
emitting retainRV or claimRV calls in the IR

Background:

This patch makes changes to the front-end and middle-end that are
needed to fix a longstanding problem where llvm breaks ARC's autorelease
optimization (see the link below) by separating calls from the marker
instructions or retainRV/claimRV calls. The backend changes are in
https://reviews.llvm.org/D92569.

https://clang.llvm.org/docs/AutomaticReferenceCounting.html#arc-runtime-objc-autoreleasereturnvalue

What this patch does to fix the problem:

- The front-end adds operand bundle "clang.arc.rv" to calls, which
  indicates the call is implicitly followed by a marker instruction and
  an implicit retainRV/claimRV call that consumes the call result. In
  addition, it emits a call to @llvm.objc.clang.arc.noop.use, which
  consumes the call result, to prevent the middle-end passes from changing
  the return type of the called function. This is currently done only when
  the target is arm64 and the optimization level is higher than -O0.

- ARC optimizer temporarily emits retainRV/claimRV calls after the calls
  with the operand bundle in the IR and removes the inserted calls after
  processing the function.

- ARC contract pass emits retainRV/claimRV calls after the call with the
  operand bundle. It doesn't remove the operand bundle on the call since
  the backend needs it to emit the marker instruction. The retainRV and
  claimRV calls are emitted late in the pipeline to prevent optimization
  passes from transforming the IR in a way that makes it harder for the
  ARC middle-end passes to figure out the def-use relationship between
  the call and the retainRV/claimRV calls (which is the cause of
  PR31925).

- The function inliner removes an autoreleaseRV call in the callee if
  nothing in the callee prevents it from being paired up with the
  retainRV/claimRV call in the caller. It then inserts a release call if
  the call is annotated with claimRV since autoreleaseRV+claimRV is
  equivalent to a release. If it cannot find an autoreleaseRV call, it
  tries to transfer the operand bundle to a function call in the callee.
  This is important since ARC optimizer can remove the autoreleaseRV
  returning the callee result, which makes it impossible to pair it up
  with the retainRV/claimRV call in the caller. If that fails, it simply
  emits a retain call in the IR if the implicit call is a call to
  retainRV and does nothing if it's a call to claimRV.

Future work:

- Use the operand bundle on x86-64.

- Fix the auto upgrader to convert call+retainRV/claimRV pairs into
  calls annotated with the operand bundles.

rdar://71443534

Differential Revision: https://reviews.llvm.org/D92808
2021-02-05 05:55:18 -08:00
..
Analysis [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
AsmParser [ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags 2021-01-27 10:43:51 -08:00
BinaryFormat
Bitcode [ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags 2021-01-27 10:43:51 -08:00
Bitstream
CodeGen [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
DebugInfo [NFC][DebugInfo] Fix Wreturn-type gcc warning 2021-01-29 11:42:23 +08:00
Demangle [Demangle] Support demangling Swift calling convention in MS demangler. 2021-01-27 13:24:54 -08:00
DWARFLinker [dsymutil][DWARFLinker][NFC] make AddressManager not depending on the order of checks for relocations. 2021-01-31 16:34:10 +03:00
ExecutionEngine [ORC] Clear unused materializing info entries. 2021-02-02 17:47:32 +11:00
Extensions
FileCheck
Frontend [OpenMPIRBuilder] Implement collapseLoops. 2021-02-03 19:12:02 -06:00
Fuzzer
FuzzMutate [FuzzMutate] Add mutator to modify instruction flags. 2021-01-23 19:05:20 +00:00
InterfaceStub [llvm-elfabi] Support ELF file that lacks .gnu.hash section 2021-01-26 12:31:52 -08:00
IR [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
IRReader
LineEditor
Linker [llvm-link] Fix for an assertion when linking global with appending linkage 2021-01-23 00:10:42 -08:00
LTO Revert "[LTO] Use lto::backend for code generation." 2021-02-03 22:49:30 +00:00
MC [WebAssembly] Support single-floating-point immediate value 2021-02-04 18:05:06 -08:00
MCA [llvm] Use llvm::find (NFC) 2021-01-19 20:19:14 -08:00
Object Use DataExtractor to decode SLEB128 in android_relas. 2021-01-28 01:35:18 -08:00
ObjectYAML [yaml2obj][wasm] Support numeric relocation type 2021-02-02 18:28:37 -08:00
Option [clang][cli] Command line round-trip for HeaderSearch options 2021-02-04 10:18:34 +01:00
Passes [NewPM][HelloWorld] Move HelloWorld to Utils 2021-02-03 12:59:40 -08:00
ProfileData [CSSPGO] Tweaking inlining with pseudo probes. 2021-02-01 13:56:40 -08:00
Remarks [llvm] Use append_range (NFC) 2021-01-27 23:25:41 -08:00
Support [PS4] Allow triple to reflect the new company name. 2021-02-04 09:43:17 -08:00
TableGen [TableGen] Fix anonymous record self-reference in foreach and multiclass 2021-02-01 10:59:07 -05:00
Target [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
Testing
TextAPI
ToolDrivers llvm-lib: Pull error printing code out of two functions 2021-01-26 19:13:30 -05:00
Transforms [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
WindowsManifest
XRay
CMakeLists.txt