File: loop_info_printer.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (121 lines) | stat: -rw-r--r-- 4,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// RUN: %target-sil-opt -enable-sil-verify-all %s -loop-info-printer 2>&1 | %FileCheck %s

// REQUIRES: asserts

import Builtin
import Swift

sil_stage canonical

// CHECK-LABEL: Loops in  simple_loop_with_enum
// CHECK: Loop at depth 1 containing: bb1<header>,bb3,bb2,bb4<exiting>,bb5<latch>

sil @simple_loop_with_enum : $@convention(thin) () -> () {
bb0:
  %0 = integer_literal $Builtin.Int32, 0
  %1 = integer_literal $Builtin.Int32, 1000
  br bb1(%0 : $Builtin.Int32)

bb1(%3 : $Builtin.Int32):
  %4 = struct $Int32 (%3 : $Builtin.Int32)
  %6 = builtin "cmp_eq_Int32"(%3 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  cond_br %6, bb2, bb3

bb2:
  %8 = enum $Optional<Int32>, #Optional.none!enumelt
  br bb4(%3 : $Builtin.Int32, %8 : $Optional<Int32>)

bb3:
  %10 = integer_literal $Builtin.Int32, 1
  %12 = integer_literal $Builtin.Int1, -1
  %13 = builtin "sadd_with_overflow_Int32"(%3 : $Builtin.Int32, %10 : $Builtin.Int32, %12 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
  %14 = tuple_extract %13 : $(Builtin.Int32, Builtin.Int1), 0
  %15 = tuple_extract %13 : $(Builtin.Int32, Builtin.Int1), 1
  cond_fail %15 : $Builtin.Int1
  %17 = enum $Optional<Int32>, #Optional.some!enumelt, %4 : $Int32
  br bb4(%14 : $Builtin.Int32, %17 : $Optional<Int32>)

bb4(%19 : $Builtin.Int32, %20 : $Optional<Int32>):
  switch_enum %20 : $Optional<Int32>, case #Optional.some!enumelt: bb5, case #Optional.none!enumelt: bb6

bb5:
  br bb1(%19 : $Builtin.Int32)

bb6:
  %23 = tuple ()
  return %23 : $()
}

// CHECK-LABEL: Loops in simple_loop
// CHECK:  Loop at depth 1 containing: bb1<header><exiting>,bb2<latch>

sil @simple_loop : $@convention(thin) () -> () {
bb0:
  %0 = integer_literal $Builtin.Int32, 0
  %1 = integer_literal $Builtin.Int32, 1000
  br bb1(%0 : $Builtin.Int32)

bb1(%3 : $Builtin.Int32):
  %4 = struct $Int32 (%3 : $Builtin.Int32)
  %6 = builtin "cmp_eq_Int32"(%3 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  cond_br %6, bb3, bb2

bb2:
  %8 = integer_literal $Builtin.Int32, 1
  %10 = integer_literal $Builtin.Int1, -1
  %11 = builtin "sadd_with_overflow_Int32"(%3 : $Builtin.Int32, %8 : $Builtin.Int32, %10 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
  %12 = tuple_extract %11 : $(Builtin.Int32, Builtin.Int1), 0
  %13 = tuple_extract %11 : $(Builtin.Int32, Builtin.Int1), 1
  cond_fail %13 : $Builtin.Int1
  %15 = enum $Optional<Int32>, #Optional.some!enumelt, %4 : $Int32
  br bb1(%12 : $Builtin.Int32)

bb3:
  %17 = tuple ()
  return %17 : $()
}

// CHECK-LABEL: nested_loop
// CHECK: Loop at depth 1 containing: bb1<header><exiting>,bb2,bb4,bb5,bb6<latch>
// CHECK:    Loop at depth 2 containing: bb4<header><exiting>,bb5<latch>

sil @nested_loop : $@convention(thin) () -> () {
bb0:
  %0 = integer_literal $Builtin.Int32, 0
  %1 = integer_literal $Builtin.Int32, 1000
  br bb1(%0 : $Builtin.Int32)

bb1(%3 : $Builtin.Int32):
  %5 = builtin "cmp_eq_Int32"(%3 : $Builtin.Int32, %1 : $Builtin.Int32) : $Builtin.Int1
  cond_br %5, bb3, bb2

bb2:
  %7 = integer_literal $Builtin.Int32, 1
  %9 = integer_literal $Builtin.Int1, -1
  %10 = builtin "sadd_with_overflow_Int32"(%3 : $Builtin.Int32, %7 : $Builtin.Int32, %9 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
  %11 = tuple_extract %10 : $(Builtin.Int32, Builtin.Int1), 0
  %12 = tuple_extract %10 : $(Builtin.Int32, Builtin.Int1), 1
  cond_fail %12 : $Builtin.Int1
  %14 = integer_literal $Builtin.Int32, 2000
  br bb4(%0 : $Builtin.Int32)

bb3:
  %16 = tuple ()
  return %16 : $()

bb4(%18 : $Builtin.Int32):
  %19 = builtin "cmp_eq_Int32"(%18 : $Builtin.Int32, %14 : $Builtin.Int32) : $Builtin.Int1
  cond_br %19, bb6, bb5

bb5:
  %21 = integer_literal $Builtin.Int32, 1
  %23 = integer_literal $Builtin.Int1, -1
  %24 = builtin "sadd_with_overflow_Int32"(%18 : $Builtin.Int32, %21 : $Builtin.Int32, %23 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
  %25 = tuple_extract %24 : $(Builtin.Int32, Builtin.Int1), 0
  %26 = tuple_extract %24 : $(Builtin.Int32, Builtin.Int1), 1
  cond_fail %26 : $Builtin.Int1
  br bb4(%25 : $Builtin.Int32)

bb6:
  br bb1(%11 : $Builtin.Int32)
}