[DebugInfo] Use the human-readable name as name of FwdDecls of unused structs

rdar://162080220
This commit is contained in:
Adrian Prantl
2025-10-06 17:54:57 -07:00
parent 305f0edb20
commit b8f2d33ded
6 changed files with 16 additions and 8 deletions

View File

@@ -2694,8 +2694,9 @@ private:
// declarations may not have a unique ID to avoid a forward declaration
// winning over a full definition.
auto *FwdDecl = DBuilder.createReplaceableCompositeType(
llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, 0, 0,
llvm::dwarf::DW_LANG_Swift);
llvm::dwarf::DW_TAG_structure_type, Name, Scope, 0, 0,
llvm::dwarf::DW_LANG_Swift, 0, 0, llvm::DINode::FlagFwdDecl,
MangledName);
FwdDeclTypes.emplace_back(
std::piecewise_construct, std::make_tuple(MangledName),
std::make_tuple(static_cast<llvm::Metadata *>(FwdDecl)));

View File

@@ -31,12 +31,11 @@ public let inner = S2<Double>.Inner(t:4.2)
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Inner",
// CHECK-SAME: size: 64, {{.*}}identifier: "$s18BoundGenericStruct2S2V5InnerVySd_GD")
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2VyxGD",
// CHECK-SAME: flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift)
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, {{.*}}flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, {{.*}}identifier: "$s18BoundGenericStruct2S2VyxGD"
// 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]+]])
// DWARF-DAG: ![[SCOPE1]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2VyxGD",
// DWARF-DAG: ![[SCOPE1]] = !DICompositeType(tag: DW_TAG_structure_type, {{.*}}identifier: "$s18BoundGenericStruct2S2VyxGD"
// DWARF-DAG: ![[PARAMS2]] = !{![[PARAMS3:[0-9]+]]}
// DWARF-DAG: ![[PARAMS3]] = !DITemplateTypeParameter(type: ![[PARAMS4:[0-9]+]])

View File

@@ -32,3 +32,11 @@ public let d = D<Int>(v: D.V(obj: 1), u: 2)
// CHECK: ![[D:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D"
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "V", scope: ![[D]],
public struct Unused {
public struct W {}
}
public let w = Unused.W()
// CHECK-DAG: ![[Unused:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Unused"
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "W", scope: ![[Unused]],

View File

@@ -9,7 +9,7 @@ public struct Q<T> {
// CHECK-SAME: ![[ARG:.*]], !DIExpression()
// CHECK: store ptr %0, ptr %[[ALLOCA]], align
// No deref here: the array argument is passed by value.
// CHECK: ![[DITY:.*]] = !DICompositeType({{.*}}name: "$sSay12generic_arg41QVyxGGD"
// CHECK: ![[DITY:.*]] = !DICompositeType({{.*}}identifier: "$sSay12generic_arg41QVyxGGD"
public func foo<T>(_ arg: [Q<T>]) {
// CHECK: ![[ARG]] = !DILocalVariable(name: "arg", arg: 1,
// CHECK-SAME: line: [[@LINE-2]], type: ![[DITY:.*]])

View File

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

View File

@@ -29,7 +29,7 @@ public func f() {
// CHECK: store ptr %[[S1]], ptr %[[ADDR]]
}
// CHECK: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s16resilient_struct4SizeVD",
// CHECK: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Size",
// CHECK: ![[LET_TY:[0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type,
// CHECK-SAME: baseType: ![[TY:[0-9]+]])
// CHECK: ![[V1]] = !DILocalVariable(name: "s1", {{.*}}type: ![[LET_TY]])