Files
swift-mirror/test/SILGen/without_actually_escaping_block.swift
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

27 lines
1.1 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %build-silgen-test-overlays
// RUN: %target-swift-emit-silgen(mock-sdk: -sdk %S/Inputs -I %t) -Xllvm -sil-print-types -module-name without_actually_escaping %s -sdk %S/Inputs -enable-objc-interop | %FileCheck %s
// REQUIRES: objc_interop
import Foundation
typealias Callback = @convention(block) () -> Void
// CHECK-LABEL: sil {{.*}} @$s25without_actually_escaping9testBlock5blockyyyXB_tF
// CHECK: bb0([[ARG:%.*]] : @guaranteed $@convention(block) @noescape () -> ()):
// CHECK: [[C1:%.*]] = copy_block [[ARG]]
// CHECK: [[B1:%.*]] = begin_borrow [[C1]]
// CHECK: [[C2:%.*]] = copy_value [[B1]]
// CHECK: [[CVT:%.*]] = convert_function [[C2]] : $@convention(block) @noescape () -> () to [without_actually_escaping] $@convention(block) () -> ()
// CHECK: [[FN:%.*]] = function_ref @$s25without_actually_escaping9testBlock5blockyyyXB_tFyyyXBXEfU_
// CHECK: apply [[FN]]([[CVT]])
// CHECK: destroy_value [[CVT]]
// CHECK: end_borrow [[B1]]
// CHECK: destroy_value [[C1]]
// CHECK: return
func testBlock(block: Callback) {
withoutActuallyEscaping(block) { $0() }
}