Skip to content

Commit b8f2d33

Browse files
committed
[DebugInfo] Use the human-readable name as name of FwdDecls of unused structs
rdar://162080220
1 parent 305f0ed commit b8f2d33

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,8 +2694,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
26942694
// declarations may not have a unique ID to avoid a forward declaration
26952695
// winning over a full definition.
26962696
auto *FwdDecl = DBuilder.createReplaceableCompositeType(
2697-
llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, 0, 0,
2698-
llvm::dwarf::DW_LANG_Swift);
2697+
llvm::dwarf::DW_TAG_structure_type, Name, Scope, 0, 0,
2698+
llvm::dwarf::DW_LANG_Swift, 0, 0, llvm::DINode::FlagFwdDecl,
2699+
MangledName);
26992700
FwdDeclTypes.emplace_back(
27002701
std::piecewise_construct, std::make_tuple(MangledName),
27012702
std::make_tuple(static_cast<llvm::Metadata *>(FwdDecl)));

test/DebugInfo/BoundGenericStruct.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ public let inner = S2<Double>.Inner(t:4.2)
3131

3232
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Inner",
3333
// CHECK-SAME: size: 64, {{.*}}identifier: "$s18BoundGenericStruct2S2V5InnerVySd_GD")
34-
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2VyxGD",
35-
// CHECK-SAME: flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift)
34+
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, {{.*}}flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, {{.*}}identifier: "$s18BoundGenericStruct2S2VyxGD"
3635

3736
// DWARF-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2V5InnerVySd_GD", scope: ![[SCOPE1:[0-9]+]], {{.*}}flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, templateParams: ![[PARAMS2:[0-9]+]])
3837

39-
// DWARF-DAG: ![[SCOPE1]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2VyxGD",
38+
// DWARF-DAG: ![[SCOPE1]] = !DICompositeType(tag: DW_TAG_structure_type, {{.*}}identifier: "$s18BoundGenericStruct2S2VyxGD"
4039

4140
// DWARF-DAG: ![[PARAMS2]] = !{![[PARAMS3:[0-9]+]]}
4241
// DWARF-DAG: ![[PARAMS3]] = !DITemplateTypeParameter(type: ![[PARAMS4:[0-9]+]])

test/DebugInfo/NestedTypes.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ public let d = D<Int>(v: D.V(obj: 1), u: 2)
3232
// CHECK: ![[D:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D"
3333
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "V", scope: ![[D]],
3434

35+
public struct Unused {
36+
public struct W {}
37+
}
38+
39+
public let w = Unused.W()
40+
41+
// CHECK-DAG: ![[Unused:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Unused"
42+
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "W", scope: ![[Unused]],

test/DebugInfo/generic_arg4.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public struct Q<T> {
99
// CHECK-SAME: ![[ARG:.*]], !DIExpression()
1010
// CHECK: store ptr %0, ptr %[[ALLOCA]], align
1111
// No deref here: the array argument is passed by value.
12-
// CHECK: ![[DITY:.*]] = !DICompositeType({{.*}}name: "$sSay12generic_arg41QVyxGGD"
12+
// CHECK: ![[DITY:.*]] = !DICompositeType({{.*}}identifier: "$sSay12generic_arg41QVyxGGD"
1313
public func foo<T>(_ arg: [Q<T>]) {
1414
// CHECK: ![[ARG]] = !DILocalVariable(name: "arg", arg: 1,
1515
// CHECK-SAME: line: [[@LINE-2]], type: ![[DITY:.*]])

test/DebugInfo/generic_arg5.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public func foo<Type>(_ values : [S<Type>])
1212
// CHECK-SAME: ![[ARG:[0-9]+]],
1313
// CHECK-SAME: !DIExpression(DW_OP_deref)
1414
// CHECK: store ptr %1, ptr %[[ALLOCA]], align
15-
// CHECK-DAG: ![[TYP:[0-9]+]] = !DICompositeType({{.*}}, name: "$s12generic_arg51SVyxGD"
15+
// CHECK-DAG: ![[TYP:[0-9]+]] = !DICompositeType({{.*}}, identifier: "$s12generic_arg51SVyxGD"
1616
// The argument is a by-ref struct and thus needs to be dereferenced.
1717
// CHECK-DAG: ![[ARG]] = !DILocalVariable(name: "arg", arg: 1,{{.*}}line: [[@LINE+6]],{{.*}} type: ![[LET_TYP:[0-9]+]])
1818
// CHECK-DAG: ![[LET_TYP]] = !DIDerivedType(tag: DW_TAG_const_type,{{.*}} baseType: ![[TYP_CONTAINER:[0-9]+]])

test/DebugInfo/struct_resilience.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public func f() {
2929
// CHECK: store ptr %[[S1]], ptr %[[ADDR]]
3030
}
3131

32-
// CHECK: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s16resilient_struct4SizeVD",
32+
// CHECK: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Size",
3333
// CHECK: ![[LET_TY:[0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type,
3434
// CHECK-SAME: baseType: ![[TY:[0-9]+]])
3535
// CHECK: ![[V1]] = !DILocalVariable(name: "s1", {{.*}}type: ![[LET_TY]])

0 commit comments

Comments
 (0)