Files
swift-mirror/test/SILOptimizer/onone_simplifications_trivial_enum.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
1.3 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types --onone-simplification %s | %FileCheck %s
// REQUIRES: swift_in_compiler
import Builtin
import Swift
class Klass {}
enum EnumTy: ~Copyable {
case klass(Klass)
case int(Builtin.Word)
}
// CHECK-LABEL: sil [ossa] @test_switch_trivial_arm
sil [ossa] @test_switch_trivial_arm : $@convention(thin) (@guaranteed EnumTy) -> () {
entry(%a : @guaranteed $EnumTy):
%b = explicit_copy_value %a : $EnumTy
// CHECK: [[MOVE:%.*]] = move_value
%c = move_value %b : $EnumTy
// CHECK: [[BORROW:%.*]] = begin_borrow [[MOVE]]
%d = begin_borrow %c : $EnumTy
// CHECK: switch_enum [[BORROW]] : {{.*}}, case #EnumTy.int!enumelt: [[INTBB:bb[0-9]+]]
switch_enum %d : $EnumTy, case #EnumTy.klass!enumelt: klass, case #EnumTy.int!enumelt: int
klass(%e : @guaranteed $Klass):
end_borrow %d : $EnumTy
%f = unchecked_enum_data %c : $EnumTy, #EnumTy.klass!enumelt
destroy_value %f : $Klass
br end
// We shouldn't remove the `unchecked_enum_data` here because it consumes the
// original enum, even though it otherwise appears dead.
// CHECK: [[INTBB]]({{.*}}):
int(%p : $Builtin.Word):
// CHECK: end_borrow [[BORROW]]
end_borrow %d : $EnumTy
// CHECK: unchecked_enum_data [[MOVE]]
%q = unchecked_enum_data %c : $EnumTy, #EnumTy.int!enumelt
br end
end:
return undef : $()
}