1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
llvm-mirror/lib/IR
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
..
AbstractCallSite.cpp
AsmWriter.cpp [NFC][IR][AsmWriter] Fix Wreturn-type gcc warning 2021-01-28 16:42:30 +08:00
Assumptions.cpp [Clang][Attr] Introduce the assume function attribute 2020-12-15 16:51:34 -06:00
AttributeImpl.h Reapply "OpaquePtr: Add type to sret attribute" 2020-10-16 11:05:02 -04:00
Attributes.cpp Support for instrumenting only selected files or functions 2021-01-26 17:13:34 -08:00
AutoUpgrade.cpp [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
BasicBlock.cpp [OpenMPIRBuilder] Implement tileLoops. 2021-01-23 19:39:29 -06:00
CMakeLists.txt [HIP] Support __managed__ attribute 2021-01-22 11:43:58 -05:00
Comdat.cpp
ConstantFold.cpp Revert "[ConstantFold] Fold more operations to poison" 2021-02-04 00:24:02 +09:00
ConstantFold.h
ConstantRange.cpp [ConstantRange] Introduce getMinSignedBits() method 2020-09-22 21:37:30 +03:00
Constants.cpp [llvm] Use llvm::all_of (NFC) 2021-01-06 18:27:36 -08:00
ConstantsContext.h
Core.cpp [llvm] Don't include StringSwitch.h where unnecessary (NFC) 2021-01-21 19:59:48 -08:00
DataLayout.cpp [IR] Allow scalable vectors in structs to support intrinsics returning multiple values. 2021-01-17 23:29:51 -08:00
DebugInfo.cpp Migrate deprecated DebugLoc::get to DILocation::get 2020-12-11 12:45:22 -08:00
DebugInfoMetadata.cpp Remove overzealous verifier check on DW_OP_LLVM_entry_value and improve the documentation 2021-02-04 10:58:35 -08:00
DebugLoc.cpp [IR] Delete unused ReplaceLast in DebugLoc::appendInlineAt 2021-01-08 23:28:22 -08:00
DiagnosticHandler.cpp
DiagnosticInfo.cpp [IR] Drop unnecessary const from return types (NFC) 2021-02-04 21:18:02 -08:00
DiagnosticPrinter.cpp
DIBuilder.cpp [DebugInfo] Support Fortran 'use <external module>' statement. 2020-12-18 13:10:57 -05:00
Dominators.cpp [DomTree] Make assert more precise 2020-10-22 22:40:06 +02:00
FPEnv.cpp
Function.cpp Allow nonnull/align attribute to accept poison 2021-01-20 11:31:23 +09:00
Globals.cpp Add a default address space for globals to DataLayout 2020-11-20 15:46:52 +00:00
GVMaterializer.cpp
InlineAsm.cpp
Instruction.cpp Revert "[ObjC][ARC] Annotate calls with attributes instead of emitting retainRV" 2021-01-25 13:53:38 -08:00
Instructions.cpp [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
IntrinsicInst.cpp [VP] Build VP SDNodes 2020-12-09 11:36:51 +01:00
IRBuilder.cpp [SVE][LoopVectorize] Add masked load/store and gather/scatter support for SVE 2021-02-02 09:52:39 +00:00
IRPrintingPasses.cpp [NewPM] Support --print-before/after in NPM 2020-12-03 16:52:14 -08:00
LegacyPassManager.cpp [LegacyPM] Update InversedLastUser on the fly. NFC. 2021-01-22 09:48:54 +00:00
LLVMContext.cpp [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly 2021-02-05 05:55:18 -08:00
LLVMContextImpl.cpp [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-16 09:40:53 -08:00
LLVMContextImpl.h [X86] Add x86_amx type for intel AMX. 2020-12-30 13:52:13 +08:00
LLVMRemarkStreamer.cpp [Remarks][2/2] Expand remarks hotness threshold option support in more tools 2020-11-30 21:55:50 -08:00
Mangler.cpp [llvm] Use isAlpha/isAlnum (NFC) 2021-01-22 23:25:03 -08:00
MDBuilder.cpp [CSSPGO] Pseudo probe encoding and emission. 2020-12-10 17:29:28 -08:00
Metadata.cpp [Analysis, IR, CodeGen] Use llvm::erase_if (NFC) 2020-12-20 09:19:35 -08:00
MetadataImpl.h
Module.cpp Refactor how -fno-semantic-interposition sets dso_local on default visibility external linkage definitions 2020-12-31 13:59:45 -08:00
ModuleSummaryIndex.cpp [ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags 2021-01-27 10:43:51 -08:00
Operator.cpp
OptBisect.cpp Make NPM OptBisectInstrumentation use global singleton OptBisect 2020-12-20 13:47:56 -08:00
Pass.cpp [PM] Avoid duplicates in the Used/Preserved/Required sets 2021-01-20 13:55:18 +01:00
PassInstrumentation.cpp [NewPM] Don't error when there's an unrecognized pass name 2021-01-07 22:33:32 -08:00
PassManager.cpp [NewPM] Make pass adaptors less templatey 2020-12-04 08:30:50 -08:00
PassRegistry.cpp [Analysis, IR] Use *Map::lookup (NFC) 2020-12-29 19:23:24 -08:00
PassTimingInfo.cpp [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation 2020-12-08 10:13:19 -08:00
PrintPasses.cpp [IR] Use llvm::is_contained (NFC) 2020-12-08 19:06:37 -08:00
ProfileSummary.cpp ProfileSummary.cpp - use auto const& iterator in for-range loop to avoid copies. NFCI. 2020-09-21 16:54:26 +01:00
PseudoProbe.cpp [CSSPGO] Introducing distribution factor for pseudo probe. 2021-02-02 11:55:01 -08:00
ReplaceConstant.cpp [HIP] Support __managed__ attribute 2021-01-22 11:43:58 -05:00
SafepointIRVerifier.cpp [llvm] Use append_range (NFC) 2021-01-27 23:25:41 -08:00
Statepoint.cpp
StructuralHash.cpp (Expensive) Check for Loop, SCC and Region pass return status 2020-08-28 07:56:35 +02:00
SymbolTableListTraitsImpl.h
Type.cpp [IR] Allow scalable vectors in structs to support intrinsics returning multiple values. 2021-01-17 23:29:51 -08:00
TypeFinder.cpp
Use.cpp
User.cpp [NFC] Edit the comment in User::replaceUsesOfWith 2020-07-29 10:02:04 +08:00
Value.cpp [NFC][LICM] Minor improvements to debug output 2021-01-11 18:02:49 -08:00
ValueSymbolTable.cpp
Verifier.cpp Revert "[Verifier] enable llvm.experimental.noalias.scope.decl dominance check." 2021-02-01 14:38:33 +01:00