File: simplify_switch_enum_objc_ossa.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 (138 lines) | stat: -rw-r--r-- 5,348 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// RUN: %target-sil-opt -test-runner %s 2>&1 | %FileCheck %s

// REQUIRES: objc_interop
import Swift
import Foundation

class Test : NSObject {
  @objc var other : Test? { get set }
}

// CHECK-LABEL: sil [ossa] @test_switch_enum_objc_call1 :
// CHECK-NOT: switch_enum
// CHECK-LABEL: } // end sil function 'test_switch_enum_objc_call1'
sil [ossa] @test_switch_enum_objc_call1 : $@convention(thin) (@guaranteed Optional<Test>) -> () {
bb0(%0 : @guaranteed $Optional<Test>):
  specify_test "simplify-cfg-simplify-switch-enum-on-objc-class-optional @instruction[1]"
  %3 = copy_value %0 : $Optional<Test>
  switch_enum %3 : $Optional<Test>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb6

bb1(%8 : @owned $Test):
  %9 = objc_method %8 : $Test, #Test.other!getter.foreign : (Test) -> () -> Test?, $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %10 = apply %9(%8) : $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  destroy_value %8 : $Test
  destroy_value %10 : $Optional<Test>
  br bb4

bb4:
  %20 = tuple ()
  return %20 : $()

bb6:
  br bb4
}

sil @some_sideeffect : $@convention(thin) () -> ()

// CHECK-LABEL: sil [ossa] @test_switch_enum_objc_call2 :
// CHECK-NOT: switch_enum
// CHECK-LABEL: } // end sil function 'test_switch_enum_objc_call2'
sil [ossa] @test_switch_enum_objc_call2 : $@convention(thin) (@guaranteed Optional<Test>) -> () {
bb0(%0 : @guaranteed $Optional<Test>):
  specify_test "simplify-cfg-simplify-switch-enum-on-objc-class-optional @instruction[1]"
  %3 = copy_value %0 : $Optional<Test>
  switch_enum %3 : $Optional<Test>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb6

bb1(%8 : @owned $Test):
  %9 = objc_method %8 : $Test, #Test.other!getter.foreign : (Test) -> () -> Test?, $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %10 = apply %9(%8) : $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %14 = objc_method %8 : $Test, #Test.other!setter.foreign : (Test) -> (Test?) -> (), $@convention(objc_method) (Optional<Test>, Test) -> ()
  %18 = apply %14(%10, %8) : $@convention(objc_method) (Optional<Test>, Test) -> ()
  destroy_value %10 : $Optional<Test>
  destroy_value %8 : $Test
  br bb4

bb4:
  %20 = tuple ()
  return %20 : $()

bb6:
  br bb4
}

// CHECK-LABEL: sil [ossa] @test_switch_enum_objc_call3 :
// CHECK: switch_enum
// CHECK-LABEL: } // end sil function 'test_switch_enum_objc_call3'
sil [ossa] @test_switch_enum_objc_call3 : $@convention(thin) (@guaranteed Optional<Test>) -> () {
bb0(%0 : @guaranteed $Optional<Test>):
  specify_test "simplify-cfg-simplify-switch-enum-on-objc-class-optional @instruction[1]"
  %3 = copy_value %0 : $Optional<Test>
  switch_enum %3 : $Optional<Test>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb6

bb1(%8 : @owned $Test):
  %9 = objc_method %8 : $Test, #Test.other!getter.foreign : (Test) -> () -> Test?, $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %10 = apply %9(%8) : $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %11 = function_ref @some_sideeffect : $@convention(thin) () -> ()
  apply %11() : $@convention(thin) () -> ()
  destroy_value %10 : $Optional<Test>
  destroy_value %8 : $Test
  br bb4

bb4:
  %20 = tuple ()
  return %20 : $()

bb6:
  br bb4
}

// CHECK-LABEL: sil [ossa] @test_switch_enum_objc_call4 :
// CHECK: switch_enum
// CHECK-LABEL: } // end sil function 'test_switch_enum_objc_call4'
sil [ossa] @test_switch_enum_objc_call4 : $@convention(thin) (@guaranteed Optional<Test>) -> () {
bb0(%0 : @guaranteed $Optional<Test>):
  specify_test "simplify-cfg-simplify-switch-enum-on-objc-class-optional @instruction[1]"
  %3 = copy_value %0 : $Optional<Test>
  switch_enum %3 : $Optional<Test>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb6

bb1(%8 : @owned $Test):
  %9 = objc_method %8 : $Test, #Test.other!getter.foreign : (Test) -> () -> Test?, $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %10 = apply %9(%8) : $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  destroy_value %10 : $Optional<Test>
  destroy_value %8 : $Test
  br bb4

bb4:
  %20 = tuple ()
  return %20 : $()

bb6:
  %11 = function_ref @some_sideeffect : $@convention(thin) () -> ()
  apply %11() : $@convention(thin) () -> ()
  br bb4
}

// CHECK-LABEL: sil [ossa] @test_switch_enum_objc_call5 :
// CHECK-NOT: switch_enum
// CHECK-LABEL: } // end sil function 'test_switch_enum_objc_call5'
sil [ossa] @test_switch_enum_objc_call5 : $@convention(thin) (@guaranteed Optional<Test>) -> () {
bb0(%0 : @guaranteed $Optional<Test>):
  specify_test "simplify-cfg-simplify-switch-enum-on-objc-class-optional @instruction[0]"
  switch_enum %0 : $Optional<Test>, case #Optional.some!enumelt: bb1, case #Optional.none!enumelt: bb6

bb1(%8 : @guaranteed $Test):
  %copy = copy_value %0 : $Optional<Test>
  %some = unchecked_enum_data %0 : $Optional<Test>, #Optional.some
  %9 = objc_method %8 : $Test, #Test.other!getter.foreign : (Test) -> () -> Test?, $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  %10 = apply %9(%some) : $@convention(objc_method) (Test) -> @autoreleased Optional<Test>
  destroy_value %10 : $Optional<Test>
  destroy_value %copy : $Optional<Test>
  br bb4

bb4:
  %20 = tuple ()
  return %20 : $()

bb6:
  br bb4
}