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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
|
// RUN: %target-sil-opt -enable-objc-interop %s | %target-sil-opt -enable-objc-interop | %FileCheck %s
sil_stage raw
import Builtin
import Swift
protocol P { }
@objc protocol ObjcP { }
protocol ClassP : class { }
class C {
let x : () = ()
@objc func fn() { }
}
class D : C, P, ClassP {
override func fn() { }
}
struct S {
let x : ()
}
enum E {
case Case
case DataCase(Void)
}
sil @general_test : $() -> () {
bb0:
// Allocation and Deallocation
// CHECK: alloc_ref_dynamic undef : $@thick C.Type, $C
alloc_ref_dynamic undef : $@thick C.Type, $C
// CHECK: dealloc_box undef : $<τ_0_0> { var τ_0_0 } <()>
dealloc_box undef : $<τ_0_0> { var τ_0_0 } <()>
// CHECK: dealloc_ref undef : $C
dealloc_ref undef : $C
// CHECK: dealloc_partial_ref undef : $D, undef : $@thick C.Type
dealloc_partial_ref undef : $D, undef : $@thick C.Type
// Debug information
// CHECK: debug_value undef : $()
debug_value undef : $()
// CHECK: debug_value undef : $*(), expr op_deref
debug_value undef : $*(), expr op_deref
// Accessing memory
// CHECK: load undef : $*()
load undef : $*()
// CHECK: store undef to undef : $*()
store undef to undef : $*()
// CHECK: assign undef to undef : $*()
assign undef to undef : $*()
// CHECK: mark_uninitialized [var] undef : $*()
mark_uninitialized [var] undef : $*()
// CHECK: mark_function_escape undef : $*()
mark_function_escape undef : $*()
// CHECK: copy_addr undef to [init] undef : $*()
copy_addr undef to [init] undef : $*()
// CHECK: destroy_addr undef : $*()
destroy_addr undef : $*()
// CHECK: index_addr undef : $*(), undef : $Builtin.Int64
index_addr undef : $*(), undef : $Builtin.Int64
// CHECK: index_raw_pointer undef : $Builtin.RawPointer, undef : $Builtin.Int64
index_raw_pointer undef : $Builtin.RawPointer, undef : $Builtin.Int64
// CHECK: bind_memory undef : $Builtin.RawPointer, undef : $Builtin.Word to $*S
bind_memory undef : $Builtin.RawPointer, undef : $Builtin.Word to $*S
// Reference Counting
// CHECK: strong_retain undef : $C
strong_retain undef : $C
// CHECK: strong_release undef : $C
strong_release undef : $C
// CHECK: strong_retain_unowned undef : $@sil_unowned C
strong_retain_unowned undef : $@sil_unowned C
// CHECK: unowned_retain undef : $@sil_unowned C
unowned_retain undef : $@sil_unowned C
// CHECK: unowned_release undef : $@sil_unowned C
unowned_release undef : $@sil_unowned C
// CHECK: load_weak undef : $*@sil_weak Optional<C>
load_weak undef : $*@sil_weak Optional<C>
// CHECK: store_weak undef to [init] undef : $*@sil_weak Optional<C>
store_weak undef to [init] undef : $*@sil_weak Optional<C>
// CHECK: fix_lifetime undef : $C
fix_lifetime undef : $C
// CHECK: mark_dependence undef : $C on undef : $C
mark_dependence undef : $C on undef : $C
// CHECK: is_unique undef : $C
is_unique undef : $C
// CHECK: copy_block undef : $@convention(block) () -> ()
copy_block undef : $@convention(block) () -> ()
// CHECK: copy_block_without_escaping undef : $@convention(block) () -> () withoutEscaping undef : $@noescape () -> ()
copy_block_without_escaping undef : $@convention(block) () -> () withoutEscaping undef : $@noescape () -> ()
// Dynamic dispatch
// CHECK: class_method undef : $C, #C.fn : (C) -> () -> (), $@convention(method) (@guaranteed C) -> ()
class_method undef : $C, #C.fn : (C) -> () -> (), $@convention(method) (@guaranteed C) -> ()
// CHECK: super_method undef : $D, #C.fn : (C) -> () -> (), $@convention(method) (@guaranteed C) -> ()
super_method undef : $D, #C.fn : (C) -> () -> (), $@convention(method) (@guaranteed C) -> ()
// CHECK: objc_method undef : $C, #C.fn!foreign : (C) -> () -> (), $@convention(objc_method) (C) -> ()
objc_method undef : $C, #C.fn!foreign : (C) -> () -> (), $@convention(objc_method) (C) -> ()
// Function Application
// CHECK: apply undef(undef) : $(()) -> ()
apply undef(undef) : $(()) -> ()
// CHECK: apply undef<()>(undef) : $<τ_0_0> (τ_0_0) -> ()
apply undef<()>(undef) : $<τ_0_0> (τ_0_0) -> ()
// CHECK: partial_apply undef(undef) : $((), ()) -> ()
partial_apply undef(undef) : $((), ()) -> ()
// CHECK: partial_apply undef<()>(undef) : $<τ_0_0> (τ_0_0, τ_0_0) -> ()
partial_apply undef<()>(undef) : $<T>(T, T) -> ()
// CHECK: builtin "sizeof"(undef : $@thick ().Type) : $Bool
builtin "sizeof"(undef : $@thick ().Type) : $Bool
// Metatypes
// CHECK: value_metatype $@thick C.Type, undef : $C
value_metatype $@thick C.Type, undef : $C
// CHECK: existential_metatype $@thick any P.Type, undef : $any P
existential_metatype $@thick P.Type, undef : $P
// Aggregate Types
// CHECK: retain_value undef : $()
retain_value undef : $()
// CHECK: release_value undef : $()
release_value undef : $()
// CHECK: autorelease_value undef : $C
autorelease_value undef : $C
// CHECK: tuple (undef : $(), undef : $())
%0 = tuple (undef : $(), undef : $())
// CHECK: tuple $(a: (), b: ()) (undef, undef)
tuple $(a: (), b: ()) (undef, undef)
// CHECK: tuple_extract undef : $((), ()), 0
tuple_extract undef : $((), ()), 0
// CHECK: tuple_element_addr undef : $*((), ()), 0
tuple_element_addr undef : $*((), ()), 0
// CHECK: struct $S (undef : $())
struct $S (undef : $())
// CHECK: struct_extract undef : $S, #S.x
struct_extract undef : $S, #S.x
// CHECK: struct_element_addr undef : $*S, #S.x
struct_element_addr undef : $*S, #S.x
// CHECK: ref_element_addr undef : $C, #C.x
ref_element_addr undef : $C, #C.x
// Enums
// CHECK: enum $E, #E.DataCase!enumelt, undef : $()
enum $E, #E.DataCase!enumelt, undef : $()
// CHECK: unchecked_enum_data undef : $E, #E.DataCase!enumelt
unchecked_enum_data undef : $E, #E.DataCase!enumelt
// CHECK: init_enum_data_addr undef : $*E, #E.DataCase!enumelt
init_enum_data_addr undef : $*E, #E.DataCase!enumelt
// CHECK: inject_enum_addr undef : $*E, #E.Case!enumelt
inject_enum_addr undef : $*E, #E.Case!enumelt
// CHECK: unchecked_take_enum_data_addr undef : $*E, #E.DataCase!enumelt
unchecked_take_enum_data_addr undef : $*E, #E.DataCase!enumelt
// CHECK: select_enum undef : $E, case #E.Case!enumelt: undef, default undef : $E
select_enum undef : $E, case #E.Case!enumelt: undef, default undef : $E
// CHECK: select_enum_addr undef : $*E, case #E.Case!enumelt: undef, default undef : $()
select_enum_addr undef : $*E, case #E.Case!enumelt: undef, default undef : $()
// Protocol and Protocol Composition Types
// CHECK: init_existential_addr undef : $*any P, $D
init_existential_addr undef : $*P, $D
// CHECK: deinit_existential_addr undef : $*any P
deinit_existential_addr undef : $*P
// CHECK: open_existential_addr immutable_access undef : $*any P to $*@opened("01234567-89AB-CDEF-0123-000000000000", any P) Self
open_existential_addr immutable_access undef : $*P to $*@opened("01234567-89AB-CDEF-0123-000000000000", P) Self
// CHECK: open_existential_addr mutable_access undef : $*any P to $*@opened("01234567-89AB-CDEF-0123-100000000000", any P) Self
open_existential_addr mutable_access undef : $*P to $*@opened("01234567-89AB-CDEF-0123-100000000000", P) Self
// CHECK: init_existential_ref undef : $D : $D, $any ClassP
init_existential_ref undef : $D : $D, $ClassP
// CHECK: open_existential_ref undef : $any ClassP to $@opened("01234567-89AB-CDEF-0123-000000000001", any ClassP) Self
open_existential_ref undef : $ClassP to $@opened("01234567-89AB-CDEF-0123-000000000001", ClassP) Self
// CHECK: init_existential_metatype undef : $@thick D.Type, $@thick any P.Type
init_existential_metatype undef : $@thick D.Type, $@thick P.Type
// CHECK: open_existential_metatype undef : $@thick any P.Type to $@thick (@opened("01234567-89AB-CDEF-0123-000000000002", any P) Self).Type
open_existential_metatype undef : $@thick P.Type to $@thick (@opened("01234567-89AB-CDEF-0123-000000000002", P) Self).Type
// CHECK: open_existential_box undef : $any Error to $*@opened("01234567-89AB-CDEF-0123-000000000003", any Error) Self
open_existential_box undef : $Error to $*@opened("01234567-89AB-CDEF-0123-000000000003", Error) Self
// CHECK: dealloc_existential_box undef : $any Error, $()
dealloc_existential_box undef : $Error, $()
// Blocks
// CHECK: project_block_storage undef : $*@block_storage Builtin.RawPointer
project_block_storage undef : $*@block_storage Builtin.RawPointer
// CHECK: init_block_storage_header undef : $*@block_storage Int, invoke undef : $@convention(c) (@inout_aliasable @block_storage Int) -> (), type $@convention(block) () -> ()
init_block_storage_header undef : $*@block_storage Int, invoke undef : $@convention(c) (@inout_aliasable @block_storage Int) -> (), type $@convention(block) () -> ()
// Unchecked Conversions
// CHECK: upcast undef : $D to $C
upcast undef : $D to $C
// CHECK: address_to_pointer undef : $*() to $Builtin.RawPointer
address_to_pointer undef : $*() to $Builtin.RawPointer
// CHECK: pointer_to_address undef : $Builtin.RawPointer to $*()
pointer_to_address undef : $Builtin.RawPointer to $*()
// CHECK: pointer_to_address undef : $Builtin.RawPointer to [strict] $*()
pointer_to_address undef : $Builtin.RawPointer to [strict] $*()
// CHECK: unchecked_ref_cast undef : $C to $D
unchecked_ref_cast undef : $C to $D
// CHECK: unchecked_addr_cast undef : $*D to $*C
unchecked_addr_cast undef : $*D to $*C
// CHECK: unchecked_trivial_bit_cast undef : $Builtin.NativeObject to $Builtin.Word
unchecked_trivial_bit_cast undef : $Builtin.NativeObject to $Builtin.Word
// CHECK: unchecked_bitwise_cast undef : $Builtin.Int64 to $Builtin.Int1
unchecked_bitwise_cast undef : $Builtin.Int64 to $Builtin.Int1
// CHECK: ref_to_raw_pointer undef : $Builtin.NativeObject to $Builtin.RawPointer
ref_to_raw_pointer undef : $Builtin.NativeObject to $Builtin.RawPointer
// CHECK: ref_to_unowned undef : $C to $@sil_unowned C
ref_to_unowned undef : $C to $@sil_unowned C
// CHECK: unowned_to_ref undef : $@sil_unowned C to $C
unowned_to_ref undef : $@sil_unowned C to $C
// CHECK: unchecked_ref_cast_addr C in undef : $*C to D in undef : $*D
unchecked_ref_cast_addr C in undef : $*C to D in undef : $*D
// CHECK: ref_to_unmanaged undef : $C to $@sil_unmanaged C
ref_to_unmanaged undef : $C to $@sil_unmanaged C
// CHECK: unmanaged_to_ref undef : $@sil_unmanaged C to $C
unmanaged_to_ref undef : $@sil_unmanaged C to $C
// CHECK: convert_function undef : $(D) -> () to $(C) -> ()
convert_function undef : $(D) -> () to $(C) -> ()
// CHECK: ref_to_bridge_object undef : $C, undef : $Builtin.Word
ref_to_bridge_object undef : $C, undef : $Builtin.Word
// CHECK: bridge_object_to_ref undef : $Builtin.BridgeObject to $C
bridge_object_to_ref undef : $Builtin.BridgeObject to $C
// CHECK: bridge_object_to_word undef : $Builtin.BridgeObject to $Builtin.Word
bridge_object_to_word undef : $Builtin.BridgeObject to $Builtin.Word
// CHECK: thin_to_thick_function undef : $@convention(thin) () -> () to $() -> ()
thin_to_thick_function undef : $@convention(thin) () -> () to $() -> ()
// Checked Conversions
// CHECK: unconditional_checked_cast undef : $C to C
unconditional_checked_cast undef : $C to C
// CHECK: unconditional_checked_cast_addr C in undef : $*C to C in undef : $*C
unconditional_checked_cast_addr C in undef : $*C to C in undef : $*C
// Runtime Failures
// CHECK: cond_fail undef : $Builtin.Int1
cond_fail undef : $Builtin.Int1
return undef : $()
}
// Terminators
sil @return_test : $() -> () {
bb0:
// CHECK: return undef : $()
return undef : $()
}
sil @throw_test : $() -> @error () {
bb0:
// CHECK: throw undef : $()
throw undef : $()
}
sil @br_test : $() -> () {
bb0:
// CHECK: br bb1(undef : $())
br bb1(undef : $())
bb1(%x : $()):
return undef : $()
}
sil @cond_br_test : $() -> () {
bb0:
// CHECK: cond_br undef, bb1(undef : $()), bb2
cond_br undef, bb1(undef : $()), bb2
bb1(%1 : $()):
br bb2
bb2:
return undef : $()
}
sil @switch_value_test : $() -> () {
bb0:
// CHECK: switch_value undef : $Builtin.Int1, case undef: bb1
switch_value undef : $Builtin.Int1, case undef: bb1
bb1:
// CHECK: switch_value undef : $() -> (), case undef: bb2
switch_value undef : $() -> (), case undef: bb2
bb2:
return undef : $()
}
sil @switch_enum_test : $() -> () {
bb0:
// CHECK: switch_enum undef : $E, case #E.Case!enumelt: bb1, default bb2
switch_enum undef : $E, case #E.Case!enumelt: bb1, default bb2
bb1:
br bb3
bb2:
br bb3
bb3:
return undef : $()
}
sil @switch_enum_addr_test : $() -> () {
bb0:
// CHECK: switch_enum_addr undef : $*E, case #E.Case!enumelt: bb1, default bb2
switch_enum_addr undef : $*E, case #E.Case!enumelt: bb1, default bb2
bb1:
br bb3
bb2:
br bb3
bb3:
return undef : $()
}
sil @dynamic_method_br_test : $() -> () {
bb0:
// CHECK: dynamic_method_br undef : $any P, #C.fn!foreign, bb1, bb2
dynamic_method_br undef : $P, #C.fn!foreign, bb1, bb2
bb1(%x : $@convention(objc_method) (P) -> ()):
br bb3
bb2:
br bb3
bb3:
return undef: $()
}
sil @checked_cast_br_test : $() -> () {
bb0:
// CHECK: checked_cast_br C in undef : $C to C, bb1, bb2
checked_cast_br C in undef : $C to C, bb1, bb2
bb1(%x : $C):
br bb3
bb2:
br bb3
bb3:
return undef : $()
}
sil @checked_cast_br_addr_test : $() -> () {
bb0:
// CHECK: checked_cast_addr_br take_always C in undef : $*C to C in undef : $*C, bb1, bb2
checked_cast_addr_br take_always C in undef : $*C to C in undef : $*C, bb1, bb2
bb1:
br bb3
bb2:
br bb3
bb3:
return undef : $()
}
sil @try_apply_test : $() -> () {
bb0:
// CHECK: try_apply undef(undef) : $@convention(thin) (()) -> @error any Error, normal bb1, error bb2
try_apply undef(undef) : $@convention(thin) (()) -> @error Error, normal bb1, error bb2
bb1(%1 : $()):
br bb3
bb2(%2 : $Error):
br bb3
bb3:
return undef : $()
}
|