mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
To avoid the debugger displaying garbage or having expressions crash when inspecting an uninitialized dictionary variable, zero-initialize the first word of the alloca at -Onone. <rdar://problem/36619561>
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**, !dbg
|
|
// CHECK: store %swift.opaque* null, %swift.opaque** %[[BC1]], align {{.*}}, !dbg
|
|
// 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**, !dbg
|
|
// CHECK: store %swift.opaque* null, %swift.opaque** %[[BC2]], align {{.*}}, !dbg
|
|
// OPT-NOT: store
|
|
// OPT: ret
|
|
}
|