llvm.org GIT mirror llvm / 9d522dc
- Removed unused lamba (IsReturnBlock) causing build bots to fail for r319398 - Added lit testcases that were supposed to be part of r319398 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319399 91177308-0d34-0410-b5e6-96231b3b80d8 Graham Yiu 1 year, 9 months ago
3 changed file(s) with 290 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
407407
408408 auto &ORE = (*GetORE)(*F);
409409
410 auto IsReturnBlock = [](BasicBlock *BB) {
411 TerminatorInst *TI = BB->getTerminator();
412 return isa(TI);
413 };
414
415410 // Return if we don't have profiling information.
416411 if (!PSI->hasInstrumentationProfile())
417412 return std::unique_ptr();
426421 };
427422
428423 auto IsSingleExit =
429 [IsReturnBlock,
430 &ORE](SmallVectorImpl &BlockList) -> BasicBlock * {
424 [&ORE](SmallVectorImpl &BlockList) -> BasicBlock * {
431425 BasicBlock *ExitBlock = nullptr;
432426 for (auto *Block : BlockList) {
433427 for (auto SI = succ_begin(Block); SI != succ_end(Block); ++SI) {
0 ; RUN: opt -S -partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
1 ; RUN: opt -S -passes=partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
2 ; Require a dummy block (if.then.b) as successor to if.then due to PI requirement
3 ; of region containing more than one BB.
4 define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 {
5 entry:
6 %value.addr = alloca i32, align 4
7 %ub.addr = alloca i32, align 4
8 %sum = alloca i32, align 4
9 %i = alloca i32, align 4
10 store i32 %value, i32* %value.addr, align 4
11 store i32 %ub, i32* %ub.addr, align 4
12 store i32 0, i32* %sum, align 4
13 store i32 0, i32* %i, align 4
14 br label %for.cond
15
16 for.cond: ; preds = %for.inc, %entry
17 %0 = load i32, i32* %i, align 4
18 %1 = load i32, i32* %ub.addr, align 4
19 %cmp = icmp slt i32 %0, %1
20 br i1 %cmp, label %for.body, label %for.cond2, !prof !31
21
22 for.body: ; preds = %for.cond
23 %2 = load i32, i32* %value.addr, align 4
24 %rem = srem i32 %2, 20
25 %cmp1 = icmp eq i32 %rem, 0
26 br i1 %cmp1, label %if.then, label %if.else, !prof !32
27
28 if.then: ; preds = %for.body
29 %3 = load i32, i32* %value.addr, align 4
30 %4 = load i32, i32* %i, align 4
31 %mul = mul nsw i32 %4, 5
32 %add = add nsw i32 %3, %mul
33 %5 = load i32, i32* %sum, align 4
34 %add2 = add nsw i32 %5, %add
35 store i32 %add2, i32* %sum, align 4
36 br label %if.then.b
37
38 if.then.b: ; preds = %if.then
39 br label %if.end
40
41 if.else: ; preds = %for.body
42 %6 = load i32, i32* %value.addr, align 4
43 %7 = load i32, i32* %i, align 4
44 %sub = sub nsw i32 %6, %7
45 %8 = load i32, i32* %sum, align 4
46 %add3 = add nsw i32 %8, %sub
47 store i32 %add3, i32* %sum, align 4
48 br label %if.end
49
50 if.end: ; preds = %if.else, %if.then
51 br label %for.inc
52
53 for.inc: ; preds = %if.end
54 %9 = load i32, i32* %i, align 4
55 %inc = add nsw i32 %9, 1
56 store i32 %inc, i32* %i, align 4
57 br label %for.cond
58
59 for.cond2: ; preds = %for.cond
60 %10 = load i32, i32* %i, align 4
61 %11 = load i32, i32* %ub.addr, align 4
62 %cmp2 = icmp slt i32 %10, %11
63 br i1 %cmp2, label %for.body2, label %for.end, !prof !31
64
65 for.body2: ; preds = %for.cond2
66 %12 = load i32, i32* %value.addr, align 4
67 %rem2 = srem i32 %12, 20
68 %cmp3 = icmp eq i32 %rem2, 0
69 br i1 %cmp3, label %if.then2, label %if.else2, !prof !32
70
71 if.then2: ; preds = %for.body2
72 %13 = load i32, i32* %value.addr, align 4
73 %14 = load i32, i32* %i, align 4
74 %mul2 = mul nsw i32 %14, 5
75 %add4 = add nsw i32 %13, %mul2
76 %15 = load i32, i32* %sum, align 4
77 %add5 = add nsw i32 %15, %add4
78 store i32 %add5, i32* %sum, align 4
79 br label %if.then2.b
80
81 if.then2.b: ; preds = %if.then2
82 br label %if.end2
83
84 if.else2: ; preds = %for.body2
85 %16 = load i32, i32* %value.addr, align 4
86 %17 = load i32, i32* %i, align 4
87 %sub2 = sub nsw i32 %16, %17
88 %18 = load i32, i32* %sum, align 4
89 %add6 = add nsw i32 %18, %sub2
90 store i32 %add6, i32* %sum, align 4
91 br label %if.end2
92
93 if.end2: ; preds = %if.else2, %if.then2
94 br label %for.inc2
95
96 for.inc2: ; preds = %if.end2
97 %19 = load i32, i32* %i, align 4
98 %inc2 = add nsw i32 %19, 1
99 store i32 %inc2, i32* %i, align 4
100 br label %for.cond2
101
102 for.end: ; preds = %for.cond2
103 %20 = load i32, i32* %sum, align 4
104 ret i32 %20
105 }
106
107 define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 {
108 ; CHECK-LABEL: @foo
109 ; CHECK-NOT: call signext i32 @bar
110 ; CHECK: codeRepl1.i:
111 ; CHECK: call void @bar.1_if.then
112 ; CHECK: codeRepl.i:
113 ; CHECK: call void @bar.1_if.then2
114 entry:
115 %value.addr = alloca i32, align 4
116 %ub.addr = alloca i32, align 4
117 store i32 %value, i32* %value.addr, align 4
118 store i32 %ub, i32* %ub.addr, align 4
119 %0 = load i32, i32* %value.addr, align 4
120 %1 = load i32, i32* %ub.addr, align 4
121 %call = call signext i32 @bar(i32 signext %0, i32 signext %1)
122 ret i32 %call
123 }
124
125 ; CHECK-LABEL: define internal void @bar.1_if.then2
126 ; CHECK: .exitStub:
127 ; CHECK: ret void
128
129 ; CHECK-LABEL: define internal void @bar.1_if.then
130 ; CHECK: .exitStub:
131 ; CHECK: ret void
132
133 !llvm.module.flags = !{!0, !1, !2}
134 !llvm.ident = !{!29}
135
136 !0 = !{i32 1, !"wchar_size", i32 4}
137 !1 = !{i32 7, !"PIC Level", i32 2}
138 !2 = !{i32 1, !"ProfileSummary", !3}
139 !3 = !{!4, !5, !6, !7, !8, !9, !10, !11}
140 !4 = !{!"ProfileFormat", !"InstrProf"}
141 !5 = !{!"TotalCount", i64 103}
142 !6 = !{!"MaxCount", i64 100}
143 !7 = !{!"MaxInternalCount", i64 1}
144 !8 = !{!"MaxFunctionCount", i64 100}
145 !9 = !{!"NumCounts", i64 5}
146 !10 = !{!"NumFunctions", i64 3}
147 !11 = !{!"DetailedSummary", !12}
148 !12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28}
149 !13 = !{i32 10000, i64 100, i32 1}
150 !14 = !{i32 100000, i64 100, i32 1}
151 !15 = !{i32 200000, i64 100, i32 1}
152 !16 = !{i32 300000, i64 100, i32 1}
153 !17 = !{i32 400000, i64 100, i32 1}
154 !18 = !{i32 500000, i64 100, i32 1}
155 !19 = !{i32 600000, i64 100, i32 1}
156 !20 = !{i32 700000, i64 100, i32 1}
157 !21 = !{i32 800000, i64 100, i32 1}
158 !22 = !{i32 900000, i64 100, i32 1}
159 !23 = !{i32 950000, i64 100, i32 1}
160 !24 = !{i32 990000, i64 1, i32 4}
161 !25 = !{i32 999000, i64 1, i32 4}
162 !26 = !{i32 999900, i64 1, i32 4}
163 !27 = !{i32 999990, i64 1, i32 4}
164 !28 = !{i32 999999, i64 1, i32 4}
165 !29 = !{!"clang version 6.0.0 (123456)"}
166 !30 = !{!"function_entry_count", i64 2}
167 !31 = !{!"branch_weights", i32 100, i32 1}
168 !32 = !{!"branch_weights", i32 0, i32 100}
0 ; RUN: opt -S -partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
1 ; RUN: opt -S -passes=partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
2 ; Require a dummy block (if.then.b) as successor to if.then due to PI requirement
3 ; of region containing more than one BB.
4 define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 {
5 entry:
6 %value.addr = alloca i32, align 4
7 %ub.addr = alloca i32, align 4
8 %sum = alloca i32, align 4
9 %i = alloca i32, align 4
10 store i32 %value, i32* %value.addr, align 4
11 store i32 %ub, i32* %ub.addr, align 4
12 store i32 0, i32* %sum, align 4
13 store i32 0, i32* %i, align 4
14 br label %for.cond
15
16 for.cond: ; preds = %for.inc, %entry
17 %0 = load i32, i32* %i, align 4
18 %1 = load i32, i32* %ub.addr, align 4
19 %cmp = icmp slt i32 %0, %1
20 br i1 %cmp, label %for.body, label %for.end, !prof !31
21
22 for.body: ; preds = %for.cond
23 %2 = load i32, i32* %value.addr, align 4
24 %rem = srem i32 %2, 20
25 %cmp1 = icmp eq i32 %rem, 0
26 br i1 %cmp1, label %if.then, label %if.else, !prof !32
27
28 if.then: ; preds = %for.body
29 %3 = load i32, i32* %value.addr, align 4
30 %4 = load i32, i32* %i, align 4
31 %mul = mul nsw i32 %4, 5
32 %add = add nsw i32 %3, %mul
33 %5 = load i32, i32* %sum, align 4
34 %add2 = add nsw i32 %5, %add
35 store i32 %add2, i32* %sum, align 4
36 br label %if.then.b
37
38 if.then.b: ; preds = %if.then
39 br label %if.end
40
41 if.else: ; preds = %for.body
42 %6 = load i32, i32* %value.addr, align 4
43 %7 = load i32, i32* %i, align 4
44 %sub = sub nsw i32 %6, %7
45 %8 = load i32, i32* %sum, align 4
46 %add3 = add nsw i32 %8, %sub
47 store i32 %add3, i32* %sum, align 4
48 br label %if.end
49
50 if.end: ; preds = %if.else, %if.then
51 br label %for.inc
52
53 for.inc: ; preds = %if.end
54 %9 = load i32, i32* %i, align 4
55 %inc = add nsw i32 %9, 1
56 store i32 %inc, i32* %i, align 4
57 br label %for.cond
58
59 for.end: ; preds = %for.cond
60 %10 = load i32, i32* %sum, align 4
61 ret i32 %10
62 }
63
64 define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 {
65 ; CHECK-LABEL: @foo
66 ; CHECK: codeRepl.i:
67 ; CHECK-NOT: call signext i32 @bar
68 ; CHECK: call void @bar.1_if.then
69 entry:
70 %value.addr = alloca i32, align 4
71 %ub.addr = alloca i32, align 4
72 store i32 %value, i32* %value.addr, align 4
73 store i32 %ub, i32* %ub.addr, align 4
74 %0 = load i32, i32* %value.addr, align 4
75 %1 = load i32, i32* %ub.addr, align 4
76 %call = call signext i32 @bar(i32 signext %0, i32 signext %1)
77 ret i32 %call
78 }
79
80 ; CHECK-LABEL: define internal void @bar.1_if.then
81 ; CHECK: .exitStub:
82 ; CHECK: ret void
83
84 !llvm.module.flags = !{!0, !1, !2}
85 !llvm.ident = !{!29}
86
87 !0 = !{i32 1, !"wchar_size", i32 4}
88 !1 = !{i32 7, !"PIC Level", i32 2}
89 !2 = !{i32 1, !"ProfileSummary", !3}
90 !3 = !{!4, !5, !6, !7, !8, !9, !10, !11}
91 !4 = !{!"ProfileFormat", !"InstrProf"}
92 !5 = !{!"TotalCount", i64 103}
93 !6 = !{!"MaxCount", i64 100}
94 !7 = !{!"MaxInternalCount", i64 1}
95 !8 = !{!"MaxFunctionCount", i64 100}
96 !9 = !{!"NumCounts", i64 5}
97 !10 = !{!"NumFunctions", i64 3}
98 !11 = !{!"DetailedSummary", !12}
99 !12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28}
100 !13 = !{i32 10000, i64 100, i32 1}
101 !14 = !{i32 100000, i64 100, i32 1}
102 !15 = !{i32 200000, i64 100, i32 1}
103 !16 = !{i32 300000, i64 100, i32 1}
104 !17 = !{i32 400000, i64 100, i32 1}
105 !18 = !{i32 500000, i64 100, i32 1}
106 !19 = !{i32 600000, i64 100, i32 1}
107 !20 = !{i32 700000, i64 100, i32 1}
108 !21 = !{i32 800000, i64 100, i32 1}
109 !22 = !{i32 900000, i64 100, i32 1}
110 !23 = !{i32 950000, i64 100, i32 1}
111 !24 = !{i32 990000, i64 1, i32 4}
112 !25 = !{i32 999000, i64 1, i32 4}
113 !26 = !{i32 999900, i64 1, i32 4}
114 !27 = !{i32 999990, i64 1, i32 4}
115 !28 = !{i32 999999, i64 1, i32 4}
116 !29 = !{!"clang version 6.0.0 (123456)"}
117 !30 = !{!"function_entry_count", i64 2}
118 !31 = !{!"branch_weights", i32 100, i32 1}
119 !32 = !{!"branch_weights", i32 0, i32 100}