llvm-project/llvm/test/Transforms/ObjCARC
Akira Hatanaka 28fe9afdba [ObjC][ARC] Prevent moving objc_retain calls past objc_release calls
that release the retained object

This patch fixes what looks like a longstanding bug in ARC optimizer
where it reverses the order of objc_retain calls and objc_release calls
that retain and release the same object.

The code in ARC optimizer that is responsible for code motion takes the
following steps:

1. Traverse the CFG bottom-up and determine how far up objc_release
   calls can be moved. Determine the insertion points for the
   objc_release calls, but don't actually move them.
2. Traverse the CFG top-down and determine how far down objc_retain
   calls can be moved. Determine the insertion points for the
   objc_retain calls, but don't actually move them.
3. Try to move the objc_retain and objc_release calls if they can't be
   removed.

The problem is that the insertion points for the objc_retain calls are
determined in step 2 without taking into consideration the insertion
points for objc_release calls determined in step 1, so the order of an
objc_retain call and an objc_release call can be reversed, which is
incorrect, even though each step is correct in isolation.

To fix this bug, this patch teaches the top-down traversal step to take
into consideration the insertion points for objc_release calls
determined in the bottom-up traversal step. Code motion for an
objc_retain call is disabled if there is a possibility that it can be
moved past an objc_release call that releases the retained object.

rdar://79292791

Differential Revision: https://reviews.llvm.org/D104953
2021-07-05 12:16:15 -07:00
..
allocas.ll
apelim.ll
basic.ll [ObjC][ARC] Do not perform code motion on precise release calls 2021-02-15 17:39:37 -08:00
cfg-hazards.ll
clang-arc-use-barrier.ll
code-motion.ll [ObjC][ARC] Prevent moving objc_retain calls past objc_release calls 2021-07-05 12:16:15 -07:00
comdat-ipo.ll
contract-catchswitch.ll
contract-end-of-use-list.ll
contract-marker-funclet.ll [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 2021-03-04 11:22:30 -08:00
contract-marker.ll
contract-replace-arg-use.ll
contract-rv-attr.ll [ObjC][ARC] Ignore operand bundle "clang.arc.attachedcall" on a call if 2021-06-28 11:02:30 -07:00
contract-storestrong-funclet.ll
contract-storestrong-ivar.ll
contract-storestrong.ll
contract-testcases.ll
contract.ll [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 2021-03-04 11:22:30 -08:00
empty-block.ll
ensure-that-exception-unwind-path-is-visited.ll
escape.ll
expand.ll
funclet.ll
gvn.ll
inert-global.ll
inlined-autorelease-return-value.ll
intrinsic-use-isolated.ll
intrinsic-use.ll [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 2021-03-04 11:22:30 -08:00
invoke-2.ll
invoke.ll
move-and-form-retain-autorelease.ll
move-and-merge-autorelease.ll
nested.ll [IR] Memory intrinsics are not unconditionally `nosync` 2021-05-21 03:40:59 +02:00
opt-catchswitch.ll
opt-max-ptr-states.ll
path-overflow.ll
pointer-types.ll
post-inlining.ll
pr12270.ll
provenance.ll
retain-block-side-effects.ll
retain-not-declared.ll
rle-s2l.ll
rv.ll [ObjC][ARC] Use operand bundle 'clang.arc.attachedcall' instead of 2021-03-04 11:22:30 -08:00
split-backedge.ll
tail-call-invariant-enforcement.ll
unsafe-claim-rv.ll
weak-contract.ll
weak-copies.ll
weak-dce.ll
weak.ll