Files
swift-mirror/test/DebugInfo/debug_fragment_merge.swift
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

43 lines
2.2 KiB
Swift

// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -primary-file %s -Xllvm -sil-print-types -emit-sil -O -g | %FileCheck %s --check-prefix CHECK-SIL
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple -primary-file %s -emit-irgen -O -g | %FileCheck %s
// REQUIRES: CPU=arm64 || CPU=x86_64 || CPU=arm64e
protocol External {
func use(str: String);
func decode<T>(_: T.Type) -> T
}
struct Data {
var a: String
var b: String
}
func test(cond: Int, external: External) async {
// CHECK-DAG: ![[VAR:[0-9]+]] = !DILocalVariable(name: "data", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: [[# @LINE + 1]], type: !{{[0-9]+}})
let data: Data
switch cond {
// CHECK-DAG: ![[LOC1:[0-9]+]] = !DILocation(line: [[# @LINE + 1]], column: 12, scope: !{{.*}})
case 42: data = external.decode(Data.self)
// CHECK-DAG: ![[LOC2:[0-9]+]] = !DILocation(line: [[# @LINE + 1]], column: 12, scope: !{{.*}})
default: data = external.decode(Data.self)
}
external.use(str: data.a)
external.use(str: data.b)
}
// CHECK-SIL: debug_value %{{.*}} : $String, let, (name "data", {{.*}}), type $Data, expr op_fragment:#Data.a
// CHECK-SIL: debug_value %{{.*}} : $String, let, (name "data", {{.*}}), type $Data, expr op_fragment:#Data.b
// CHECK-SIL: debug_value %{{.*}} : $String, let, (name "data", {{.*}}), type $Data, expr op_fragment:#Data.a
// CHECK-SIL: debug_value %{{.*}} : $String, let, (name "data", {{.*}}), type $Data, expr op_fragment:#Data.b
// CHECK-DAG: #dbg_value{{.*}} ![[VAR:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} ![[LOC1]]
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} ![[LOC1]]
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} ![[LOC1]]
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} ![[LOC1]]
//
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 192, 64){{.*}} ![[LOC2]]
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 128, 64){{.*}} ![[LOC2]]
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64){{.*}} ![[LOC2]]
// CHECK-DAG: #dbg_value{{.*}} ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 0, 64){{.*}} ![[LOC2]]