llvm.org GIT mirror llvm / 7f8cd41
[BPI] Consider deoptimize calls as "unreachable" Summary: Calls to @llvm.experimental.deoptimize are expected to "never execute", so optimize them as such. Reviewers: chandlerc Subscribers: junbuml, mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D19095 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266654 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjoy Das 4 years ago
2 changed file(s) with 26 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
114114 bool BranchProbabilityInfo::calcUnreachableHeuristics(const BasicBlock *BB) {
115115 const TerminatorInst *TI = BB->getTerminator();
116116 if (TI->getNumSuccessors() == 0) {
117 if (isa(TI))
117 if (isa(TI) ||
118 // If this block is terminated by a call to
119 // @llvm.experimental.deoptimize then treat it like an unreachable since
120 // the @llvm.experimental.deoptimize call is expected to practically
121 // never execute.
122 BB->getTerminatingDeoptimizeCall())
118123 PostDominatedByUnreachable.insert(BB);
119124 return false;
120125 }
0 ; RUN: opt -analyze -branch-prob < %s | FileCheck %s
1
2 declare i32 @llvm.experimental.deoptimize.i32(...)
3
4 define i32 @test1(i32 %a, i32 %b) {
5 ; CHECK-LABEL: Printing analysis 'Branch Probability Analysis' for function 'test1':
6 entry:
7 %cond = icmp eq i32 %a, 42
8 br i1 %cond, label %exit, label %deopt
9
10 ; CHECK: edge entry -> exit probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
11 ; CHECK: edge entry -> deopt probability is 0x00000800 / 0x80000000 = 0.00%
12
13 deopt:
14 %rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"() ]
15 ret i32 %rval
16
17 exit:
18 ret i32 %b
19 }