|
1 | 1 | // RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine | %FileCheck %s
|
2 | 2 | // RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -generic-specializer | %FileCheck %s --check-prefix=CHECK_FORWARDING_OWNERSHIP_KIND
|
3 |
| -// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -enable-copy-propagation |
| 3 | +// |
| 4 | +// FIXME: check copy-propagation output instead once it is the default mode |
| 5 | +// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -enable-copy-propagation | %FileCheck %s --check-prefix=CHECK_COPYPROP |
4 | 6 |
|
5 | 7 | // Declare this SIL to be canonical because some tests break raw SIL
|
6 | 8 | // conventions. e.g. address-type block args. -enforce-exclusivity=none is also
|
@@ -5155,3 +5157,65 @@ bb0(%0 : $Builtin.Int64, %1 : @owned $MyContiguousArrayStorage):
|
5155 | 5157 | %10 = tuple ()
|
5156 | 5158 | return %10 : $()
|
5157 | 5159 | }
|
| 5160 | + |
| 5161 | +// Test Ownership RAUW when the replacement address requires an additional unchecked_addr_cast. |
| 5162 | +// |
| 5163 | +// |
| 5164 | +// CHECK-LABEL: sil [ossa] @testAddrCast : $@convention(thin) (UnsafePointer<AnyObject>) -> @owned Optional<AnyObject> { |
| 5165 | +// CHECK: bb0(%0 : $UnsafePointer<AnyObject>): |
| 5166 | +// CHECK: [[A1:%.*]] = index_addr %{{.*}} : $*AnyObject, undef : $Builtin.Word |
| 5167 | +// CHECK: [[A2:%.*]] = unchecked_addr_cast [[A1]] : $*AnyObject to $*Optional<AnyObject> |
| 5168 | +// CHECK: load [copy] [[A2]] : $*Optional<AnyObject> |
| 5169 | +// CHECK-LABEL: } // end sil function 'testAddrCast' |
| 5170 | +sil [ossa] @testAddrCast : $@convention(thin) (UnsafePointer<AnyObject>) -> @owned Optional<AnyObject> { |
| 5171 | +bb0(%0 : $UnsafePointer<AnyObject>): |
| 5172 | + %1 = struct_extract %0 : $UnsafePointer<AnyObject>, #UnsafePointer._rawValue |
| 5173 | + %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*AnyObject |
| 5174 | + %3 = index_addr %2 : $*AnyObject, undef : $Builtin.Word |
| 5175 | + %4 = address_to_pointer %3 : $*AnyObject to $Builtin.RawPointer |
| 5176 | + %5 = pointer_to_address %4 : $Builtin.RawPointer to [strict] $*Optional<AnyObject> |
| 5177 | + %6 = load [copy] %5 : $*Optional<AnyObject> |
| 5178 | + return %6 : $Optional<AnyObject> |
| 5179 | +} |
| 5180 | + |
| 5181 | +// CHECK-LABEL: sil [ossa] @test_pointer_to_address : $@convention(thin) (@owned Klass, Builtin.Word) -> @owned AnyObject { |
| 5182 | +// CHECK: bb0(%0 : @owned $Klass, %1 : $Builtin.Word): |
| 5183 | +// CHECK: [[CP1:%.*]] = copy_value %0 : $Klass |
| 5184 | +// CHECK: [[BORROW:%.*]] = begin_borrow [[CP1]] : $Klass |
| 5185 | +// CHECK: ref_tail_addr [[BORROW]] : $Klass, $AnyObject |
| 5186 | +// CHECK: index_addr %{{.*}} : $*AnyObject, %1 : $Builtin.Word |
| 5187 | +// CHECK: index_addr %{{.*}} : $*AnyObject, %1 : $Builtin.Word |
| 5188 | +// CHECK: load [copy] %{{.*}} : $*AnyObject |
| 5189 | +// CHECK: end_borrow [[BORROW]] : $Klass |
| 5190 | +// CHECK: destroy_value [[CP1]] : $Klass |
| 5191 | +// CHECK: fix_lifetime %0 : $Klass |
| 5192 | +// CHECK-LABEL: } // end sil function 'test_pointer_to_address' |
| 5193 | +// |
| 5194 | +// CHECK_COPYPROP-LABEL: sil [ossa] @test_pointer_to_address : $@convention(thin) (@owned Klass, Builtin.Word) -> @owned AnyObject { |
| 5195 | +// CHECK_COPYPROP: bb0(%0 : @owned $Klass, %1 : $Builtin.Word): |
| 5196 | +// CHECK_COPYPROP-NOT: copy_value |
| 5197 | +// CHECK_COPYPROP: [[BORROW:%.*]] = begin_borrow %0 : $Klass |
| 5198 | +// CHECK_COPYPROP: ref_tail_addr [[BORROW]] : $Klass, $AnyObject |
| 5199 | +// CHECK_COPYPROP: index_addr %{{.*}} : $*AnyObject, %1 : $Builtin.Word |
| 5200 | +// CHECK_COPYPROP: index_addr %{{.*}} : $*AnyObject, %1 : $Builtin.Word |
| 5201 | +// CHECK_COPYPROP: load [copy] %{{.*}} : $*AnyObject |
| 5202 | +// CHECK_COPYPROP: end_borrow [[BORROW]] : $Klass |
| 5203 | +// CHECK_COPYPROP: fix_lifetime %0 : $Klass |
| 5204 | +// CHECK_COPYPROP: destroy_value %0 : $Klass |
| 5205 | +// CHECK_COPYPROP-LABEL: } // end sil function 'test_pointer_to_address' |
| 5206 | +sil [ossa] @test_pointer_to_address : $@convention(thin) (@owned Klass, Builtin.Word) -> @owned AnyObject { |
| 5207 | +bb0(%0 : @owned $Klass, %1 : $Builtin.Word): |
| 5208 | + %2 = begin_borrow %0 : $Klass |
| 5209 | + %3 = ref_tail_addr %2 : $Klass, $AnyObject |
| 5210 | + %4 = index_addr %3 : $*AnyObject, %1 : $Builtin.Word |
| 5211 | + %5 = address_to_pointer %4 : $*AnyObject to $Builtin.RawPointer |
| 5212 | + end_borrow %2 : $Klass |
| 5213 | + %7 = pointer_to_address %5 : $Builtin.RawPointer to [strict] $*AnyObject |
| 5214 | + %8 = index_addr %7 : $*AnyObject, %1 : $Builtin.Word |
| 5215 | + %9 = address_to_pointer %8 : $*AnyObject to $Builtin.RawPointer |
| 5216 | + %10 = pointer_to_address %9 : $Builtin.RawPointer to [strict] $*AnyObject |
| 5217 | + %11 = load [copy] %10 : $*AnyObject |
| 5218 | + fix_lifetime %0 : $Klass |
| 5219 | + destroy_value %0 : $Klass |
| 5220 | + return %11 : $AnyObject |
| 5221 | +} |
0 commit comments