|
1 |
| -// RUN: %target-sil-opt -mandatory-combine -sil-mandatory-combine-enable-canon-and-simple-dce %s | %FileCheck %s |
| 1 | +// RUN: %target-sil-opt -optimized-mandatory-combine -sil-mandatory-combine-enable-canon-and-simple-dce %s | %FileCheck %s |
2 | 2 |
|
3 | 3 | // Tests for when the mandatory combiner is running with optimizations
|
4 | 4 | // enabled. Only put tests here for functionality that only occurs when the
|
@@ -106,3 +106,32 @@ bb0(%0 : @guaranteed $Klass):
|
106 | 106 | %9999 = tuple()
|
107 | 107 | return %9999 : $()
|
108 | 108 | }
|
| 109 | + |
| 110 | +// ----------------------------------------------------------------------------- |
| 111 | +// Test removal of redundant borrow scopes for owned-to-guaranteed |
| 112 | +// coroutine arguments. |
| 113 | +class C { |
| 114 | + @_hasStorage var float: Builtin.Int64 { get set } |
| 115 | + init(_ float: Builtin.Int64) |
| 116 | +} |
| 117 | + |
| 118 | +// CHECK-LABEL: sil hidden [ossa] @testCoroutineBorrow : $@convention(thin) (@owned C, Builtin.Int64) -> () { |
| 119 | +// CHECK-LABEL: bb0(%0 : @owned $C, %1 : $Builtin.Int64): |
| 120 | +// CHECK-NOT: borrow |
| 121 | +// CHECK: class_method %0 : $C, #C.float!modify : (C) -> () -> (), $@yield_once @convention(method) (@guaranteed C) -> @yields @inout Builtin.Int64 |
| 122 | +// CHECK: begin_apply %{{.*}}(%0) : $@yield_once @convention(method) (@guaranteed C) -> @yields @inout Builtin.Int64 |
| 123 | +// CHECK-NOT: borrow |
| 124 | +// CHECK: destroy_value %0 : $C |
| 125 | +// CHECK-LABEL: } // end sil function 'testCoroutineBorrow' |
| 126 | +sil hidden [ossa] @testCoroutineBorrow : $@convention(thin) (@owned C, Builtin.Int64) -> () { |
| 127 | +bb0(%0 : @owned $C, %1 : $Builtin.Int64): |
| 128 | + %14 = begin_borrow %0 : $C |
| 129 | + %15 = class_method %14 : $C, #C.float!modify : (C) -> () -> (), $@yield_once @convention(method) (@guaranteed C) -> @yields @inout Builtin.Int64 |
| 130 | + (%16, %17) = begin_apply %15(%14) : $@yield_once @convention(method) (@guaranteed C) -> @yields @inout Builtin.Int64 |
| 131 | + store %1 to [trivial] %16 : $*Builtin.Int64 |
| 132 | + end_apply %17 |
| 133 | + end_borrow %14 : $C |
| 134 | + destroy_value %0 : $C |
| 135 | + %23 = tuple () |
| 136 | + return %23 : $() |
| 137 | +} |
0 commit comments