Skip to content

Commit de7fcf3

Browse files
committed
Emit the special stdlib builtin types into full dwarf metadata
1 parent 7b6f45c commit de7fcf3

File tree

1 file changed

+35
-41
lines changed

1 file changed

+35
-41
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "IRGenDebugInfo.h"
18+
#include "GenEnum.h"
1819
#include "GenOpaque.h"
1920
#include "GenStruct.h"
2021
#include "GenType.h"
@@ -1525,7 +1526,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15251526
? 0
15261527
: DbgTy.getAlignment().getValue() * SizeOfByte;
15271528
unsigned Encoding = 0;
1528-
uint32_t NumExtraInhabitants = 0;
1529+
uint32_t NumExtraInhabitants =
1530+
DbgTy.getNumExtraInhabitants() ? *DbgTy.getNumExtraInhabitants() : 0;
1531+
15291532
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
15301533

15311534
TypeBase *BaseTy = DbgTy.getType();
@@ -1549,17 +1552,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15491552
Encoding = llvm::dwarf::DW_ATE_unsigned;
15501553
if (auto CompletedDbgTy = CompletedDebugTypeInfo::get(DbgTy))
15511554
SizeInBits = getSizeOfBasicType(*CompletedDbgTy);
1552-
if (auto DbgTyNumExtraInhabitants = DbgTy.getNumExtraInhabitants())
1553-
NumExtraInhabitants = *DbgTyNumExtraInhabitants;
15541555
break;
15551556
}
15561557

15571558
case TypeKind::BuiltinIntegerLiteral: {
15581559
Encoding = llvm::dwarf::DW_ATE_unsigned; // ?
15591560
if (auto CompletedDbgTy = CompletedDebugTypeInfo::get(DbgTy))
15601561
SizeInBits = getSizeOfBasicType(*CompletedDbgTy);
1561-
if (auto DbgTyNumExtraInhabitants = DbgTy.getNumExtraInhabitants())
1562-
NumExtraInhabitants = *DbgTyNumExtraInhabitants;
15631562
break;
15641563
}
15651564

@@ -1568,48 +1567,30 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15681567
// Assuming that the bitwidth and FloatTy->getFPKind() are identical.
15691568
SizeInBits = FloatTy->getBitWidth();
15701569
Encoding = llvm::dwarf::DW_ATE_float;
1571-
if (auto DbgTyNumExtraInhabitants = DbgTy.getNumExtraInhabitants())
1572-
NumExtraInhabitants = *DbgTyNumExtraInhabitants;
15731570
break;
15741571
}
15751572

1576-
case TypeKind::BuiltinNativeObject: {
1577-
unsigned PtrSize = CI.getTargetInfo().getPointerWidth(clang::LangAS::Default);
1578-
auto PTy = DBuilder.createPointerType(nullptr, PtrSize, 0,
1579-
/* DWARFAddressSpace */ llvm::None,
1580-
MangledName);
1581-
return DBuilder.createObjectPointerType(PTy);
1582-
}
1583-
1584-
case TypeKind::BuiltinBridgeObject: {
1585-
unsigned PtrSize = CI.getTargetInfo().getPointerWidth(clang::LangAS::Default);
1586-
auto PTy = DBuilder.createPointerType(nullptr, PtrSize, 0,
1587-
/* DWARFAddressSpace */ llvm::None,
1588-
MangledName);
1589-
return DBuilder.createObjectPointerType(PTy);
1590-
}
1591-
1592-
case TypeKind::BuiltinRawPointer: {
1593-
unsigned PtrSize = CI.getTargetInfo().getPointerWidth(clang::LangAS::Default);
1594-
return DBuilder.createPointerType(nullptr, PtrSize, 0,
1595-
/* DWARFAddressSpace */ llvm::None,
1596-
MangledName);
1597-
}
1573+
case TypeKind::BuiltinNativeObject:
1574+
case TypeKind::BuiltinBridgeObject:
1575+
case TypeKind::BuiltinRawPointer:
1576+
case TypeKind::BuiltinRawUnsafeContinuation:
1577+
case TypeKind::BuiltinJob: {
1578+
unsigned PtrSize =
1579+
CI.getTargetInfo().getPointerWidth(clang::LangAS::Default);
1580+
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
1581+
Flags |= llvm::DINode::FlagArtificial;
1582+
llvm::DICompositeType *PTy = DBuilder.createStructType(
1583+
Scope, MangledName, File, 0, PtrSize, 0, Flags, nullptr, nullptr,
1584+
llvm::dwarf::DW_LANG_Swift, nullptr, {}, NumExtraInhabitants);
1585+
return PTy;
15981586

1599-
case TypeKind::BuiltinRawUnsafeContinuation: {
1600-
unsigned PtrSize = CI.getTargetInfo().getPointerWidth(clang::LangAS::Default);
1601-
return DBuilder.createPointerType(nullptr, PtrSize, 0,
1602-
/* DWARFAddressSpace */ llvm::None,
1603-
MangledName);
1604-
}
1587+
}
1588+
llvm::DIDerivedType *PTy = DBuilder.createPointerType(
1589+
nullptr, PtrSize, 0,
1590+
/* DWARFAddressSpace */ llvm::None, MangledName);
16051591

1606-
case TypeKind::BuiltinJob: {
1607-
unsigned PtrSize = CI.getTargetInfo().getPointerWidth(clang::LangAS::Default);
1608-
return DBuilder.createPointerType(nullptr, PtrSize, 0,
1609-
/* DWARFAddressSpace */ llvm::None,
1610-
MangledName);
1592+
return DBuilder.createObjectPointerType(PTy);
16111593
}
1612-
16131594
case TypeKind::BuiltinExecutor: {
16141595
return createDoublePointerSizedStruct(
16151596
Scope, "Builtin.Executor", nullptr, MainFile, 0,
@@ -2033,6 +2014,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20332014
}
20342015
#endif
20352016

2017+
void createSpecialStlibBuiltinTypes() {
2018+
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::ASTTypes)
2019+
return;
2020+
for (auto BuiltinType: IGM.getSpecialBuiltinTypes()) {
2021+
auto DbgTy = DebugTypeInfo::getFromTypeInfo(
2022+
BuiltinType, IGM.getTypeInfoForUnlowered(BuiltinType), IGM, false);
2023+
DBuilder.retainType(getOrCreateType(DbgTy));
2024+
}
2025+
}
2026+
20362027
llvm::DIType *getOrCreateType(DebugTypeInfo DbgTy) {
20372028
// Is this an empty type?
20382029
if (DbgTy.isNull())
@@ -2079,6 +2070,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20792070
TypeDecl = ND;
20802071
Context = ND->getParent();
20812072
ClangDecl = ND->getClangDecl();
2073+
} else if (auto BNO = dyn_cast<BuiltinType>(DbgTy.getType())) {
2074+
Context = BNO->getASTContext().TheBuiltinModule;
20822075
}
20832076
if (ClangDecl) {
20842077
clang::ASTReader &Reader = *CI.getClangInstance().getASTReader();
@@ -2255,6 +2248,7 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
22552248
}
22562249
OS << '"';
22572250
}
2251+
createSpecialStlibBuiltinTypes();
22582252
}
22592253

22602254
void IRGenDebugInfoImpl::finalize() {

0 commit comments

Comments
 (0)