This is an archive of the discontinued LLVM Phabricator instance.

[ObjC][ARC] Check the basic block size before calling DominatorTree::dominate
ClosedPublic

Authored by ahatanak on Apr 18 2019, 11:26 PM.

Details

Summary

ARC contract pass has an optimization that replaces the uses of the argument of an ObjC runtime function calls 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, 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.

rdar://problem/49477063

Diff Detail

Repository
rC Clang

Event Timeline

ahatanak created this revision.Apr 18 2019, 11:26 PM
pete accepted this revision.Apr 19 2019, 11:06 AM

LGTM.

This revision is now accepted and ready to land.Apr 19 2019, 11:06 AM
ahatanak updated this revision to Diff 195951.Apr 19 2019, 6:11 PM

Fix the comment on why we have to check the size of the basic block before calling DominatorTree::dominate to compute the dominance relation between two instructions in the same basic block.

Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2019, 6:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ahatanak removed a project: Restricted Project.Apr 19 2019, 6:19 PM
ahatanak removed a subscriber: cfe-commits.
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2019, 6:19 PM
ahatanak removed a project: Restricted Project.Apr 19 2019, 6:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2019, 6:20 PM
This revision was automatically updated to reflect the committed changes.