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

50 lines
1.4 KiB
Plaintext

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -emit-module -module-name ossa -o %t/ossa.swiftmodule %s
// RUN: %target-sil-opt -sil-print-types %t/ossa.swiftmodule | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
import SwiftShims
class X {}
// CHECK-LABEL: sil [serialized] [canonical] [ossa] @test_unchecked_ref_cast
sil [serialized] [ossa] @test_unchecked_ref_cast : $@convention(thin) (@guaranteed AnyObject) -> @owned X {
bb0(%0 : @guaranteed $AnyObject):
// CHECK: %1 = unchecked_ref_cast %0 : $AnyObject to $X, forwarding: @unowned
%1 = unchecked_ref_cast %0 : $AnyObject to $X, forwarding: @unowned
%2 = copy_value %1 : $X
return %2 : $X
}
// CHECK-LABEL: sil [serialized] [canonical] [ossa] @reborrowTest :
// CHECK: bb1:
// CHECK-NEXT: {{%.*}} = begin_borrow %0 : $X
// CHECK: bb2:
// CHECK-NEXT: {{%.*}} = begin_borrow %0 : $X
// CHECK: bb3([[ARG:%.*]] : @reborrow $X):
// CHECK-NEXT: {{%.*}} = borrowed [[ARG]] : $X from (%0 : $X)
// CHECK: } // end sil function 'reborrowTest'
sil [serialized] [ossa] @reborrowTest : $@convention(thin) (@owned X) -> () {
bb0(%0 : @owned $X):
cond_br undef, bb1, bb2
bb1:
%b1 = begin_borrow %0 : $X
br bb3(%b1 : $X)
bb2:
%b2 = begin_borrow %0 : $X
br bb3(%b2 : $X)
bb3(%r : @reborrow $X):
%f = borrowed %r : $X from (%0 : $X)
end_borrow %f : $X
destroy_value %0 : $X
%9999 = tuple()
return %9999 : $()
}