Files
swift-mirror/test/DebugInfo/callexpr.swift
Felipe de Azevedo Piovezan f7f869c88d [DebugInfo] Don't inherit debug location of previous instruction
Prior to this commit, when lowering SIL instructions that should are
"hidden" for the purposes of debugging, the compiler just attaches the
location of the previous instruction in the name of keeping a simpler
line table.

However, this is wrong for many reasons. One such reason is this: at the
start of a basic block, inheriting the previous debug location will
almost certainly cause the instruction to have a random location in the
code, as it will depend on whatever BB was visited previously.

Other examples can be seen in the tests affect by this commit, which
changes lowering to use Line 0 instead of the line number of the
previous instruction.

CodeView doesn't handle line 0 the same way DWARF does, so this commit
preserves the old behavior for the CodeView path.

The test changes here are effectively undoing some of the diffs from
158772c2ab.

rdar://139826231&110187845
2024-11-18 10:23:41 -08:00

27 lines
948 B
Swift

// RUN: %target-swift-frontend %s -g -emit-ir -o - | %FileCheck %s
// RUN: %target-swift-frontend %s -g -emit-ir -o - | %FileCheck --check-prefix=CHECK2 %s
func markUsed<T>(_ t: T) {}
func foo(_ a : Int64, _ b : Int64) -> Int64 {
return a+b
}
// CHECK: call {{.*}}foo{{.*}}, !dbg ![[ARG1:.*]]
// CHECK: call {{.*}}foo{{.*}}, !dbg ![[ARG2:.*]]
// CHECK: call {{.*}}foo{{.*}}, !dbg ![[OUTER:.*]]
let r = foo(
foo(1, 23), // CHECK: ![[ARG1]] = !DILocation(line: [[@LINE]],
foo(2, 42) // CHECK: ![[ARG2]] = !DILocation(line: [[@LINE]],
) // CHECK: ![[OUTER]] = !DILocation(line: [[@LINE-3]],
markUsed(r)
struct MyType {}
func bar(x: MyType = MyType()) {}
// CHECK2: call {{.*}}MyType{{.*}}, !dbg ![[DEFAULTARG:.*]]
// CHECK2: call {{.*}}bar{{.*}}, !dbg ![[BARCALL:.*]]
bar() // CHECK2: ![[DEFAULTARG]] = !DILocation(line: 0
// CHECK2: ![[BARCALL]] = !DILocation(line: [[@LINE-1]], column: 1