Skip to content

Commit 7685371

Browse files
authored
Merge pull request #71939 from augusto2112/fix-specify-of-2
[DebugInfo] Fix bound generic types debug info generation
2 parents 59153a0 + 10d263b commit 7685371

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
12071207
return OpaqueType;
12081208
}
12091209

1210-
auto *opaqueType = createOpaqueStructWithSizedContainer(
1211-
Scope, Decl ? Decl->getNameStr() : "", File, Line, SizeInBits,
1212-
AlignInBits, Flags, MangledName, collectGenericParams(Type),
1213-
UnsubstitutedType);
1214-
return opaqueType;
1210+
auto *OpaqueType = createOpaqueStruct(
1211+
Scope, "", File, Line, SizeInBits, AlignInBits, Flags, MangledName,
1212+
collectGenericParams(Type), UnsubstitutedType);
1213+
return OpaqueType;
12151214
}
12161215

12171216
/// Create debug information for an enum with a raw type (enum E : Int {}).
@@ -1647,12 +1646,19 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16471646
llvm::DICompositeType *
16481647
createOpaqueStruct(llvm::DIScope *Scope, StringRef Name, llvm::DIFile *File,
16491648
unsigned Line, unsigned SizeInBits, unsigned AlignInBits,
1650-
llvm::DINode::DIFlags Flags, StringRef MangledName) {
1651-
return DBuilder.createStructType(
1649+
llvm::DINode::DIFlags Flags, StringRef MangledName,
1650+
llvm::DINodeArray BoundParams = {},
1651+
llvm::DIType *SpecificationOf = nullptr) {
1652+
1653+
auto StructType = DBuilder.createStructType(
16521654
Scope, Name, File, Line, SizeInBits, AlignInBits, Flags,
16531655
/* DerivedFrom */ nullptr,
16541656
DBuilder.getOrCreateArray(ArrayRef<llvm::Metadata *>()),
1655-
llvm::dwarf::DW_LANG_Swift, nullptr, MangledName);
1657+
llvm::dwarf::DW_LANG_Swift, nullptr, MangledName, SpecificationOf);
1658+
1659+
if (BoundParams)
1660+
DBuilder.replaceArrays(StructType, nullptr, BoundParams);
1661+
return StructType;
16561662
}
16571663

16581664
bool shouldCacheDIType(llvm::DIType *DITy, DebugTypeInfo &DbgTy) {
@@ -2035,11 +2041,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20352041
// Force the creation of the unsubstituted type, don't create it
20362042
// directly so it goes through all the caching/verification logic.
20372043
auto unsubstitutedDbgTy = getOrCreateType(DbgTy);
2038-
DBuilder.retainType(unsubstitutedDbgTy);
2039-
return createOpaqueStructWithSizedContainer(
2040-
Scope, Decl->getName().str(), L.File, FwdDeclLine, SizeInBits,
2041-
AlignInBits, Flags, MangledName, collectGenericParams(EnumTy),
2042-
unsubstitutedDbgTy);
2044+
return createOpaqueStruct(
2045+
Scope, "", L.File, FwdDeclLine, SizeInBits, AlignInBits, Flags,
2046+
MangledName, collectGenericParams(EnumTy), unsubstitutedDbgTy);
20432047
}
20442048
return createOpaqueStructWithSizedContainer(
20452049
Scope, Decl->getName().str(), L.File, FwdDeclLine, SizeInBits,

test/DebugInfo/BoundGenericStruct.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ public let s = S<Int>(t: 0)
1313
// CHECK: ![[INT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$sSiD",
1414

1515

16-
// DWARF: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct1SVySiGD",
16+
// DWARF: !DICompositeType(tag: DW_TAG_structure_type,
1717
// DWARF-SAME: templateParams: ![[PARAMS:[0-9]+]]
18+
// DWARF-SAME: identifier: "$s18BoundGenericStruct1SVySiGD"
19+
// DWARF-SAME: specification_of:
20+
1821
// DWARF: ![[PARAMS]] = !{![[INTPARAM:[0-9]+]]}
1922
// DWARF: ![[INTPARAM]] = !DITemplateTypeParameter(type: ![[INT:[0-9]+]])
2023
// DWARF: ![[INT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Int", {{.*}}identifier: "$sSiD"

0 commit comments

Comments
 (0)