[DebugInfo] Generate full debug info for classes

This commit is contained in:
Augusto Noronha
2024-02-01 17:39:22 -08:00
committed by Augusto Noronha
parent 2084da1163
commit 3352e7d157
2 changed files with 22 additions and 6 deletions

View File

@@ -1079,8 +1079,6 @@ private:
llvm::dwarf::DW_TAG_structure_type, UniqueID, Scope, File, Line,
llvm::dwarf::DW_LANG_Swift, SizeInBits, 0);
}
if (OffsetInBits > SizeInBits)
SizeInBits = OffsetInBits;
auto DITy = DBuilder.createStructType(
Scope, Name, File, Line, SizeInBits, AlignInBits, Flags, DerivedFrom,
@@ -1526,8 +1524,7 @@ private:
? 0
: DbgTy.getAlignment().getValue() * SizeOfByte;
unsigned Encoding = 0;
uint32_t NumExtraInhabitants =
DbgTy.getNumExtraInhabitants() ? *DbgTy.getNumExtraInhabitants() : 0;
uint32_t NumExtraInhabitants = DbgTy.getNumExtraInhabitants().value_or(0);
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
@@ -1644,6 +1641,25 @@ private:
unsigned FwdDeclLine = 0;
assert(SizeInBits ==
CI.getTargetInfo().getPointerWidth(clang::LangAS::Default));
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
auto *DIType = createStructType(
DbgTy, Decl, ClassTy, Scope, File, L.Line, SizeInBits, AlignInBits,
Flags, nullptr, llvm::dwarf::DW_LANG_Swift, MangledName);
assert(DIType && "Unexpected null DIType!");
assert(DIType && "createStructType should never return null!");
auto SuperClassTy = ClassTy->getSuperclass();
if (SuperClassTy) {
auto SuperClassDbgTy = DebugTypeInfo::getFromTypeInfo(
SuperClassTy, IGM.getTypeInfoForUnlowered(SuperClassTy), IGM,
false);
llvm::DIType *SuperClassDITy = getOrCreateType(SuperClassDbgTy);
assert(SuperClassDITy && "getOrCreateType should never return null!");
DBuilder.retainType(DBuilder.createInheritance(
DIType, SuperClassDITy, 0, 0, llvm::DINode::FlagZero));
}
return DIType;
}
return createPointerSizedStruct(Scope, Decl->getNameStr(), L.File,
FwdDeclLine, Flags, MangledName);
}
@@ -2021,7 +2037,7 @@ private:
void createSpecialStlibBuiltinTypes() {
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::ASTTypes)
return;
for (auto BuiltinType: IGM.getSpecialBuiltinTypes()) {
for (auto BuiltinType: IGM.getOrCreateSpecialStlibBuiltinTypes()) {
auto DbgTy = DebugTypeInfo::getFromTypeInfo(
BuiltinType, IGM.getTypeInfoForUnlowered(BuiltinType), IGM, false);
DBuilder.retainType(getOrCreateType(DbgTy));

View File

@@ -13,6 +13,6 @@ public class C<T>
}
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "T",
// CHECK-SAME: baseType: ![[PTRTY:[0-9]+]]
// CHECK: ![[PTRTY]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "$sBpD", baseType: null, size: {{64|32}})
// CHECK: ![[PTRTY]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "$sBpD", baseType: null, size: {{64|32}}, flags: DIFlagArtificial | DIFlagObjectPointer)
// CHECK: ![[LOC]] = !DILocation(line: 0,