File: simplify-cfg-debugonly.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (86 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download | duplicates (2)
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
// RUN: %target-sil-opt -enable-sil-verify-all -simplify-cfg -debug-only=sil-simplify-cfg %s -o /dev/null 2>&1 | %FileCheck %s

// REQUIRES: asserts

import Builtin
import Swift

import Builtin
import Swift

protocol OtherKlass : AnyObject {}

class Klass {}

sil @getKlass : $@convention(thin) () -> @owned Klass

// Verify that checked-cast jump-threading kicks in and generates verifiable SIL.
//
// CHECK: Condition is the same if reached over {{.*}} parent @$testCheckCastJumpThread : $@convention(thin) (@guaranteed Klass) -> @owned any OtherKlass }
// CHECK-NEXT: bb3(%{{.*}} : $any OtherKlass):
// CHECK-NEXT:   br bb5(%{{.*}} : $Klass)
sil shared @$testCheckCastJumpThread : $@convention(thin) (@guaranteed Klass) -> @owned OtherKlass {
bb0(%0 : $Klass):
  %1 = function_ref @getKlass : $@convention(thin) () -> @owned Klass
  %2 = integer_literal $Builtin.Int64, 1
  %3 = apply %1() : $@convention(thin) () -> @owned Klass
  checked_cast_br Klass in %3 : $Klass to OtherKlass, bb1, bb2

bb1(%5 : $OtherKlass):
  %6 = integer_literal $Builtin.Int1, -1
  br bb3(%6 : $Builtin.Int1)

bb2:
  %8 = integer_literal $Builtin.Int1, 0
  br bb3(%8 : $Builtin.Int1)

bb3(%10 : $Builtin.Int1):
  cond_br %10, bb5, bb6

bb4:
  unreachable

bb5:
  br bb7(%3 : $Klass)

bb6:
  strong_release %3 : $Klass
  br bb10(%2 : $Builtin.Int64)

bb7(%16 : $Klass):
  checked_cast_br Klass in %16 : $Klass to OtherKlass, bb9, bb8

bb8:
  strong_release %16 : $Klass
  br bb4

bb9(%20 : $OtherKlass):
  return %20 : $OtherKlass

bb10(%22 : $Builtin.Int64):
  %23 = apply %1() : $@convention(thin) () -> @owned Klass
  checked_cast_br Klass in %23 : $Klass to OtherKlass, bb11, bb12

bb11(%25 : $OtherKlass):
  %26 = integer_literal $Builtin.Int1, -1
  br bb13(%26 : $Builtin.Int1)

bb12:
  %28 = integer_literal $Builtin.Int1, 0
  br bb13(%28 : $Builtin.Int1)

bb13(%30 : $Builtin.Int1):
  cond_br %30, bb14, bb15

bb14:
  br bb7(%23 : $Klass)

bb15:
  cond_br undef, bb16, bb17

bb16:
  br bb4

bb17:
  br bb10(undef : $Builtin.Int64)
}