mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The effect of this tiny change is that local variables will be described by llvm.dbg.values, which will get lowered into an accurate location list instead of a stack slot that is valid for the entire scope of the variable. This means the debugger can now accurately track the liveness of variables knowing exactly when they are initialized and when there values go away. Function arguments are still kept in stack slots because (1) they are already initialized at the function entry and (2) LLDB really needs self to be available at all times for the expression evaluator. This was made possible by recent advancements in LLVM such as the live debug variables pass and various related bugfixes. <rdar://problem/15746520>
24 lines
642 B
Swift
24 lines
642 B
Swift
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
|
|
class A {
|
|
init(handler: (() -> ())) { }
|
|
}
|
|
|
|
class B { }
|
|
|
|
// CHECK: define {{.*}} @_TF11WeakCapture8functionFT_T_()
|
|
func function() {
|
|
let b = B()
|
|
|
|
// Ensure that the local b and its weak copy are distinct local variables.
|
|
// CHECK: call void @llvm.dbg.value(metadata %C11WeakCapture1B*
|
|
// CHECK-SAME: metadata [[B:.*]], metadata
|
|
// CHECK: call void @llvm.dbg.value(metadata %swift.weak*
|
|
// CHECK-NOT: metadata [[B]]
|
|
// CHECK: call
|
|
A(handler: { [weak b] _ in
|
|
if b != nil { }
|
|
})
|
|
}
|
|
|
|
function()
|