]> granicus.if.org Git - llvm/commit
[ObjC][ARC] Check the basic block size before calling
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 23 Apr 2019 19:49:03 +0000 (19:49 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 23 Apr 2019 19:49:03 +0000 (19:49 +0000)
commit66aa9e14bd04766f4c4450fd07c5c4d6e21095b2
treeba9827cf36af1e8d6d8f4ab7563dc5278fe99422
parenta6030f2c0d934ad3331347920b042b6109af9d1e
[ObjC][ARC] Check the basic block size before calling
DominatorTree::dominate.

ARC contract pass has an optimization that replaces the uses of the
argument of an ObjC runtime function call with the call result.

For example:

; Before optimization
%1 = tail call i8* @foo1()
%2 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
store i8* %1, i8** @g0, align 8

; After optimization
%1 = tail call i8* @foo1()
%2 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
store i8* %2, i8** @g0, align 8 // %1 is replaced with %2

Before replacing the argument use, DominatorTree::dominate is called to
determine whether the user instruction is dominated by the ObjC runtime
function call instruction. The call to DominatorTree::dominate can be
expensive if the two instructions belong to the same basic block and the
size of the basic block is large. This patch checks the basic block size
and just bails out if the size exceeds the limit set by command line
option "arc-contract-max-bb-size".

rdar://problem/49477063

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359027 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/ObjCARC/ObjCARCContract.cpp
test/Transforms/ObjCARC/contract-max-bb-size.ll [new file with mode: 0644]