llvm.org GIT mirror llvm / 8c9cc1f
[PartialInlining] Use isInlineViable to detect constructs preventing inlining. Use isInlineViable to prevent inlining of functions with non-inlinable constructs, in case cost analysis is skipped. Reviewers: efriedma, sfertile, davide, davidxl Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D42846 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327207 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 1 year, 6 months ago
2 changed file(s) with 66 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
768768 BlockFrequency WeightedOutliningRcost) {
769769 using namespace ore;
770770
771 if (SkipCostAnalysis)
772 return true;
773
774771 Instruction *Call = CS.getInstruction();
775772 Function *Callee = CS.getCalledFunction();
776773 assert(Callee == Cloner.ClonedFunc);
774
775 if (SkipCostAnalysis)
776 return isInlineViable(*Callee);
777777
778778 Function *Caller = CS.getCaller();
779779 auto &CalleeTTI = (*GetTTI)(*Callee);
0 ; RUN: opt < %s -partial-inliner -skip-partial-inlining-cost-analysis -S | FileCheck %s
1 ;
2
3 define i32 @callee_indr_branch(i32 %v) {
4 entry:
5 %cmp = icmp sgt i32 %v, 2000
6 %addr = select i1 %cmp, i8* blockaddress(@callee_indr_branch, %if.then), i8* blockaddress(@callee_indr_branch, %if.end)
7 indirectbr i8* %addr, [ label %if.then, label %if.end]
8
9 if.then: ; preds = %entry
10 %mul = mul nsw i32 %v, 10
11 br label %if.then2
12
13 if.then2:
14 %sub = sub i32 %v, 10
15 br label %if.end
16
17 if.end: ; preds = %if.then, %entry
18 %v2 = phi i32 [ %v, %entry ], [ %mul, %if.then2 ]
19 %add = add nsw i32 %v2, 200
20 ret i32 %add
21 }
22
23 declare void @use_fp(i8 *)
24 declare void @llvm.localescape(...)
25 declare i8* @llvm.frameaddress(i32)
26 declare i8* @llvm.localrecover(i8*, i8*, i32)
27
28
29
30 define i32 @callee_frameescape(i32 %v) {
31 entry:
32 %a = alloca i32
33 call void (...) @llvm.localescape(i32* %a)
34 %cmp = icmp sgt i32 %v, 2000
35 br i1 %cmp, label %if.then, label %if.end
36
37 if.then: ; preds = %entry
38 %mul = mul nsw i32 %v, 10
39 br label %if.then2
40
41 if.then2:
42 %sub = sub i32 %v, 10
43 br label %if.end
44
45 if.end: ; preds = %if.then, %entry
46 %v2 = phi i32 [ %v, %entry ], [ %mul, %if.then2 ]
47 %add = add nsw i32 %v2, 200
48 ret i32 %add
49 }
50
51
52 ; CHECK-LABEL: @caller
53 ; CHECK: %r1 = call i32 @callee_indr_branch(i32 %v)
54 ; CHECK-NEXT: %r2 = call i32 @callee_frameescape(i32 %v)
55 define i32 @caller(i32 %v) {
56 entry:
57 %r1 = call i32 @callee_indr_branch(i32 %v)
58 %r2 = call i32 @callee_frameescape(i32 %v)
59 %res = add i32 %r1, %r2
60 ret i32 %res
61 }
62