|
1 | 1 | // RUN: %target-sil-opt -unit-test-runner %s -o /dev/null 2>&1 | %FileCheck %s
|
2 | 2 |
|
3 | 3 | class C {}
|
| 4 | +sil @getOwned : $@convention(thin) () -> @owned C |
4 | 5 |
|
5 | 6 | // When access scopes are respected, the lifetime which previously extended
|
6 | 7 | // beyond the access scope still extends beyond it.
|
@@ -45,3 +46,62 @@ bb0(%addr : $*C):
|
45 | 46 | %retval = tuple ()
|
46 | 47 | return %retval : $()
|
47 | 48 | }
|
| 49 | + |
| 50 | + |
| 51 | +// CHECK-LABEL: begin running test 1 of 1 on reuse_destroy_after_barrier_phi: canonicalize-ossa-lifetime with: true, false, true, @trace |
| 52 | +// CHECK-LABEL: sil [ossa] @reuse_destroy_after_barrier_phi : {{.*}} { |
| 53 | +// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : |
| 54 | +// CHECK: {{bb[0-9]+}}({{%[^,]+}} |
| 55 | +// CHECK: destroy_value [[INSTANCE]] |
| 56 | +// CHECK-LABEL: } // end sil function 'reuse_destroy_after_barrier_phi' |
| 57 | +// CHECK-LABEL: end running test 1 of 1 on reuse_destroy_after_barrier_phi: canonicalize-ossa-lifetime with: true, false, true, @trace |
| 58 | +sil [ossa] @reuse_destroy_after_barrier_phi : $@convention(thin) (@owned C) -> @owned C { |
| 59 | +entry(%instance : @owned $C): |
| 60 | + debug_value [trace] %instance : $C |
| 61 | + test_specification "canonicalize-ossa-lifetime true false true @trace" |
| 62 | + %get = function_ref @getOwned : $@convention(thin) () -> @owned C |
| 63 | + cond_br undef, through, loop |
| 64 | + |
| 65 | +through: |
| 66 | + %4 = copy_value %instance : $C |
| 67 | + br exit(%4 : $C) |
| 68 | + |
| 69 | +loop: |
| 70 | + %other = apply %get() : $@convention(thin) () -> @owned C |
| 71 | + br exit(%other : $C) |
| 72 | + |
| 73 | +exit(%out : @owned $C): |
| 74 | + destroy_value %instance : $C |
| 75 | + return %out : $C |
| 76 | +} |
| 77 | + |
| 78 | +// CHECK-LABEL: begin running test 1 of 1 on dont_reuse_destroy_after_barrier_phi_and_nonignoreable_instruction: canonicalize-ossa-lifetime with: true, false, true, @trace |
| 79 | +// dont_reuse_destroy_after_barrier_phi_and_nonignoreable_instruction |
| 80 | +// CHECK-LABEL: sil [ossa] @dont_reuse_destroy_after_barrier_phi_and_nonignoreable_instruction : {{.*}} { |
| 81 | +// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : |
| 82 | +// CHECK: {{bb[0-9]+}}({{%[^,]+}} |
| 83 | +// CHECK: metatype |
| 84 | +// CHECK: destroy_value [[INSTANCE]] |
| 85 | +// CHECK-LABEL: } // end sil function 'dont_reuse_destroy_after_barrier_phi_and_nonignoreable_instruction' |
| 86 | + |
| 87 | +// CHECK-LABEL: end running test 1 of 1 on dont_reuse_destroy_after_barrier_phi_and_nonignoreable_instruction: canonicalize-ossa-lifetime with: true, false, true, @trace |
| 88 | +sil [ossa] @dont_reuse_destroy_after_barrier_phi_and_nonignoreable_instruction : $@convention(thin) (@owned C) -> @owned C { |
| 89 | +entry(%instance : @owned $C): |
| 90 | + debug_value [trace] %instance : $C |
| 91 | + test_specification "canonicalize-ossa-lifetime true false true @trace" |
| 92 | + %get = function_ref @getOwned : $@convention(thin) () -> @owned C |
| 93 | + cond_br undef, through, loop |
| 94 | + |
| 95 | +through: |
| 96 | + %4 = copy_value %instance : $C |
| 97 | + br exit(%4 : $C) |
| 98 | + |
| 99 | +loop: |
| 100 | + %other = apply %get() : $@convention(thin) () -> @owned C |
| 101 | + br exit(%other : $C) |
| 102 | + |
| 103 | +exit(%out : @owned $C): |
| 104 | + metatype $@thin C.Type |
| 105 | + destroy_value %instance : $C |
| 106 | + return %out : $C |
| 107 | +} |
0 commit comments