Skip to content

Commit 49c0ae4

Browse files
Merge pull request #28029 from adrian-prantl/56521648-structs
Debug Info: Avoid type uniquing clashes for bound generic structs
2 parents ce756e3 + 8e9b028 commit 49c0ae4

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,9 +1328,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
13281328
auto *StructTy = BaseTy->castTo<BoundGenericStructType>();
13291329
auto *Decl = StructTy->getDecl();
13301330
auto L = getDebugLoc(*this, Decl);
1331-
return createOpaqueStruct(Scope, Decl ? Decl->getNameStr() : MangledName,
1332-
File, L.Line, SizeInBits, AlignInBits, Flags,
1333-
MangledName);
1331+
return createOpaqueStructWithSizedContainer(
1332+
Scope, Decl ? Decl->getNameStr() : "", File, L.Line, SizeInBits,
1333+
AlignInBits, Flags, MangledName);
13341334
}
13351335

13361336
case TypeKind::BoundGenericClass: {

test/DebugInfo/generic_arg5.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ public func foo<Type>(_ values : [S<Type>])
1515
// CHECK: ![[TYP:[0-9]+]] = !DICompositeType({{.*}}, identifier: "$s12generic_arg51SVyxGD")
1616
// The argument is a by-ref struct and thus needs to be dereferenced.
1717
// CHECK: ![[ARG]] = !DILocalVariable(name: "arg", arg: 1,
18-
// CHECK-SAME: line: [[@LINE+4]],
18+
// CHECK-SAME: line: [[@LINE+7]],
1919
// CHECK-SAME: type: ![[LET_TYP:[0-9]+]])
2020
// CHECK: ![[LET_TYP]] = !DIDerivedType(tag: DW_TAG_const_type,
21-
// CHECK-SAME: baseType: ![[TYP]])
21+
// CHECK-SAME: baseType: ![[TYP_CONTAINER:[0-9]+]])
22+
// CHECK: ![[TYP_CONTAINER]] = !DICompositeType({{.*}}elements: ![[TYP_ELTS:[0-9]+]]
23+
// CHECK: ![[TYP_ELTS]] = !{![[TYP_MEMBER:[0-9]+]]}
24+
// CHECK: ![[TYP_MEMBER]] = !DIDerivedType(tag: DW_TAG_member, {{.*}}baseType: ![[TYP]]
2225
let _ = values.flatMap { arg in
2326
return .some(arg)
2427
}

test/DebugInfo/generic_enum_closure.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ struct CErrorOr<T>
1515
// CHECK-SAME: !DIExpression(DW_OP_deref))
1616
// CHECK-DAG: store i8* %[[DYN:.*]], i8** %[[SHADOW]]
1717
// CHECK-DAG: %[[DYN]] = alloca i8, i{{32|64}} %
18-
// CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, type: ![[T1:.*]])
19-
// CHECK-DAG: ![[T1]] = !DICompositeType({{.*}}, identifier: "$s20generic_enum_closure8CErrorOrVyxGD")
18+
// CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, type: ![[TY_CONTAINER:.*]])
19+
// CHECK-DAG: ![[TY_CONTAINER]] = !DICompositeType({{.*}}elements: ![[TY_ELTS:[0-9]+]]
20+
// CHECK-DAG: ![[TY_ELTS]] = !{![[TY_MEMBER:[0-9]+]]}
21+
// CHECK-DAG: ![[TY_MEMBER]] = !DIDerivedType(tag: DW_TAG_member, {{.*}}baseType: ![[TY:[0-9]+]]
22+
// CHECK-DAG: ![[TY]] = !DICompositeType({{.*}}, identifier: "$s20generic_enum_closure8CErrorOrVyxGD")
2023
value = .none
2124
}
2225
}

test/DebugInfo/mangling.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ func markUsed<T>(_ t: T) {}
99
// mangling.myDict : Swift.Dictionary<Swift.Int64, Swift.String>
1010
// CHECK: !DIGlobalVariable(name: "myDict",
1111
// CHECK-SAME: linkageName: "$s8mangling6myDictSDys5Int64VSSGvp",
12-
// CHECK-SAME: line: [[@LINE+3]]
13-
// CHECK-SAME: type: ![[DT:[0-9]+]]
12+
// CHECK-SAME: line: [[@LINE+6]]
13+
// CHECK-SAME: type: ![[DT_CONTAINER:[0-9]+]]
14+
// CHECK: ![[DT_CONTAINER]] = !DICompositeType({{.*}}elements: ![[DT_ELTS:[0-9]+]]
15+
// CHECK: ![[DT_ELTS]] = !{![[DT_MEMBER:[0-9]+]]}
16+
// CHECK: ![[DT_MEMBER]] = !DIDerivedType(tag: DW_TAG_member, {{.*}}baseType: ![[DT:[0-9]+]]
1417
// CHECK: ![[DT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Dictionary"
1518
var myDict = Dictionary<Int64, String>()
1619
myDict[12] = "Hello!"

test/DebugInfo/variables.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ myprint(tuple)
7272

7373
// Arrays are represented as an instantiation of Array.
7474
// CHECK-DAG: ![[ARRAYTY:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Array",
75-
// CHECK-DAG: !DIGlobalVariable(name: "array_of_tuples",{{.*}} type: ![[ARRAYTY]]
75+
// CHECK-DAG: ![[ARRAY_MEMBER:.*]] = !DIDerivedType(tag: DW_TAG_member, {{.*}}baseType: ![[ARRAYTY]]
76+
// CHECK-DAG: ![[ARRAY_ELTS:.*]] = !{![[ARRAY_MEMBER]]}
77+
// CHECK-DAG: ![[ARRAY_CONTAINER:.*]] = !DICompositeType({{.*}}elements: ![[ARRAY_ELTS]]
78+
// CHECK-DAG: !DIGlobalVariable(name: "array_of_tuples",{{.*}} type: ![[ARRAY_CONTAINER]]
7679
var array_of_tuples : [(a : Int, b : Int)] = [(1,2)]
7780
var twod : [[Int]] = [[1]]
7881

0 commit comments

Comments
 (0)