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 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
|
// RUN: %target-sil-opt -enable-sil-verify-all %s -function-order-printer -o /dev/null | %FileCheck --check-prefix=CHECK %s
sil_stage canonical
import Builtin
// CHECK: Bottom up function order:
// CHECK-NEXT: private_bottom
// CHECK-NEXT: private_middle
// CHECK-NEXT: private_top
// CHECK-NEXT: internal_bottom
// CHECK-NEXT: internal_middle
// CHECK-NEXT: internal_top
// CHECK-NEXT: public_bottom
// CHECK-NEXT: public_middle
// CHECK-NEXT: public_top
// CHECK-NEXT: private_base_foo
// CHECK-NEXT: private_derived_foo
// CHECK-NEXT: call_private
// CHECK-NEXT: internal_base_foo
// CHECK-NEXT: internal_derived_foo
// CHECK-NEXT: internal_base_bar
// CHECK-NEXT: internal_derived_bar
// CHECK-NEXT: call_internal
// CHECK-NEXT: public_base_foo
// CHECK-NEXT: public_derived_foo
// CHECK-NEXT: public_base_bar
// CHECK-NEXT: public_derived_bar
// CHECK-NEXT: public_base_baz
// CHECK-NEXT: public_derived_baz
// CHECK-NEXT: call_public
// CHECK-NEXT: private_proto_private_class_theMethod
// CHECK-NEXT: private_proto_1_private_class_witness
// CHECK-NEXT: call_through_private_proto_1
// CHECK-NEXT: private_proto_internal_class_theMethod
// CHECK-NEXT: private_proto_2_internal_class_witness
// CHECK-NEXT: call_through_private_proto_2
// CHECK-NEXT: private_proto_public_class_theMethod
// CHECK-NEXT: private_proto_3_public_class_witness
// CHECK-NEXT: call_through_private_proto_3
// CHECK-NEXT: private_proto_public_class_private_method_theMethod
// CHECK-NEXT: private_proto_4_public_class_private_method_witness
// CHECK-NEXT: call_through_private_proto_4
// CHECK-NEXT: Non-trivial SCC:
// CHECK-NEXT: second_recursive
// CHECK-NEXT: first_recursive
sil private @private_top : $@convention(thin) () -> () {
bb0:
%0 = function_ref @private_middle : $@convention(thin) () -> ()
%1 = apply %0() : $@convention(thin) () -> ()
%2 = tuple ()
return %2 : $()
}
sil private @private_middle : $@convention(thin) () -> () {
bb0:
%0 = function_ref @private_bottom : $@convention(thin) () -> ()
%1 = apply %0() : $@convention(thin) () -> ()
%2 = tuple ()
return %2 : $()
}
sil private @private_bottom : $@convention(thin) () -> () {
bb0:
%0 = tuple ()
return %0 : $()
}
sil hidden @internal_top : $@convention(thin) () -> () {
bb0:
%0 = function_ref @internal_middle : $@convention(thin) () -> ()
%1 = apply %0() : $@convention(thin) () -> ()
%2 = tuple ()
return %2 : $()
}
sil hidden @internal_middle : $@convention(thin) () -> () {
bb0:
%0 = function_ref @internal_bottom : $@convention(thin) () -> ()
%1 = apply %0() : $@convention(thin) () -> ()
%2 = tuple ()
return %2 : $()
}
sil hidden @internal_bottom : $@convention(thin) () -> () {
bb0:
%0 = tuple ()
return %0 : $()
}
sil @public_top : $@convention(thin) () -> () {
bb0:
%0 = function_ref @public_middle : $@convention(thin) () -> ()
%1 = apply %0() : $@convention(thin) () -> ()
%2 = tuple ()
return %2 : $()
}
sil @public_middle : $@convention(thin) () -> () {
bb0:
%0 = function_ref @public_bottom : $@convention(thin) () -> ()
%1 = apply %0() : $@convention(thin) () -> ()
%2 = tuple ()
return %2 : $()
}
sil @public_bottom : $@convention(thin) () -> () {
bb0:
%0 = tuple ()
return %0 : $()
}
private class private_base {
func foo()
}
private class private_derived : private_base {
override func foo()
}
@inline(never) private func call_private(b: private_base)
class internal_base {
func foo()
private func bar()
}
class internal_derived : internal_base {
override func foo()
override func bar()
}
@inline(never) func call_internal(b: internal_base)
public class public_base {
func foo()
public func bar()
private func baz()
}
public class public_derived : public_base {
override func foo()
public override func bar()
public override func baz()
}
sil private [noinline] @call_private : $@convention(thin) (@owned private_base) -> () {
bb0(%0 : $private_base):
debug_value %0 : $private_base
%2 = class_method %0 : $private_base, #private_base.foo : (private_base) -> () -> (), $@convention(method) (@guaranteed private_base) -> ()
%3 = apply %2(%0) : $@convention(method) (@guaranteed private_base) -> ()
strong_release %0 : $private_base
%5 = tuple ()
return %5 : $()
}
sil private @private_derived_foo : $@convention(method) (@guaranteed private_derived) -> () {
bb0(%0 : $private_derived):
debug_value %0 : $private_derived
%2 = tuple ()
return %2 : $()
}
sil private @private_base_foo : $@convention(method) (@guaranteed private_base) -> () {
bb0(%0 : $private_base):
debug_value %0 : $private_base
%2 = tuple ()
return %2 : $()
}
sil hidden [noinline] @call_internal : $@convention(thin) (@owned internal_base) -> () {
bb0(%0 : $internal_base):
debug_value %0 : $internal_base
%2 = class_method %0 : $internal_base, #internal_base.foo : (internal_base) -> () -> (), $@convention(method) (@guaranteed internal_base) -> ()
%3 = apply %2(%0) : $@convention(method) (@guaranteed internal_base) -> ()
%4 = class_method %0 : $internal_base, #internal_base.bar : (internal_base) -> () -> (), $@convention(method) (@guaranteed internal_base) -> ()
%5 = apply %4(%0) : $@convention(method) (@guaranteed internal_base) -> ()
strong_release %0 : $internal_base
%7 = tuple ()
return %7 : $()
}
sil hidden @internal_base_foo : $@convention(method) (@guaranteed internal_base) -> () {
bb0(%0 : $internal_base):
debug_value %0 : $internal_base
%2 = tuple ()
return %2 : $()
}
sil private @internal_base_bar : $@convention(method) (@guaranteed internal_base) -> () {
bb0(%0 : $internal_base):
debug_value %0 : $internal_base
%2 = tuple ()
return %2 : $()
}
sil hidden @internal_derived_foo : $@convention(method) (@guaranteed internal_derived) -> () {
bb0(%0 : $internal_derived):
debug_value %0 : $internal_derived
%2 = tuple ()
return %2 : $()
}
sil hidden @internal_derived_bar : $@convention(method) (@guaranteed internal_derived) -> () {
bb0(%0 : $internal_derived):
debug_value %0 : $internal_derived
%2 = tuple ()
return %2 : $()
}
sil hidden [noinline] @call_public : $@convention(thin) (@owned public_base) -> () {
bb0(%0 : $public_base):
debug_value %0 : $public_base
%2 = class_method %0 : $public_base, #public_base.foo : (public_base) -> () -> (), $@convention(method) (@guaranteed public_base) -> ()
%3 = apply %2(%0) : $@convention(method) (@guaranteed public_base) -> ()
%4 = class_method %0 : $public_base, #public_base.bar : (public_base) -> () -> (), $@convention(method) (@guaranteed public_base) -> ()
%5 = apply %4(%0) : $@convention(method) (@guaranteed public_base) -> ()
%6 = class_method %0 : $public_base, #public_base.baz : (public_base) -> () -> (), $@convention(method) (@guaranteed public_base) -> ()
%7 = apply %6(%0) : $@convention(method) (@guaranteed public_base) -> ()
strong_release %0 : $public_base
%9 = tuple ()
return %9 : $()
}
sil hidden @public_base_foo : $@convention(method) (@guaranteed public_base) -> () {
bb0(%0 : $public_base):
debug_value %0 : $public_base
%2 = tuple ()
return %2 : $()
}
sil @public_base_bar : $@convention(method) (@guaranteed public_base) -> () {
bb0(%0 : $public_base):
debug_value %0 : $public_base
%2 = tuple ()
return %2 : $()
}
sil private @public_base_baz : $@convention(method) (@guaranteed public_base) -> () {
bb0(%0 : $public_base):
debug_value %0 : $public_base
%2 = tuple ()
return %2 : $()
}
sil hidden @public_derived_foo : $@convention(method) (@guaranteed public_derived) -> () {
bb0(%0 : $public_derived):
debug_value %0 : $public_derived
%2 = tuple ()
return %2 : $()
}
sil @public_derived_bar : $@convention(method) (@guaranteed public_derived) -> () {
bb0(%0 : $public_derived):
debug_value %0 : $public_derived
%2 = tuple ()
return %2 : $()
}
sil @public_derived_baz : $@convention(method) (@guaranteed public_derived) -> () {
bb0(%0 : $public_derived):
debug_value %0 : $public_derived
%2 = tuple ()
return %2 : $()
}
sil_vtable private_base {
#private_base.foo: @private_base_foo
}
sil_vtable private_derived {
#private_base.foo: @private_derived_foo [override]
}
sil_vtable internal_base {
#internal_base.foo: @internal_base_foo
#internal_base.bar: @internal_base_bar
}
sil_vtable internal_derived {
#internal_base.foo: @internal_derived_foo [override]
#internal_base.bar: @internal_derived_bar [override]
}
sil_vtable public_base {
#public_base.foo: @public_base_foo
#public_base.bar: @public_base_bar
#public_base.baz: @public_base_baz
}
sil_vtable public_derived {
#public_base.foo: @public_derived_foo [override]
#public_base.bar: @public_derived_bar [override]
#public_base.baz: @public_derived_baz [override]
}
private protocol private_proto_1 {
func theMethod()
}
private class private_proto_private_class : private_proto_1 {
func theMethod()
}
private func call_through_private_proto_1<T : private_proto_1>(x: T)
private protocol private_proto_2 {
func theMethod()
}
class private_proto_internal_class : private_proto_2 {
func theMethod()
}
private func call_through_private_proto_2<T : private_proto_2>(x: T)
private protocol private_proto_3 {
func theMethod()
}
public class private_proto_public_class : private_proto_3 {
public func theMethod()
}
private func call_through_private_proto_3<T : private_proto_3>(x: T)
private protocol private_proto_4 {
func theMethod()
}
public class private_proto_public_class_private_method : private_proto_4 {
fileprivate func theMethod()
}
private func call_through_private_proto_4<T : private_proto_4>(x: T)
sil private @private_proto_private_class_theMethod : $@convention(method) (@guaranteed private_proto_private_class) -> () {
bb0(%0 : $private_proto_private_class):
debug_value %0 : $private_proto_private_class
%2 = tuple ()
return %2 : $()
}
sil private [transparent] [thunk] @private_proto_1_private_class_witness : $@convention(witness_method: private_proto_1) (@in_guaranteed private_proto_private_class) -> () {
bb0(%0 : $*private_proto_private_class):
%1 = load %0 : $*private_proto_private_class
strong_retain %1 : $private_proto_private_class
%3 = class_method %1 : $private_proto_private_class, #private_proto_private_class.theMethod : (private_proto_private_class) -> () -> (), $@convention(method) (@guaranteed private_proto_private_class) -> ()
%4 = apply %3(%1) : $@convention(method) (@guaranteed private_proto_private_class) -> ()
strong_release %1 : $private_proto_private_class
return %4 : $()
}
sil private @call_through_private_proto_1 : $@convention(thin) <T where T : private_proto_1> (@in T) -> () {
bb0(%0 : $*T):
debug_value %0 : $*T, expr op_deref
%2 = witness_method $T, #private_proto_1.theMethod : $@convention(witness_method: private_proto_1) <τ_0_0 where τ_0_0 : private_proto_1> (@in_guaranteed τ_0_0) -> ()
%3 = apply %2<T>(%0) : $@convention(witness_method: private_proto_1) <τ_0_0 where τ_0_0 : private_proto_1> (@in_guaranteed τ_0_0) -> ()
destroy_addr %0 : $*T
%5 = tuple ()
return %5 : $()
}
sil hidden @private_proto_internal_class_theMethod : $@convention(method) (@guaranteed private_proto_internal_class) -> () {
bb0(%0 : $private_proto_internal_class):
debug_value %0 : $private_proto_internal_class
%2 = tuple ()
return %2 : $()
}
sil private [transparent] [thunk] @private_proto_2_internal_class_witness : $@convention(witness_method: private_proto_2) (@in_guaranteed private_proto_internal_class) -> () {
bb0(%0 : $*private_proto_internal_class):
%1 = load %0 : $*private_proto_internal_class
strong_retain %1 : $private_proto_internal_class
%3 = class_method %1 : $private_proto_internal_class, #private_proto_internal_class.theMethod : (private_proto_internal_class) -> () -> (), $@convention(method) (@guaranteed private_proto_internal_class) -> ()
%4 = apply %3(%1) : $@convention(method) (@guaranteed private_proto_internal_class) -> ()
strong_release %1 : $private_proto_internal_class
return %4 : $()
}
sil private @call_through_private_proto_2 : $@convention(thin) <T where T : private_proto_2> (@in T) -> () {
bb0(%0 : $*T):
debug_value %0 : $*T, expr op_deref
%2 = witness_method $T, #private_proto_2.theMethod : $@convention(witness_method: private_proto_2) <τ_0_0 where τ_0_0 : private_proto_2> (@in_guaranteed τ_0_0) -> ()
%3 = apply %2<T>(%0) : $@convention(witness_method: private_proto_2) <τ_0_0 where τ_0_0 : private_proto_2> (@in_guaranteed τ_0_0) -> ()
destroy_addr %0 : $*T
%5 = tuple ()
return %5 : $()
}
sil @private_proto_public_class_theMethod : $@convention(method) (@guaranteed private_proto_public_class) -> () {
bb0(%0 : $private_proto_public_class):
debug_value %0 : $private_proto_public_class
%2 = tuple ()
return %2 : $()
}
sil private [transparent] [thunk] @private_proto_3_public_class_witness : $@convention(witness_method: private_proto_3) (@in_guaranteed private_proto_public_class) -> () {
bb0(%0 : $*private_proto_public_class):
%1 = load %0 : $*private_proto_public_class
strong_retain %1 : $private_proto_public_class
%3 = class_method %1 : $private_proto_public_class, #private_proto_public_class.theMethod : (private_proto_public_class) -> () -> (), $@convention(method) (@guaranteed private_proto_public_class) -> ()
%4 = apply %3(%1) : $@convention(method) (@guaranteed private_proto_public_class) -> ()
strong_release %1 : $private_proto_public_class
return %4 : $()
}
sil private @call_through_private_proto_3 : $@convention(thin) <T where T : private_proto_3> (@in T) -> () {
bb0(%0 : $*T):
debug_value %0 : $*T, expr op_deref
%2 = witness_method $T, #private_proto_3.theMethod : $@convention(witness_method: private_proto_3) <τ_0_0 where τ_0_0 : private_proto_3> (@in_guaranteed τ_0_0) -> ()
%3 = apply %2<T>(%0) : $@convention(witness_method: private_proto_3) <τ_0_0 where τ_0_0 : private_proto_3> (@in_guaranteed τ_0_0) -> ()
destroy_addr %0 : $*T
%5 = tuple ()
return %5 : $()
}
sil private @private_proto_public_class_private_method_theMethod : $@convention(method) (@guaranteed private_proto_public_class_private_method) -> () {
bb0(%0 : $private_proto_public_class_private_method):
debug_value %0 : $private_proto_public_class_private_method
%2 = tuple ()
return %2 : $()
}
sil private [transparent] [thunk] @private_proto_4_public_class_private_method_witness : $@convention(witness_method: private_proto_4) (@in_guaranteed private_proto_public_class_private_method) -> () {
bb0(%0 : $*private_proto_public_class_private_method):
%1 = load %0 : $*private_proto_public_class_private_method
strong_retain %1 : $private_proto_public_class_private_method
%3 = class_method %1 : $private_proto_public_class_private_method, #private_proto_public_class_private_method.theMethod : (private_proto_public_class_private_method) -> () -> (), $@convention(method) (@guaranteed private_proto_public_class_private_method) -> ()
%4 = apply %3(%1) : $@convention(method) (@guaranteed private_proto_public_class_private_method) -> ()
strong_release %1 : $private_proto_public_class_private_method
return %4 : $()
}
sil private @call_through_private_proto_4 : $@convention(thin) <T where T : private_proto_4> (@in T) -> () {
bb0(%0 : $*T):
debug_value %0 : $*T, expr op_deref
%2 = witness_method $T, #private_proto_4.theMethod : $@convention(witness_method: private_proto_4) <τ_0_0 where τ_0_0 : private_proto_4> (@in_guaranteed τ_0_0) -> ()
%3 = apply %2<T>(%0) : $@convention(witness_method: private_proto_4) <τ_0_0 where τ_0_0 : private_proto_4> (@in_guaranteed τ_0_0) -> ()
destroy_addr %0 : $*T
%5 = tuple ()
return %5 : $()
}
sil_vtable private_proto_private_class {
#private_proto_private_class.theMethod: @private_proto_private_class_theMethod
}
sil_vtable private_proto_internal_class {
#private_proto_internal_class.theMethod: @private_proto_internal_class_theMethod
}
sil_vtable private_proto_public_class {
#private_proto_public_class.theMethod: @private_proto_public_class_theMethod
}
sil_vtable private_proto_public_class_private_method {
#private_proto_public_class_private_method.theMethod: @private_proto_public_class_private_method_theMethod
}
sil_witness_table private private_proto_private_class: private_proto_1 module witness {
method #private_proto_1.theMethod: @private_proto_1_private_class_witness
}
sil_witness_table private private_proto_internal_class: private_proto_2 module witness {
method #private_proto_2.theMethod: @private_proto_2_internal_class_witness
}
sil_witness_table private private_proto_public_class: private_proto_3 module witness {
method #private_proto_3.theMethod: @private_proto_3_public_class_witness
}
sil_witness_table private private_proto_public_class_private_method: private_proto_4 module witness {
method #private_proto_4.theMethod: @private_proto_4_public_class_private_method_witness
}
sil hidden @first_recursive : $@convention(thin) (Builtin.Int32) -> Builtin.Int32 {
bb0(%0 : $Builtin.Int32):
%2 = integer_literal $Builtin.Int32, 0
%4 = builtin "cmp_sgt_Int32"(%0 : $Builtin.Int32, %2 : $Builtin.Int32) : $Builtin.Int1
cond_br %4, bb1, bb2
bb1:
%8 = function_ref @second_recursive : $@convention(thin) (Builtin.Int32) -> Builtin.Int32
%9 = integer_literal $Builtin.Int32, 1
%11 = integer_literal $Builtin.Int1, -1
%12 = builtin "ssub_with_overflow_Int32"(%0 : $Builtin.Int32, %9 : $Builtin.Int32, %11 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
%13 = tuple_extract %12 : $(Builtin.Int32, Builtin.Int1), 0
%14 = tuple_extract %12 : $(Builtin.Int32, Builtin.Int1), 1
cond_fail %14 : $Builtin.Int1
%17 = apply %8(%13) : $@convention(thin) (Builtin.Int32) -> Builtin.Int32
br bb3(%17 : $Builtin.Int32)
bb2:
%19 = integer_literal $Builtin.Int32, 27
br bb3(%19 : $Builtin.Int32)
bb3(%22 : $Builtin.Int32):
return %22 : $Builtin.Int32
}
sil hidden @second_recursive : $@convention(thin) (Builtin.Int32) -> Builtin.Int32 {
bb0(%0 : $Builtin.Int32):
%2 = integer_literal $Builtin.Int32, 0
%4 = builtin "cmp_sgt_Int32"(%0 : $Builtin.Int32, %2 : $Builtin.Int32) : $Builtin.Int1
cond_br %4, bb1, bb2
bb1:
%8 = function_ref @first_recursive : $@convention(thin) (Builtin.Int32) -> Builtin.Int32
%9 = integer_literal $Builtin.Int32, 3
%11 = integer_literal $Builtin.Int1, -1
%12 = builtin "ssub_with_overflow_Int32"(%0 : $Builtin.Int32, %9 : $Builtin.Int32, %11 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1)
%13 = tuple_extract %12 : $(Builtin.Int32, Builtin.Int1), 0
%14 = tuple_extract %12 : $(Builtin.Int32, Builtin.Int1), 1
cond_fail %14 : $Builtin.Int1
%17 = apply %8(%13) : $@convention(thin) (Builtin.Int32) -> Builtin.Int32
br bb3(%17 : $Builtin.Int32)
bb2:
%19 = integer_literal $Builtin.Int32, 9
br bb3(%19 : $Builtin.Int32)
bb3(%22 : $Builtin.Int32):
return %22 : $Builtin.Int32
}
|