File: constant_propagation_casts_ossa.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 (96 lines) | stat: -rw-r--r-- 2,754 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
87
88
89
90
91
92
93
94
95
96
// RUN: %target-sil-opt -enable-sil-verify-all %s -diagnostic-constant-propagation | %FileCheck %s
sil_stage canonical

//import Swift

class Klass {
}

class SubKlass : Klass {
}

class NoSubKlass {
}

sil [noinline] @blackhole1 : $@convention(thin) (@guaranteed SubKlass) -> ()
sil [noinline] @blackhole2 : $@convention(thin) (@guaranteed NoSubKlass) -> ()

// CHECK-LABEL: sil [ossa] @test_guaranteed_cast_opt1 :
// CHECK-NOT: checked_cast_br
// CHECK: upcast 
// CHECK-LABEL: } // end sil function 'test_guaranteed_cast_opt1'
sil [ossa] @test_guaranteed_cast_opt1 : $@convention(thin) (@owned SubKlass) -> () {
bb0(%0 : @owned $SubKlass):
  %borrow = begin_borrow %0 : $SubKlass
  checked_cast_br SubKlass in %borrow : $SubKlass to Klass, bb1, bb2

bb1(%val1 : @guaranteed $Klass):
  %copy = copy_value %val1: $Klass
  end_borrow %borrow : $SubKlass
  destroy_value %copy : $Klass
  br bb3

bb2(%val2 : @guaranteed $SubKlass):
  end_borrow %borrow : $SubKlass
  br bb3

bb3:
  destroy_value %0 : $SubKlass
  %r = tuple ()
  return %r : $()
}

// CHECK-LABEL: sil [ossa] @test_guaranteed_cast_opt2 :
// CHECK-NOT: checked_cast_br
// CHECK: upcast 
// CHECK-LABEL: } // end sil function 'test_guaranteed_cast_opt2'
sil [ossa] @test_guaranteed_cast_opt2 : $@convention(thin) (@owned SubKlass) -> () {
bb0(%0 : @owned $SubKlass):
  %borrow = begin_borrow %0 : $SubKlass
  checked_cast_br SubKlass in %borrow : $SubKlass to Klass, bb1, bb2

bb1(%val1 : @guaranteed $Klass):
  %copy = copy_value %val1: $Klass
  end_borrow %borrow : $SubKlass
  destroy_value %copy : $Klass
  br bb3

bb2(%val2 : @guaranteed $SubKlass):
  %func = function_ref @blackhole1 : $@convention(thin) (@guaranteed SubKlass) -> ()
  apply %func(%val2) : $@convention(thin) (@guaranteed SubKlass) -> ()
  end_borrow %borrow : $SubKlass
  br bb3

bb3:
  destroy_value %0 : $SubKlass
  %r = tuple ()
  return %r : $()
}

// CHECK-LABEL: sil [ossa] @test_guaranteed_cast_opt3 :
// CHECK-NOT: checked_cast_br
// CHECK: br bb2
// CHECK-LABEL: } // end sil function 'test_guaranteed_cast_opt3'
sil [ossa] @test_guaranteed_cast_opt3 : $@convention(thin) (@owned NoSubKlass) -> () {
bb0(%0 : @owned $NoSubKlass):
  %borrow = begin_borrow %0 : $NoSubKlass
  checked_cast_br NoSubKlass in %borrow : $NoSubKlass to Klass, bb1, bb2

bb1(%val1 : @guaranteed $Klass):
  %copy = copy_value %val1: $Klass
  end_borrow %borrow : $NoSubKlass
  destroy_value %copy : $Klass
  br bb3

bb2(%val2 : @guaranteed $NoSubKlass):
  %func = function_ref @blackhole2 : $@convention(thin) (@guaranteed NoSubKlass) -> ()
  apply %func(%val2) : $@convention(thin) (@guaranteed NoSubKlass) -> ()
  end_borrow %borrow : $NoSubKlass
  br bb3

bb3:
  destroy_value %0 : $NoSubKlass
  %r = tuple ()
  return %r : $()
}