|
1 | | -// RUN: %target-sil-opt -sil-print-types -enable-objc-interop -enable-sil-verify-all %s -simplify-cfg | %FileCheck %s |
| 1 | +// RUN: %target-sil-opt -sil-print-types -enable-objc-interop -enable-experimental-feature MoveOnlyEnumDeinits -enable-sil-verify-all %s -simplify-cfg | %FileCheck %s |
| 2 | + |
| 3 | +// REQUIRES: swift_feature_MoveOnlyEnumDeinits |
2 | 4 |
|
3 | 5 | // OSSA form of tests from simplify_cfg.sil and simplify_cfg_simple.sil. |
4 | 6 | // |
@@ -64,6 +66,12 @@ struct S { |
64 | 66 | var b: NonTrivial |
65 | 67 | } |
66 | 68 |
|
| 69 | +enum NCE: ~Copyable { |
| 70 | + case a |
| 71 | + case b(AnyObject) |
| 72 | + deinit |
| 73 | +} |
| 74 | + |
67 | 75 | /////////// |
68 | 76 | // Tests // |
69 | 77 | /////////// |
@@ -1944,6 +1952,44 @@ bb3: |
1944 | 1952 | return %t : $() |
1945 | 1953 | } |
1946 | 1954 |
|
| 1955 | +// CHECK-LABEL: sil [ossa] @insert_compensating_endlifetime_in_switch_enum_destination_block : |
| 1956 | +// CHECK: bb0(%0 : @owned $Optional<AnyObject>): |
| 1957 | +// CHECK-NEXT: end_lifetime %0 |
| 1958 | +// CHECK-NEXT: tuple |
| 1959 | +// CHECK: } // end sil function 'insert_compensating_endlifetime_in_switch_enum_destination_block' |
| 1960 | +sil [ossa] @insert_compensating_endlifetime_in_switch_enum_destination_block : $@convention(thin) (@owned Optional<AnyObject>) -> () { |
| 1961 | +bb0(%0 : @owned $Optional<AnyObject>): |
| 1962 | + switch_enum %0, case #Optional.none!enumelt: bb1, case #Optional.some!enumelt: bb2 |
| 1963 | + |
| 1964 | +bb1: |
| 1965 | + %15 = tuple () |
| 1966 | + return %15 |
| 1967 | + |
| 1968 | +bb2(%4 : @owned $AnyObject): |
| 1969 | + destroy_value %4 |
| 1970 | + unreachable |
| 1971 | +} |
| 1972 | + |
| 1973 | +// CHECK-LABEL: sil [ossa] @insert_compensating_endlifetime_in_switch_enum_destination_block2 : |
| 1974 | +// CHECK: bb0(%0 : @owned $NCE): |
| 1975 | +// CHECK-NEXT: %1 = drop_deinit %0 |
| 1976 | +// CHECK-NEXT: end_lifetime %1 |
| 1977 | +// CHECK-NEXT: tuple |
| 1978 | +// CHECK: } // end sil function 'insert_compensating_endlifetime_in_switch_enum_destination_block2' |
| 1979 | +sil [ossa] @insert_compensating_endlifetime_in_switch_enum_destination_block2 : $@convention(thin) (@owned NCE) -> () { |
| 1980 | +bb0(%0 : @owned $NCE): |
| 1981 | + %1 = drop_deinit %0 |
| 1982 | + switch_enum %1, case #NCE.a!enumelt: bb1, case #NCE.b!enumelt: bb2 |
| 1983 | + |
| 1984 | +bb1: |
| 1985 | + %15 = tuple () |
| 1986 | + return %15 |
| 1987 | + |
| 1988 | +bb2(%4 : @owned $AnyObject): |
| 1989 | + destroy_value %4 |
| 1990 | + unreachable |
| 1991 | +} |
| 1992 | + |
1947 | 1993 | // CHECK-LABEL: sil [ossa] @replace_phi_arg_with_borrowed_from_use : |
1948 | 1994 | // CHECK: bb3([[R:%.*]] : @reborrow $B): |
1949 | 1995 | // CHECK: bb6([[G:%.*]] : @guaranteed $E): |
|
0 commit comments