mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
32 lines
1019 B
Swift
32 lines
1019 B
Swift
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
|
|
|
|
// CHECK: define{{.*}}@"$s11autoclosure7call_meyys5Int64VF"
|
|
// CHECK-NOT: ret void
|
|
// CHECK: #dbg_declare{{.*}}
|
|
// CHECK-NOT: ret void
|
|
// CHECK: _value {{.*}}, !dbg ![[DBG:.*]]
|
|
// CHECK: ret void
|
|
|
|
func get_truth(_ input: Int64) -> Int64 {
|
|
return input % 2
|
|
}
|
|
|
|
// Since this is an autoclosure test, don't use &&, which is transparent.
|
|
infix operator &&&&& : LogicalConjunctionPrecedence
|
|
|
|
func &&&&&(lhs: Bool, rhs: @autoclosure () -> Bool) -> Bool {
|
|
return lhs ? rhs() : false
|
|
}
|
|
|
|
func call_me(_ input: Int64) -> Void {
|
|
// An autoclosure should have a line number in the debug info and a scope line of 0.
|
|
// CHECK-DAG: !DISubprogram({{.*}}linkageName: "$s11autoclosure7call_meyys5Int64VFSbyXEfu_",{{.*}} spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
|
|
// Instructions setting up the closure should have a line number of 0.
|
|
// CHECK-DAG: ![[DBG]] = !DILocation(line: 0,
|
|
if input != 0 &&&&& ( get_truth (input * 2 + 1) > 0 ) {
|
|
}
|
|
|
|
}
|
|
|
|
call_me(5)
|