mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
e62d58349f
The swift compiler memsets new allocas to zero. It does this so that LLDB is able to display a friendly 'variable is uninitialized' message rather than garbage. Unfortunately this use of a variable before its lifetime.start disagrees with the memtag-stack tagging pass. This patch attaches a piece of metadata to these memsets, so that the memtag-stack tagging pass can recognize them and work around them appropriately. Paired with: https://github.com/swiftlang/llvm-project/pull/11846. rdar://162206592
28 lines
1016 B
Swift
28 lines
1016 B
Swift
// RUN: %target-swift-frontend %s -c -emit-ir -g -o - | %FileCheck %s
|
|
// RUN: %target-swift-frontend %s -O -c -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 ptr, align
|
|
// CHECK: #dbg_declare(ptr %[[OBJ]],
|
|
// CHECK: void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[OBJ]], i8 0,
|
|
// CHECK-SAME: ), !Swift.isSwiftLLDBpreinit
|
|
// OPT-NOT: @llvm.memset
|
|
// OPT: ret
|
|
}
|
|
|
|
// CHECK-LABEL: define {{.*}} @"$s13uninitialized1gyyF"
|
|
// OPT-LABEL: define {{.*}} @"$s13uninitialized1gyyF"
|
|
public func g() {
|
|
var dict: Dictionary<Int64, Int64>
|
|
// CHECK: %[[DICT:.*]] = alloca
|
|
// CHECK: #dbg_declare(ptr %[[DICT]],
|
|
// CHECK: void @llvm.memset.{{.*}}(ptr align {{(4|8)}} %[[DICT]], i8 0,
|
|
// CHECK-SAME: ), !Swift.isSwiftLLDBpreinit
|
|
// OPT-NOT: @llvm.memset
|
|
// OPT: ret
|
|
}
|