llvm-project/llvm/test/Transforms/ObjCARC
Akira Hatanaka dea090e6b2 [ObjCARC] Traverse chain downwards to replace uses of argument passed to
ObjC library call with call return.

ARC contraction tries to replace uses of an argument passed to an
objective-c library call with the call return value. For example, in the
following IR, it replaces uses of argument %9 and uses of the values
discovered traversing the chain upwards (%7 and %8) with the call return
%10, if they are dominated by the call to @objc_autoreleaseReturnValue.
This transformation enables code-gen to tail-call the call to
@objc_autoreleaseReturnValue, which is necessary to enable auto release
return value optimization.

%7 = tail call i8* @objc_loadWeakRetained(i8** %6)
%8 = bitcast i8* %7 to %0*
%9 = bitcast %0* %8 to i8*
%10 = tail call i8* @objc_autoreleaseReturnValue(i8* %9)
ret %0* %8

Since r276727, llvm started removing redundant bitcasts and as a result
started feeding the following IR to ARC contraction:

%7 = tail call i8* @objc_loadWeakRetained(i8** %6)
%8 = bitcast i8* %7 to %0*
%9 = tail call i8* @objc_autoreleaseReturnValue(i8* %7)
ret %0* %8

ARC contraction no longer does the optimization described above since it
only traverses the chain upwards and fails to recognize that the
function return can be replaced by the call return. This commit changes
ARC contraction to traverse the chain downwards too and replace uses of
bitcasts with the call return.

rdar://problem/28011339

Differential Revision: https://reviews.llvm.org/D24523

llvm-svn: 281419
2016-09-13 23:43:11 +00:00
..
allocas.ll
apelim.ll
basic.ll [PR27284] Reverse the ownership between DICompileUnit and DISubprogram. 2016-04-15 15:57:41 +00:00
cfg-hazards.ll
comdat-ipo.ll Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
contract-end-of-use-list.ll
contract-marker.ll Add support for objc_unsafeClaimAutoreleasedReturnValue to the 2016-01-27 19:05:08 +00:00
contract-replace-arg-use.ll [ObjCARC] Traverse chain downwards to replace uses of argument passed to 2016-09-13 23:43:11 +00:00
contract-storestrong-ivar.ll
contract-storestrong.ll Form objc_storeStrong in the presence of bitcasts. 2016-05-27 02:13:53 +00:00
contract-testcases.ll
contract.ll
empty-block.ll
ensure-that-exception-unwind-path-is-visited.ll [PR27284] Reverse the ownership between DICompileUnit and DISubprogram. 2016-04-15 15:57:41 +00:00
escape.ll
expand.ll
gvn.ll
intrinsic-use-isolated.ll
intrinsic-use.ll
invoke.ll
move-and-form-retain-autorelease.ll
move-and-merge-autorelease.ll
nested.ll
path-overflow.ll [Verifier] Resume instructions can only be in functions w/ a personality 2016-08-01 18:06:34 +00:00
pointer-types.ll
post-inlining.ll
pr12270.ll
provenance.ll
retain-block-side-effects.ll
retain-not-declared.ll
rle-s2l.ll
rv.ll
split-backedge.ll
tail-call-invariant-enforcement.ll Add support for objc_unsafeClaimAutoreleasedReturnValue to the 2016-01-27 19:05:08 +00:00
unsafe-claim-rv.ll [ObjCARC] Handle ARCInstKind::ClaimRV in OptimizeIndividualCalls. 2016-02-17 18:51:27 +00:00
weak-contract.ll
weak-copies.ll
weak-dce.ll
weak.ll