|
2 | 2 |
|
3 | 3 | class C {}
|
4 | 4 |
|
| 5 | +@_moveOnly struct MoS {} |
| 6 | +@_moveOnly struct MoE {} |
| 7 | + |
5 | 8 | // When access scopes are respected, the lifetime which previously extended
|
6 | 9 | // beyond the access scope still extends beyond it.
|
7 | 10 | // CHECK-LABEL: begin running test 1 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize-ossa-lifetime with: true, false, true, @trace
|
@@ -45,3 +48,46 @@ bb0(%addr : $*C):
|
45 | 48 | %retval = tuple ()
|
46 | 49 | return %retval : $()
|
47 | 50 | }
|
| 51 | + |
| 52 | +sil @empty : $@convention(thin) () -> () { |
| 53 | +[global: ] |
| 54 | +bb0: |
| 55 | + %0 = tuple () |
| 56 | + return %0 : $() |
| 57 | +} |
| 58 | + |
| 59 | +// Even though the apply of %empty is not a deinit barrier, verify that the |
| 60 | +// destroy is not hoisted, because MoS is move-only. |
| 61 | +// CHECK-LABEL: begin running test {{.*}} on dont_move_destroy_value_of_moveonly_struct: canonicalize-ossa-lifetime with: true, false, true, @argument |
| 62 | +// CHECK-LABEL: sil [ossa] @dont_move_destroy_value_of_moveonly_struct : {{.*}} { |
| 63 | +// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : |
| 64 | +// CHECK: apply |
| 65 | +// CHECK: destroy_value [[INSTANCE]] |
| 66 | +// CHECK-LABEL: } // end sil function 'dont_move_destroy_value_of_moveonly_struct' |
| 67 | +// CHECK-LABEL: end running test {{.*}} on dont_move_destroy_value_of_moveonly_struct: canonicalize-ossa-lifetime with: true, false, true, @argument |
| 68 | +sil [ossa] @dont_move_destroy_value_of_moveonly_struct : $@convention(thin) (@owned MoS) -> () { |
| 69 | +entry(%instance : @owned $MoS): |
| 70 | + test_specification "canonicalize-ossa-lifetime true false true @argument" |
| 71 | + %empty = function_ref @empty : $@convention(thin) () -> () |
| 72 | + apply %empty() : $@convention(thin) () -> () |
| 73 | + destroy_value %instance : $MoS |
| 74 | + %retval = tuple () |
| 75 | + return %retval : $() |
| 76 | +} |
| 77 | + |
| 78 | +// CHECK-LABEL: begin running test {{.*}} on dont_move_destroy_value_of_moveonly_enum: canonicalize-ossa-lifetime with: true, false, true, @argument |
| 79 | +// CHECK-LABEL: sil [ossa] @dont_move_destroy_value_of_moveonly_enum : {{.*}} { |
| 80 | +// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : |
| 81 | +// CHECK: apply |
| 82 | +// CHECK: destroy_value [[INSTANCE]] |
| 83 | +// CHECK-LABEL: } // end sil function 'dont_move_destroy_value_of_moveonly_enum' |
| 84 | +// CHECK-LABEL: end running test {{.*}} on dont_move_destroy_value_of_moveonly_enum: canonicalize-ossa-lifetime with: true, false, true, @argument |
| 85 | +sil [ossa] @dont_move_destroy_value_of_moveonly_enum : $@convention(thin) (@owned MoE) -> () { |
| 86 | +entry(%instance : @owned $MoE): |
| 87 | + test_specification "canonicalize-ossa-lifetime true false true @argument" |
| 88 | + %empty = function_ref @empty : $@convention(thin) () -> () |
| 89 | + apply %empty() : $@convention(thin) () -> () |
| 90 | + destroy_value %instance : $MoE |
| 91 | + %retval = tuple () |
| 92 | + return %retval : $() |
| 93 | +} |
0 commit comments