Files
swift-mirror/test/SIL/Serialization/copy_value_destroy_value.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

47 lines
2.4 KiB
Plaintext

// First parse this and then emit a *.sib. Then read in the *.sib, then recreate
// RUN: %empty-directory(%t)
// RUN: %target-sil-opt -sil-print-types %s -emit-sib -o %t/tmp.sib -module-name copydestroy_value
// RUN: %target-sil-opt -sil-print-types %t/tmp.sib -o %t/tmp.2.sib -module-name copydestroy_value
// RUN: %target-sil-opt -sil-print-types %t/tmp.2.sib -module-name copydestroy_value -emit-sorted-sil | %FileCheck %s
sil_stage canonical
import Builtin
// CHECK-LABEL: sil [serialized] [ossa] @test_copy_value : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
// CHECK: bb0([[ARG1:%[0-9]+]] : @owned $Builtin.NativeObject):
// CHECK: [[COPY_VALUE_RESULT:%[0-9]+]] = copy_value [[ARG1]] : $Builtin.NativeObject
// CHECK: destroy_value [[ARG1]]
// CHECK: return [[COPY_VALUE_RESULT]]
sil [serialized] [ossa] @test_copy_value : $@convention(thin) (@owned Builtin.NativeObject) -> @owned Builtin.NativeObject {
bb0(%0 : @owned $Builtin.NativeObject):
%1 = copy_value %0 : $Builtin.NativeObject
destroy_value %0 : $Builtin.NativeObject
return %1 : $Builtin.NativeObject
}
// CHECK-LABEL: sil [serialized] [ossa] @test_poison
// CHECK: bb0(%0 : @owned $Builtin.NativeObject):
// CHECK-NEXT: destroy_value [poison] %0 : $Builtin.NativeObject
// CHECK-NEXT: tuple
// CHECK-NEXT: return
sil [serialized] [ossa] @test_poison : $@convention(thin) (@owned Builtin.NativeObject) -> () {
bb0(%0 : @owned $Builtin.NativeObject):
destroy_value [poison] %0 : $Builtin.NativeObject
%2 = tuple ()
return %2 : $()
}
// CHECK-LABEL: sil [serialized] [ossa] @test_strong_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
// CHECK: bb0([[T0:%[0-9]+]] : @owned $@sil_unowned Builtin.NativeObject):
// CHECK-NEXT: [[COPY_RESULT:%.*]] = strong_copy_unowned_value [[T0]] : $@sil_unowned Builtin.NativeObject
// CHECK-NEXT: destroy_value [[T0]] : $@sil_unowned Builtin.NativeObject
// CHECK-NEXT: return [[COPY_RESULT]] : $Builtin.NativeObject
sil [serialized] [ossa] @test_strong_copy_unowned_value : $@convention(thin) (@owned @sil_unowned Builtin.NativeObject) -> @owned Builtin.NativeObject {
bb0(%0 : @owned $@sil_unowned Builtin.NativeObject):
%1 = strong_copy_unowned_value %0 : $@sil_unowned Builtin.NativeObject
destroy_value %0 : $@sil_unowned Builtin.NativeObject
return %1 : $Builtin.NativeObject
}