Files
swift-mirror/test/SILOptimizer/sil_combine_objc_bridge.sil
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00

59 lines
1.9 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -sil-combine | %FileCheck %s
// REQUIRES: objc_interop
// TODO: Update optimizer for id-as-Any changes.
sil_stage canonical
import Builtin
import Swift
import Foundation
// CHECK-LABEL: sil shared @bridge_from_swift_array_to_NSObject_cast
// CHECK: function_ref @$sSa10FoundationE19_bridgeToObjectiveC{{[_0-9a-zA-Z]*}}F
// CHECK-NOT: retain
// CHECK: apply
// CHECK: release_value
// CHECK: upcast %{{.*}} : $NSArray to $NSObject
// CHECK: store
// CHECK: return
sil shared @bridge_from_swift_array_to_NSObject_cast: $@convention(thin) (@in Array<String>) -> @out NSObject {
bb0(%0 : $*NSObject, %1 : $*Array<String>):
%2 = alloc_stack $Array<String>
copy_addr %1 to [init] %2 : $*Array<String>
unconditional_checked_cast_addr Array<String> in %2 : $*Array<String> to NSObject in %0 : $*NSObject
dealloc_stack %2 : $*Array<String>
destroy_addr %1 : $*Array<String>
%7 = tuple ()
return %7 : $()
}
enum AddressOnlyError : Error {
case data(Data)
case none
}
// Test that we emit a copy_addr for the address-only value initialization.
// CHECK-LABEL: sil @unconditional_checked_cast_addr_address_only_type
// CHECK: alloc_stack $any Error
// CHECK: alloc_stack $AddressOnlyError
// CHECK: copy_addr
// CHECK: alloc_existential_box
// CHECK: project_existential_box
// CHECK: copy_addr
// CHECK: store
sil @unconditional_checked_cast_addr_address_only_type: $@convention(thin) (@in_guaranteed AddressOnlyError) -> @owned Error {
bb0(%0 : $*AddressOnlyError):
%1 = alloc_stack $Error
%2 = alloc_stack $AddressOnlyError
copy_addr %0 to [init] %2 : $*AddressOnlyError
unconditional_checked_cast_addr AddressOnlyError in %2 : $*AddressOnlyError to Error in %1 : $*Error
dealloc_stack %2 : $*AddressOnlyError
%8 = tuple ()
%9 = load %1 : $*Error
dealloc_stack %1 : $*Error
return %9 : $Error
}