|
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,31 @@ 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 | +} |
0 commit comments