Files
swift-mirror/test/DebugInfo/dead-obj-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

40 lines
1.7 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all -deadobject-elim %s | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
struct MyObject {
var _storage: (UInt8, UInt8)
}
// CHECK-LABEL: sil @$myFunc
sil @$myFunc : $@convention(thin) (UInt8) -> UInt8 {
[global: ]
bb0(%0 : $UInt8):
debug_value %0 : $UInt8, let, name "value", argno 1
// CHECK-NOT: alloc_stack
%2 = alloc_stack $MyObject, var, name "obj"
%24 = integer_literal $Builtin.Int8, 3
%25 = struct_extract %0 : $UInt8, #UInt8._value
%26 = integer_literal $Builtin.Int1, -1
%27 = builtin "uadd_with_overflow_Int8"(%25 : $Builtin.Int8, %24 : $Builtin.Int8, %26 : $Builtin.Int1) : $(Builtin.Int8, Builtin.Int1)
%28 = tuple_extract %27 : $(Builtin.Int8, Builtin.Int1), 0
%29 = tuple_extract %27 : $(Builtin.Int8, Builtin.Int1), 1
cond_fail %29 : $Builtin.Int1, "arithmetic overflow"
%31 = struct $UInt8 (%28 : $Builtin.Int8)
%34 = struct_element_addr %2 : $*MyObject, #MyObject._storage
%35 = tuple_element_addr %34 : $*(UInt8, UInt8), 0
%36 = tuple_element_addr %34 : $*(UInt8, UInt8), 1
// The store below should be replaced by a debug_value with the same operand as the store (%0)
// The fragment refers to the member being modified
// CHECK-NOT: store
// CHECK: debug_value %0 : $UInt8, var, name "obj", type $MyObject, expr op_fragment:#MyObject._storage:op_tuple_fragment:$(UInt8, UInt8):1
store %0 to %36 : $*UInt8
// CHECK: debug_value %{{[0-9]}} : $UInt8, var, name "obj", type $MyObject, expr op_fragment:#MyObject._storage:op_tuple_fragment:$(UInt8, UInt8):0
store %31 to %35 : $*UInt8
dealloc_stack %2 : $*MyObject
return %31 : $UInt8
} // end sil function '$myFunc'