File: simplify-cfg-debugonly.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 (86 lines) | stat: -rw-r--r-- 2,021 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
// 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)
}