Files
swift-mirror/test/DebugInfo/line-directive-codeview.swift
Ellis Hoag 8200916129 Fix debug locations to work well with CodeView
Summary:
There are a few problems with how Swift currently emits location
information for CodeView.

1. WinDbg does not work well with column information so all column
locations must be set to zero.

2. Some instructions, e.g., ``a + b``,  will emit ``@llvm.trap()``
and ``unreachable``. Those instructions should have artificial
locations, i.e., they should have a line location of zero.

3. Some instructions, e.g., ``a / b``, will emit ``unreachable``
sandwiched between other code for that instruction. This makes
WinDbg confused and it cannot decide which set of instructions
to break on. Those instructions should have the same line location
as the others.

4. There are several prologue instructions with artificial line
locations that create breaks in the linetables. Those instructions
should have valid line locations, usually at the start of the
function.

5. Case bodies have cleanup instructions with artificial line
locations unless it has a ``do`` block. Those locations should
be the last line in the case block.

Test Plan:
test/DebugInfo/basic.swift
test/DebugInfo/columns.swift
test/DebugInfo/linetable-codeview.swift
test/DebugInfo/line-directive-codeview.swift
2018-07-18 09:54:19 -07:00

29 lines
1.1 KiB
Swift

func markUsed<T>(_ t: T) {}
func myFunc() {
if 1==1 {
#sourceLocation(file: "abc.swift", line: 42)
markUsed("Hello World")
#sourceLocation()
}
markUsed("Test")
#sourceLocation(file: "abc.swift", line: 142)
markUsed("abc again")
#sourceLocation(file: "def.swift", line: 142)
markUsed("jump directly to def")
}
// REQUIRES: OS=Windows
// RUN: %swiftc_driver %s -S -g -debug-info-format=codeview -target x86_64-unknown-windows-msvc -o - | %FileCheck --check-prefix CV-CHECK %s
// CV-CHECK: .cv_file [[MAIN:[0-9]+]] "{{.*}}line-directive-codeview.swift"
// CV-CHECK: .cv_loc {{[0-9]+}} [[MAIN]] 1 {{0?}}
// CV-CHECK: .def $S4main6myFuncyyF;
// CV-CHECK-NOT: .def
// CV-CHECK: .cv_func_id [[MYFUNC:[0-9]+]]
// CV-CHECK: .cv_file [[ABC:[0-9]+]] "{{.*}}abc.swift"
// CV-CHECK: .cv_loc [[MYFUNC]] [[ABC]] 42 {{0?}}
// CV-CHECK: .cv_loc [[MYFUNC]] [[MAIN]] 8 {{0?}}
// CV-CHECK: .cv_loc [[MYFUNC]] [[ABC]] 142 {{0?}}
// CV-CHECK: .cv_file [[DEF:[0-9]+]] "{{.*}}def.swift"
// CV-CHECK: .cv_loc [[MYFUNC]] [[DEF]] 142 {{0?}}
// CV-CHECK: .cv_linetable [[MYFUNC]], $S4main6myFuncyyF