mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The source location for the variable should be the value in VarInfo if set, otherwise it should use the location of the instruction. Both ways should be consistent, and as we use column number if VarInfo is set, we have to do it if isnt, too.
36 lines
1.3 KiB
Plaintext
36 lines
1.3 KiB
Plaintext
// RUN: %target-swiftc_driver -g -emit-ir %s | %FileCheck %s
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
sil_scope 2 { loc "simple.swift":1:2 parent @test_debug_value : $@convention(thin) (Builtin.Int64) -> () }
|
|
|
|
// CHECK-LABEL: @test_debug_value
|
|
// CHECK-SAME: !dbg ![[FUNC_DI:[0-9]+]]
|
|
sil hidden @test_debug_value : $@convention(thin) (Builtin.Int64) -> () {
|
|
bb0(%0 : $Builtin.Int64):
|
|
// CHECK: @llvm.dbg.declare(metadata ptr
|
|
// CHECK-SAME: metadata ![[VAR_DI:[0-9]+]]
|
|
// CHECK-SAME: ), !dbg ![[LOC_DI:[0-9]+]]
|
|
debug_value %0 : $Builtin.Int64, var, name "x", loc "simple.swift":1:16, scope 2
|
|
%zero = integer_literal $Builtin.Int64, 0
|
|
debug_value %zero : $Builtin.Int64, var, (name "x", loc "simple.swift":1:16, scope 2), loc "simple.swift":3:4, scope 2
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
// One debug_value uses the VarInfo way, the other uses the instruction way.
|
|
// They should both resolve to the same variable, so we should only have one x.
|
|
|
|
// CHECK: !DISubprogram(name: "test_debug_value"
|
|
// CHECK-SAME: retainedNodes: ![[RETAINED:[0-9]+]]
|
|
|
|
// Only one variable should be retained
|
|
// CHECK: ![[RETAINED]] = !{![[VAR_DI]]}
|
|
|
|
// CHECK-NOT: !DILocalVariable(name: "x"
|
|
// CHECK: ![[VAR_DI]] = !DILocalVariable(name: "x"
|
|
// CHECK-SAME: line: 1
|
|
// CHECK-NOT: !DILocalVariable(name: "x"
|