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
|
// RUN: %target-sil-opt -enable-objc-interop -enable-sil-verify-all=0 -module-name Swift -ownership-dumper -o /dev/null %s | %FileCheck %s
// REQUIRES: asserts
sil_stage raw
import Builtin
class Klass {}
struct MyInt {
var i: Builtin.Int32
}
struct MyKlassWrapper {
var i: Klass
}
// Make sure that we handle undef in an appropriate way. Do to special handling
// in SIL around undef, we test this using the ownership dumper for simplicity.
// CHECK-LABEL: *** Dumping Function: 'undef_addresses_have_any_ownership'
// CHECK: Visiting: {{.*}}%0 = mark_uninitialized [var] undef : $*Klass
// CHECK-NEXT: Ownership Constraint:
// CHECK-NEXT: Op #: 0
// CHECK-NEXT: Constraint: <Constraint Kind:owned LifetimeConstraint:LifetimeEnding>
// CHECK: Visiting: {{.*}}%1 = mark_uninitialized [var] undef : $Klass
// CHECK-NEXT: Ownership Constraint:
// CHECK-NEXT: Op #: 0
// CHECK-NEXT: Constraint: <Constraint Kind:owned LifetimeConstraint:LifetimeEnding>
// CHECK: Visiting: {{.*}}%3 = mark_uninitialized [var] undef : $*Builtin.Int32
// CHECK-NEXT: Ownership Constraint:
// CHECK-NEXT: Op #: 0
// CHECK-NEXT: Constraint: <Constraint Kind:owned LifetimeConstraint:LifetimeEnding>
// CHECK: Visiting: {{.*}}%4 = struct $MyInt (undef : $Builtin.Int32)
// CHECK-NEXT: Ownership Constraint:
// CHECK-NEXT: Op #: 0
// CHECK-NEXT: Constraint: <Constraint Kind:none LifetimeConstraint:NonLifetimeEnding>
// CHECK-LABEL: Visiting: {{%.*}} = struct $MyKlassWrapper (undef : $Klass)
// CHECK-NEXT: Ownership Constraint:
// CHECK-NEXT: Op #: 0
// CHECK-NEXT: Constraint: <Constraint Kind:none LifetimeConstraint:NonLifetimeEnding>
// CHECK-NEXT: Results Ownership Kinds:
// CHECK-NEXT: Result: {{%.*}} = struct $MyKlassWrapper (undef : $Klass)
// CHECK-NEXT: Kind: none
sil [ossa] @undef_addresses_have_any_ownership : $@convention(thin) () -> () {
bb0:
%0 = mark_uninitialized [var] undef : $*Klass
%1 = mark_uninitialized [var] undef : $Klass
destroy_value %1 : $Klass
%2 = mark_uninitialized [var] undef : $*Builtin.Int32
%3 = struct $MyInt(undef : $Builtin.Int32)
%4 = struct $MyKlassWrapper(undef : $Klass)
%9999 = tuple()
return %9999 : $()
}
|