Files
swift-mirror/test/SIL/Parser/async.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

137 lines
4.6 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all=true %s | %target-sil-opt -sil-print-types -enable-sil-verify-all=true | %FileCheck %s
// REQUIRES: concurrency
import Builtin
import Swift
import _Concurrency
// CHECK: sil @not_async_test : $@convention(thin) () -> () {
sil @not_async_test : $@convention(thin) () -> () {
bb0:
%0 = tuple ()
return %0 : $()
}
// CHECK: sil @not_async_test2 : $@convention(thin) (Builtin.Int32) -> () {
sil @not_async_test2 : $(Builtin.Int32) -> () {
bb0(%int : $Builtin.Int32):
%0 = tuple ()
return %0 : $()
}
// CHECK: sil @async_test : $@convention(thin) @async
sil @async_test : $@async () -> () {
bb0:
%0 = tuple ()
return %0 : $()
}
// CHECK: sil @take_async : $@convention(thin) (@async () -> ()) -> ()
sil @take_async : $(@async () -> ()) -> () {
bb0(%fn : $@async () -> ()):
%0 = tuple ()
return %0 : $()
}
// CHECK: sil @async_continuation : $@convention(thin) @async () -> () {
sil @async_continuation : $@async () -> () {
// CHECK-NEXT: bb
entry:
// CHECK-NEXT: [[CONT:%.*]] = get_async_continuation Builtin.Int32
%c = get_async_continuation Builtin.Int32
// CHECK-NEXT: // function_ref
// CHECK-NEXT: function_ref
%f = function_ref @not_async_test : $@convention(thin) () -> ()
// CHECK-NEXT: apply
apply %f() : $@convention(thin) () -> ()
// CHECK-NEXT: await_async_continuation [[CONT]] : $Builtin.RawUnsafeContinuation, resume [[RESUME:bb[0-9]+]]
await_async_continuation %c : $Builtin.RawUnsafeContinuation, resume bb1
// CHECK-NEXT: {{^ *$}}
// CHECK-NEXT: [[RESUME]]([[RVALUE:%.*]] : $Builtin.Int32):
bb1(%r : $Builtin.Int32):
return undef : $()
}
// CHECK: sil @async_continuation_throws : $@convention(thin) @async () -> () {
sil @async_continuation_throws : $@async () -> () {
// CHECK-NEXT: bb
entry:
// CHECK-NEXT: [[CONT:%.*]] = get_async_continuation [throws] Builtin.Int32
%c = get_async_continuation [throws] Builtin.Int32
// CHECK-NEXT: // function_ref
// CHECK-NEXT: function_ref
%f = function_ref @not_async_test : $@convention(thin) () -> ()
// CHECK-NEXT: apply
apply %f() : $@convention(thin) () -> ()
// CHECK-NEXT: await_async_continuation [[CONT]] : $Builtin.RawUnsafeContinuation, resume [[RESUME:bb[0-9]+]], error [[ERROR:bb[0-9]+]]
await_async_continuation %c : $Builtin.RawUnsafeContinuation, resume bb1, error bb2
// CHECK-NEXT: {{^ *$}}
// CHECK-NEXT: [[RESUME]]([[RVALUE:%.*]] : $Builtin.Int32):
bb1(%r : $Builtin.Int32):
// CHECK-NEXT: br
br bb3
// CHECK-NEXT: {{^ *$}}
// CHECK-NEXT: [[ERROR]]([[EVALUE:%.*]] : $any Error):
bb2(%e : $Error):
// CHECK-NEXT: br
br bb3
bb3:
return undef : $()
}
// CHECK: sil @async_continuation_addr : $@convention(thin) @async () -> () {
sil @async_continuation_addr : $@async () -> () {
// CHECK-NEXT: bb
entry:
// CHECK: [[SLOT:%.*]] = alloc_stack
%a = alloc_stack $Builtin.Int32
// CHECK-NEXT: [[CONT:%.*]] = get_async_continuation_addr Builtin.Int32, [[SLOT]] : $*Builtin.Int32
%c = get_async_continuation_addr Builtin.Int32, %a : $*Builtin.Int32
// CHECK-NEXT: // function_ref
// CHECK-NEXT: function_ref
%f = function_ref @not_async_test : $@convention(thin) () -> ()
// CHECK-NEXT: apply
apply %f() : $@convention(thin) () -> ()
// CHECK-NEXT: await_async_continuation [[CONT]] : $Builtin.RawUnsafeContinuation, resume [[RESUME:bb[0-9]+]]
await_async_continuation %c : $Builtin.RawUnsafeContinuation, resume bb1
// CHECK-NEXT: {{^ *$}}
// CHECK-NEXT: [[RESUME]]:
bb1:
dealloc_stack %a : $*Builtin.Int32
return undef : $()
}
// CHECK: sil @async_continuation_throws_addr : $@convention(thin) @async () -> () {
sil @async_continuation_throws_addr : $@async () -> () {
// CHECK-NEXT: bb
entry:
// CHECK: [[SLOT:%.*]] = alloc_stack
%a = alloc_stack $Builtin.Int32
// CHECK-NEXT: [[CONT:%.*]] = get_async_continuation_addr [throws] Builtin.Int32, [[SLOT]] : $*Builtin.Int32
%c = get_async_continuation_addr [throws] Builtin.Int32, %a : $*Builtin.Int32
// CHECK-NEXT: // function_ref
// CHECK-NEXT: function_ref
%f = function_ref @not_async_test : $@convention(thin) () -> ()
// CHECK-NEXT: apply
apply %f() : $@convention(thin) () -> ()
// CHECK-NEXT: await_async_continuation [[CONT]] : $Builtin.RawUnsafeContinuation, resume [[RESUME:bb[0-9]+]], error [[ERROR:bb[0-9]+]]
await_async_continuation %c : $Builtin.RawUnsafeContinuation, resume bb1, error bb2
// CHECK-NEXT: {{^ *$}}
// CHECK-NEXT: [[RESUME]]:
bb1:
// CHECK-NEXT: dealloc_stack
dealloc_stack %a : $*Builtin.Int32
// CHECK-NEXT: br
br bb3
// CHECK-NEXT: {{^ *$}}
// CHECK-NEXT: [[ERROR]]([[EVALUE:%.*]] : $any Error):
bb2(%e : $Error):
dealloc_stack %a : $*Builtin.Int32
br bb3
bb3:
return undef : $()
}