|
| 1 | +// RUN: %target-sil-opt -unit-test-runner %s -o /dev/null 2>&1 | %FileCheck %s |
| 2 | + |
| 3 | +class C {} |
| 4 | + |
| 5 | +// When access scopes are respected, the lifetime which previously extended |
| 6 | +// beyond the access scope still extends beyond it. |
| 7 | +// 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 |
| 8 | +// CHECK-LABEL: sil [ossa] @retract_value_lifetime_into_access_scope_when_access_scopes_not_respected {{.*}} { |
| 9 | +// CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : |
| 10 | +// CHECK: [[INSTANCE:%[^,]+]] = apply |
| 11 | +// CHECK: [[COPY:%[^,]+]] = copy_value [[INSTANCE]] |
| 12 | +// CHECK: [[ACCESS:%[^,]+]] = begin_access [modify] [static] [[ADDR]] |
| 13 | +// CHECK: store [[COPY]] to [init] [[ACCESS]] |
| 14 | +// CHECK: end_access [[ACCESS]] |
| 15 | +// CHECK: destroy_value [[INSTANCE]] |
| 16 | +// CHECK-LABEL: } // end sil function 'retract_value_lifetime_into_access_scope_when_access_scopes_not_respected' |
| 17 | +// CHECK-LABEL: end 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 |
| 18 | + |
| 19 | +// When access scopes are not respected, the lifetime which previously extended |
| 20 | +// beyond the access scope is retracted into the scope. |
| 21 | +// CHECK-LABEL: begin running test 2 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize-ossa-lifetime with: true, false, false, @trace |
| 22 | +// CHECK-LABEL: sil [ossa] @retract_value_lifetime_into_access_scope_when_access_scopes_not_respected {{.*}} { |
| 23 | +// CHECK: {{bb[0-9]+}}([[ADDR:%[^,]+]] : |
| 24 | +// CHECK: [[INSTANCE:%[^,]+]] = apply |
| 25 | +// CHECK: [[ACCESS:%[^,]+]] = begin_access [modify] [static] [[ADDR]] |
| 26 | +// CHECK: store [[INSTANCE]] to [init] [[ACCESS]] |
| 27 | +// CHECK: end_access [[ACCESS]] |
| 28 | +// CHECK-LABEL: } // end sil function 'retract_value_lifetime_into_access_scope_when_access_scopes_not_respected' |
| 29 | +// CHECK-LABEL: end running test 2 of 2 on retract_value_lifetime_into_access_scope_when_access_scopes_not_respected: canonicalize-ossa-lifetime with: true, false, false, @trace |
| 30 | +sil [ossa] @retract_value_lifetime_into_access_scope_when_access_scopes_not_respected : $@convention(thin) () -> @out C { |
| 31 | +bb0(%addr : $*C): |
| 32 | + %instance = apply undef() : $@convention(thin) () -> @owned C |
| 33 | + debug_value [trace] %instance : $C |
| 34 | + // respect access scopes |
| 35 | + // VVVV |
| 36 | + test_specification "canonicalize-ossa-lifetime true false true @trace" |
| 37 | + test_specification "canonicalize-ossa-lifetime true false false @trace" |
| 38 | + // ^^^^^ |
| 39 | + // respect access scopes |
| 40 | + %copy = copy_value %instance : $C |
| 41 | + %access = begin_access [modify] [static] %addr : $*C |
| 42 | + store %copy to [init] %access : $*C |
| 43 | + end_access %access : $*C |
| 44 | + destroy_value %instance : $C |
| 45 | + %retval = tuple () |
| 46 | + return %retval : $() |
| 47 | +} |
0 commit comments