mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We already zero init AllocStack, and here's the same. The debugger's variable view shows up variables on the line where they're declared (before they've been initialized). In some cases, we just print garbage. In some others, it's dangerous (imagine an array which we believe has 2^32 elements because we ended up reusing a stack slot). This way it's always consistent, as lldb uses the first word to understand whether an object is initialized or not here. Fixes <rdar://problem/39883298>
28 lines
1.1 KiB
Swift
28 lines
1.1 KiB
Swift
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
|
|
// RUN: %target-swift-frontend %s -O -emit-ir -g -o - | %FileCheck %s --check-prefix=OPT
|
|
class MyClass {}
|
|
|
|
// CHECK-LABEL: define {{.*}} @"$S13uninitialized1fyyF"
|
|
// OPT-LABEL: define {{.*}} @"$S13uninitialized1fyyF"
|
|
public func f() {
|
|
var object: MyClass
|
|
// CHECK: %[[OBJ:.*]] = alloca %[[T1:.*]]*, align
|
|
// CHECK: call void @llvm.dbg.declare(metadata %[[T1]]** %[[OBJ]],
|
|
// CHECK: %[[BC1:.*]] = bitcast %[[T1]]** %[[OBJ]] to %swift.opaque**
|
|
// CHECK: store %swift.opaque* null, %swift.opaque** %[[BC1]], align {{.*}}
|
|
// OPT-NOT: store
|
|
// OPT: ret
|
|
}
|
|
|
|
// CHECK-LABEL: define {{.*}} @"$S13uninitialized1gyyF"
|
|
// OPT-LABEL: define {{.*}} @"$S13uninitialized1gyyF"
|
|
public func g() {
|
|
var dict: Dictionary<Int64, Int64>
|
|
// CHECK: %[[DICT:.*]] = alloca %[[T2:.*]], align
|
|
// CHECK: call void @llvm.dbg.declare(metadata %[[T2]]* %[[DICT]],
|
|
// CHECK: %[[BC2:.*]] = bitcast %[[T2]]* %[[DICT]] to %swift.opaque**
|
|
// CHECK: store %swift.opaque* null, %swift.opaque** %[[BC2]], align {{.*}}
|
|
// OPT-NOT: store
|
|
// OPT: ret
|
|
}
|