Debug info: move the IrTypeAggr::diCompositeType field into IrAggr to get it reset when emitting a new module

diCompositeType might contain references to another compile unit, so has to be re-created for each module.
This commit is contained in:
Elie Morisse 2018-08-21 00:09:41 -03:00 committed by Martin Kinkelin
parent 02eb4058fa
commit a62a94fa43
3 changed files with 11 additions and 12 deletions

View file

@ -506,11 +506,10 @@ ldc::DIType ldc::DIBuilder::CreateCompositeType(Type *type) {
LLType *T = DtoType(ad->type); LLType *T = DtoType(ad->type);
if (t->ty == Tclass) if (t->ty == Tclass)
T = T->getPointerElementType(); T = T->getPointerElementType();
IrTypeAggr *ir = ad->type->ctype->isAggr(); IrAggr *irAggr = getIrAggr(ad, true);
assert(ir);
if (static_cast<llvm::MDNode *>(ir->diCompositeType) != nullptr) { if (static_cast<llvm::MDNode *>(irAggr->diCompositeType) != nullptr) {
return ir->diCompositeType; return irAggr->diCompositeType;
} }
const llvm::StringRef name = ad->ident->toChars(); const llvm::StringRef name = ad->ident->toChars();
@ -534,7 +533,7 @@ ldc::DIType ldc::DIBuilder::CreateCompositeType(Type *type) {
// set diCompositeType to handle recursive types properly // set diCompositeType to handle recursive types properly
unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type
: llvm::dwarf::DW_TAG_class_type; : llvm::dwarf::DW_TAG_class_type;
ir->diCompositeType = DBuilder.createReplaceableCompositeType( irAggr->diCompositeType = DBuilder.createReplaceableCompositeType(
tag, name, scope, file, linnum); tag, name, scope, file, linnum);
if (!ad->isInterfaceDeclaration()) // plain interfaces don't have one if (!ad->isInterfaceDeclaration()) // plain interfaces don't have one
@ -602,9 +601,9 @@ ldc::DIType ldc::DIBuilder::CreateCompositeType(Type *type) {
uniqueIdent(t)); // UniqueIdentifier uniqueIdent(t)); // UniqueIdentifier
} }
ir->diCompositeType = DBuilder.replaceTemporary( irAggr->diCompositeType = DBuilder.replaceTemporary(
llvm::TempDINode(ir->diCompositeType), static_cast<llvm::DIType *>(ret)); llvm::TempDINode(irAggr->diCompositeType), static_cast<llvm::DIType *>(ret));
ir->diCompositeType = ret; irAggr->diCompositeType = ret;
return ret; return ret;
} }

View file

@ -46,6 +46,10 @@ struct IrAggr {
/// Aggregate D type. /// Aggregate D type.
Type *type = nullptr; Type *type = nullptr;
/// Composite type debug description. This is not only to cache, but also
/// used for resolving forward references.
llvm::DIType *diCompositeType = nullptr;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Returns the static default initializer of a field. // Returns the static default initializer of a field.

View file

@ -67,10 +67,6 @@ public:
void getMemberLocation(VarDeclaration *var, unsigned &fieldIndex, void getMemberLocation(VarDeclaration *var, unsigned &fieldIndex,
unsigned &byteOffset) const; unsigned &byteOffset) const;
/// Composite type debug description. This is not only to cache, but also
/// used for resolving forward references.
llvm::DIType *diCompositeType = nullptr;
/// true, if the LLVM struct type for the aggregate is declared as packed /// true, if the LLVM struct type for the aggregate is declared as packed
bool packed = false; bool packed = false;