@@ -7,6 +7,11 @@ sil_stage canonical
7
7
import Builtin
8
8
import Swift
9
9
10
+ internal enum Enum {
11
+ case one
12
+ case two
13
+ }
14
+
10
15
// CHECK-LABEL: sil @simple_test : $@convention(thin) () -> () {
11
16
// CHECK: bb0:
12
17
// CHECK-NEXT: tuple
27
32
%9999 = tuple ()
28
33
return %9999 : $()
29
34
}
35
+
36
+ // Test that SimplifyCFG::simplifyBlocks, tryJumpThreading does not
37
+ // perform unbounded loop peeling.
38
+ //
39
+ // rdar://73357726 ([SR-14068]: Compiling with optimisation runs indefinitely for grpc-swift)
40
+ // CHECK-LABEL: sil @testInfinitePeeling : $@convention(method) (Builtin.Int64, Enum) -> () {
41
+ //
42
+ // There is only one switch_enum blocks, and it is no longer in a loop.
43
+ // CHECK: bb0(%0 : $Builtin.Int64, %1 : $Enum):
44
+ // CHECK: switch_enum %1 : $Enum, case #Enum.one!enumelt: bb3, case #Enum.two!enumelt: bb4
45
+ // CHECK: bb1:
46
+ // CHECK: br bb8
47
+ // CHECK: bb2:
48
+ // CHECK: br bb5(%{{.*}} : $Enum)
49
+ //
50
+ // This is the original cond_br block
51
+ // CHECK: bb3:
52
+ // CHECK: cond_br %{{.*}}, bb2, bb1
53
+ // CHECK: bb4:
54
+ // CHECK: br bb5(%1 : $Enum)
55
+ //
56
+ // This is the cond_br block after jump-threading.
57
+ // CHECK: bb5(%{{.*}} : $Enum):
58
+ // CHECK: cond_br %{{.*}}, bb6, bb7
59
+ // CHECK: bb6:
60
+ // CHECK: br bb5(%{{.*}} : $Enum)
61
+ // CHECK: bb7:
62
+ // CHECK: br bb8
63
+ // CHECK: bb8:
64
+ // CHECK: return %19 : $()
65
+ // CHECK-LABEL: } // end sil function 'testInfinitePeeling'
66
+ sil @testInfinitePeeling : $@convention(method) (Builtin.Int64, Enum) -> () {
67
+ bb0(%0 : $Builtin.Int64, %1 : $Enum):
68
+ %2 = integer_literal $Builtin.Int64, 99999999
69
+ br bb1(%0 : $Builtin.Int64, %1 : $Enum)
70
+
71
+ bb1(%4 : $Builtin.Int64, %5 : $Enum):
72
+ switch_enum %5 : $Enum, case #Enum.one!enumelt: bb4, default bb5
73
+
74
+ bb2(%7 : $Builtin.Int64, %8 : $Enum):
75
+ %9 = builtin "cmp_slt_Int64"(%2 : $Builtin.Int64, %7 : $Builtin.Int64) : $Builtin.Int1
76
+ cond_br %9, bb3, bb6
77
+
78
+ bb3:
79
+ br bb1(%7 : $Builtin.Int64, %8 : $Enum)
80
+
81
+ bb4:
82
+ %12 = integer_literal $Builtin.Int64, 1
83
+ %13 = integer_literal $Builtin.Int1, -1
84
+ %14 = builtin "sadd_with_overflow_Int64"(%4 : $Builtin.Int64, %12 : $Builtin.Int64, %13 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
85
+ %15 = tuple_extract %14 : $(Builtin.Int64, Builtin.Int1), 0
86
+ %16 = enum $Enum, #Enum.two!enumelt
87
+ br bb2(%15 : $Builtin.Int64, %16 : $Enum)
88
+
89
+ bb5:
90
+ br bb2(%2 : $Builtin.Int64, %5 : $Enum)
91
+
92
+ bb6:
93
+ %19 = tuple ()
94
+ return %19 : $()
95
+ }
0 commit comments