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

59 lines
2.0 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -sil-lexical-lifetime-eliminator %s -enable-sil-verify-all | %FileCheck %s
sil_stage raw
import Builtin
class Klass {}
sil @getKlass : $() -> (@owned Klass)
// CHECK-LABEL: sil [ossa] @lexical_lifetime_object : $@convention(thin) (@owned Klass) -> () {
// CHECK: bb0(%0 : @owned $Klass):
// CHECK-NEXT: %1 = begin_borrow %0 : $Klass
// CHECK-NEXT: end_borrow %1 : $Klass
// CHECK-NEXT: destroy_value %0 : $Klass
// CHECK-NEXT: tuple ()
// CHECK-NEXT: return
// CHECK-NEXT: }
sil [ossa] @lexical_lifetime_object : $@convention(thin) (@owned Klass) -> () {
bb0(%0 : @owned $Klass):
%1 = begin_borrow [lexical] %0 : $Klass
end_borrow %1 : $Klass
destroy_value %0 : $Klass
%9999 = tuple()
return %9999 : $()
}
// CHECK-LABEL: sil [ossa] @lexical_lifetime_move : {{.*}} {
// CHECK-NOT: move_value [lexical]
// CHECK: move_value
// CHECK-LABEL: } // end sil function 'lexical_lifetime_move'
sil [ossa] @lexical_lifetime_move : $@convention(thin) () -> () {
%getKlass = function_ref @getKlass : $@convention(thin) () -> (@owned Klass)
%instance = apply %getKlass() : $@convention(thin) () -> (@owned Klass)
%lifetime = move_value [lexical] %instance : $Klass
destroy_value %lifetime : $Klass
%retval = tuple ()
return %retval : $()
}
// CHECK-LABEL: sil [ossa] @lexical_lifetime_address : $@convention(thin) (@in Klass) -> () {
// CHECK: bb0(%0 : $*Klass):
// CHECK-NEXT: %1 = alloc_stack $Klass
// CHECK-NEXT: copy_addr [take] %0 to [init] %1 : $*Klass
// CHECK-NEXT: destroy_addr %1 : $*Klass
// CHECK-NEXT: dealloc_stack %1 : $*Klass
// CHECK-NEXT: tuple ()
// CHECK-NEXT: return
// CHECK-NEXT: }
sil [ossa] @lexical_lifetime_address : $@convention(thin) (@in Klass) -> () {
bb0(%0 : $*Klass):
%1 = alloc_stack [lexical] $Klass
copy_addr [take] %0 to [init] %1 : $*Klass
destroy_addr %1 : $*Klass
dealloc_stack %1 : $*Klass
%9999 = tuple()
return %9999 : $()
}