llvm.org GIT mirror llvm / 06a55fc
[LoopSink] Do not sink instructions into non-cold blocks Summary: This fixes PR39570. Reviewers: danielcdh, rnk, bkramer Reviewed By: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54181 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346337 91177308-0d34-0410-b5e6-96231b3b80d8 Mandeep Singh Grang 11 months ago
2 changed file(s) with 119 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
200200 findBBsToSinkInto(L, BBs, ColdLoopBBs, DT, BFI);
201201 if (BBsToSinkInto.empty())
202202 return false;
203
204 // Return if any of the candidate blocks to sink into is non-cold.
205 if (BBsToSinkInto.size() > 1) {
206 for (auto *BB : BBsToSinkInto)
207 if (!LoopBlockNumber.count(BB))
208 return false;
209 }
203210
204211 // Copy the final BBs into a vector and sort them using the total ordering
205212 // of the loop block numbers as iterating the set doesn't give a useful
0 ; RUN: opt -S -loop-sink < %s | FileCheck %s
1
2 ; CHECK: pr39570
3 ; Make sure not to assert.
4
5 %0 = type { i32, %1*, %2, %6*, %33* }
6 %1 = type { i32 (...)** }
7 %2 = type { %3* }
8 %3 = type { %4, i32, %5* }
9 %4 = type { i32 (...)**, i32 }
10 %5 = type opaque
11 %6 = type { %7, %1*, %31*, i8, %2, %32* }
12 %7 = type <{ %8, %9*, %10, i32, %33*, %33*, %33*, %27, %28, i16 }>
13 %8 = type { i32 (...)** }
14 %9 = type opaque
15 %10 = type { %11, %16, %18, %19 }
16 %11 = type { %12*, i32, i32, %13* }
17 %12 = type { i32 (...)** }
18 %13 = type { %14*, %14* }
19 %14 = type { %15, i32 }
20 %15 = type { %12*, i32, i32, i16* }
21 %16 = type { %12*, i32, i32, %17* }
22 %17 = type { %13, %14* }
23 %18 = type { %12*, i32, i32, %14** }
24 %19 = type { %20, %21, %12*, float, i32, i32, %22, %22, %24, i32, i32 }
25 %20 = type { i8 }
26 %21 = type { i8 }
27 %22 = type { %12*, %23*, %23* }
28 %23 = type opaque
29 %24 = type { %12*, i32, i32, %25* }
30 %25 = type { %12*, i32, i32, %26* }
31 %26 = type opaque
32 %27 = type { %33* }
33 %28 = type { %29, i32, i32, %14* }
34 %29 = type { %30 }
35 %30 = type { i32 (...)** }
36 %31 = type opaque
37 %32 = type { i32 (...)** }
38 %33 = type <{ %8, %9*, %10, i32, %33*, %33*, %33*, %27, %28, i16, [2 x i8] }>
39
40 define dso_local void @pr39570() local_unnamed_addr align 2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !prof !1 {
41 br i1 undef, label %8, label %1, !prof !2
42
43 ;
44 %2 = load %0*, %0** undef, align 4
45 br label %3
46
47 ;
48 %4 = getelementptr inbounds %0, %0* %2, i32 undef, i32 0
49 br label %5
50
51 ;
52 %6 = getelementptr inbounds %0, %0* %2, i32 undef, i32 4
53 br i1 undef, label %18, label %7, !prof !3
54
55 ;
56 br label %3
57
58 ;
59 invoke void @baz()
60 to label %9 unwind label %12
61
62 ;
63 invoke void @bar()
64 to label %17 unwind label %10
65
66 ;
67 %11 = landingpad { i8*, i32 }
68 catch i8* null
69 unreachable
70
71 ;
72 %13 = landingpad { i8*, i32 }
73 cleanup
74 invoke void @bar()
75 to label %16 unwind label %14
76
77 ;
78 %15 = landingpad { i8*, i32 }
79 catch i8* null
80 unreachable
81
82 ;
83 resume { i8*, i32 } %13
84
85 ;
86 br label %18
87
88 ;
89 invoke void @baz()
90 to label %19 unwind label %20
91
92 ;
93 invoke void @bar()
94 to label %22 unwind label %20
95
96 ;
97 %21 = landingpad { i8*, i32 }
98 catch i8* null
99 unreachable
100
101 ;
102 ret void
103 }
104
105 declare dso_local i32 @__gxx_personality_v0(...)
106 declare dso_local void @bar() local_unnamed_addr
107 declare dso_local void @baz() local_unnamed_addr align 2
108
109 !1 = !{!"function_entry_count", i64 0}
110 !2 = !{!"branch_weights", i32 1, i32 3215551}
111 !3 = !{!"branch_weights", i32 3215551, i32 1}