Files
swift-mirror/test/SILOptimizer/address_lowering_lib.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

63 lines
3.3 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -address-lowering -emit-sorted-sil -enable-sil-opaque-values -sil-verify-all %s | %FileCheck %s
//
import Builtin
import Swift
sil_stage raw
// CHECK-LABEL: sil [ossa] @test_open_existential_box_value : $@convention(thin) (@in any Error) -> () {
// CHECK: [[ALLOC:%.*]] = alloc_stack $Any
// CHECK: [[VAL:%.*]] = load [take] %0 : $*any Error
// CHECK: [[BORROW:%.*]] = begin_borrow [lexical] [[VAL]] : $any Error
// CHECK: [[OPENADDR:%.*]] = open_existential_box [[BORROW]] : $any Error to $*@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", any Error) Self
// CHECK: [[INIT:%.*]] = init_existential_addr [[ALLOC]] : $*Any, $@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", any Error) Self
// CHECK: copy_addr [[OPENADDR]] to [init] [[INIT]] : $*@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", any Error) Self
// CHECK: destroy_addr [[ALLOC]] : $*Any
// CHECK: end_borrow [[BORROW]] : $any Error
// CHECK: destroy_value [[VAL]] : $any Error
// CHECK: dealloc_stack [[ALLOC]] : $*Any
// CHECK-LABEL: } // end sil function 'test_open_existential_box_value'
sil [ossa] @test_open_existential_box_value : $@convention(thin) (@in Error) -> () {
bb0(%0 : @owned $Error):
%1 = begin_borrow [lexical] %0 : $Error
%2 = open_existential_box_value %1 : $Error to $@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", Error) Self
%3 = copy_value %2 : $@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", Error) Self
%4 = init_existential_value %3 : $@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", Error) Self, $@opened("169A6848-B636-11EC-83C4-D0817AD59B9D", Error) Self, $Any
destroy_value %4 : $Any
end_borrow %1 : $Error
destroy_value %0 : $Error
%ret = tuple ()
return %ret : $()
}
struct WeakBox<T : AnyObject> {
weak var t: T?
}
// CHECK-LABEL: sil [ossa] @test_strong_copy_weak_value : {{.*}} {
// CHECK: {{bb[0-9]+}}([[BOX_ADDR:%[^,]+]] :
// CHECK: [[VALUE_ADDR:%[^,]+]] = struct_element_addr [[BOX_ADDR]] : {{.*}}, #WeakBox.t
// CHECK: [[VALUE:%[^,]+]] = load_weak [[VALUE_ADDR]] : $*@sil_weak Optional<T>
// CHECK: return [[VALUE]] : $Optional<T>
// CHECK-LABEL: } // end sil function 'test_strong_copy_weak_value'
sil [ossa] @test_strong_copy_weak_value : $@convention(thin) <T where T : AnyObject> (@in_guaranteed WeakBox<T>) -> @owned Optional<T> {
bb0(%instance : @guaranteed $WeakBox<T>):
%weak_optional = struct_extract %instance : $WeakBox<T>, #WeakBox.t
%strong_optional = strong_copy_weak_value %weak_optional : $@sil_weak Optional<T>
return %strong_optional : $Optional<T>
}
// CHECK-LABEL: sil [ossa] @test_weak_copy_value_1 : {{.*}} {
// CHECK: {{bb[0-9]+}}([[RETVAL:%[^,]+]] : $*WeakBox<T>, [[VALUE:%[^,]+]] :
// CHECK: [[VALUE_ADDR:%[^,]+]] = struct_element_addr [[RETVAL]] : {{.*}}, #WeakBox.t
// CHECK: store_weak [[VALUE]] to [init] [[VALUE_ADDR]]
// CHECK: destroy_value [[VALUE]]
// CHECK-LABEL: } // end sil function 'test_weak_copy_value_1'
sil [ossa] @test_weak_copy_value_1 : $@convention(thin) <T where T : AnyObject> (@owned Optional<T>) -> @out WeakBox<T> {
bb0(%value : @owned $Optional<T>):
%weak_value = weak_copy_value %value : $Optional<T>
destroy_value %value : $Optional<T>
%retval = struct $WeakBox<T> (%weak_value : $@sil_weak Optional<T>)
return %retval : $WeakBox<T>
}