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

98 lines
3.2 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -onone-simplification -simplify-instruction=init_enum_data_addr | %FileCheck %s
// REQUIRES: swift_in_compiler
import Swift
import Builtin
enum E {
case A(Int)
case B(AnyObject)
}
// CHECK-LABEL: sil @optional_int
// CHECK: %2 = enum $Optional<Int>, #Optional.some!enumelt, %1 : $Int
// CHECK: store %2 to %0 : $*Optional<Int>
// CHECK: %4 = tuple ()
// CHECK: return %4
// CHECK: } // end sil function 'optional_int'
sil @optional_int : $@convention(thin) (Int) -> @out Optional<Int> {
bb0(%0 : $*Optional<Int>, %1 : $Int):
%2 = init_enum_data_addr %0 : $*Optional<Int>, #Optional.some!enumelt
store %1 to %2 : $*Int
inject_enum_addr %0 : $*Optional<Int>, #Optional.some!enumelt
%5 = tuple ()
return %5 : $()
}
// CHECK-LABEL: sil [ossa] @ossa_trivial
// CHECK: %2 = enum $Optional<Int>, #Optional.some!enumelt, %1 : $Int
// CHECK: store %2 to [trivial] %0 : $*Optional<Int>
// CHECK: %4 = tuple ()
// CHECK: return %4
// CHECK: } // end sil function 'ossa_trivial'
sil [ossa] @ossa_trivial : $@convention(thin) (Int) -> @out Optional<Int> {
bb0(%0 : $*Optional<Int>, %1 : $Int):
%2 = init_enum_data_addr %0 : $*Optional<Int>, #Optional.some!enumelt
store %1 to [trivial] %2 : $*Int
inject_enum_addr %0 : $*Optional<Int>, #Optional.some!enumelt
%5 = tuple ()
return %5 : $()
}
// CHECK-LABEL: sil [ossa] @ossa_nontrivial
// CHECK: %2 = enum $E, #E.A!enumelt, %1 : $Int
// CHECK: store %2 to [init] %0 : $*E
// CHECK: %4 = tuple ()
// CHECK: return %4
// CHECK: } // end sil function 'ossa_nontrivial'
sil [ossa] @ossa_nontrivial : $@convention(thin) (Int) -> @out E {
bb0(%0 : $*E, %1 : $Int):
%2 = init_enum_data_addr %0 : $*E, #E.A!enumelt
store %1 to [trivial] %2 : $*Int
inject_enum_addr %0 : $*E, #E.A!enumelt
%5 = tuple ()
return %5 : $()
}
enum GenE<T> {
case A(Int)
case B(T)
}
// CHECK-LABEL: sil [ossa] @not_loadable
// CHECK: %2 = init_enum_data_addr
// CHECK: store %1 to [trivial] %2
// CHECK: inject_enum_addr
// CHECK: } // end sil function 'not_loadable'
sil [ossa] @not_loadable : $@convention(thin) <T> (Int) -> @out GenE<T> {
bb0(%0 : $*GenE<T>, %1 : $Int):
%2 = init_enum_data_addr %0 : $*GenE<T>, #GenE.A!enumelt
store %1 to [trivial] %2 : $*Int
inject_enum_addr %0 : $*GenE<T>, #GenE.A!enumelt
%5 = tuple ()
return %5 : $()
}
enum F {
case A(UnsafeMutableRawPointer)
case B(AnyObject)
}
// CHECK-LABEL: sil [ossa] @enum_data_addr
// CHECK: %2 = struct $UnsafeMutableRawPointer (%1 : $Builtin.RawPointer)
// CHECK: %3 = enum $F, #F.A!enumelt, %2 : $UnsafeMutableRawPointer
// CHECK: store %3 to [init] %0 : $*F
// CHECK: %5 = tuple ()
// CHECK: return %5
// CHECK: } // end sil function 'enum_data_addr'
sil [ossa] @enum_data_addr : $@convention(thin) (Builtin.RawPointer) -> @out F {
bb0(%0 : $*F, %1 : $Builtin.RawPointer):
%2 = init_enum_data_addr %0 : $*F, #F.A!enumelt
%3 = struct $UnsafeMutableRawPointer (%1 : $Builtin.RawPointer)
store %3 to [trivial] %2 : $*UnsafeMutableRawPointer
inject_enum_addr %0 : $*F, #F.A!enumelt
%6 = tuple ()
return %6 : $()
}