return GVEs;
}
-/// Create a DIE for \p Ty if it doesn't already exist. If type units are
-/// enabled, try to emit a type unit without a CU skeleton DIE.
-static void createMaybeUnusedType(DwarfDebug &DD, DwarfCompileUnit &CU,
- DIType &Ty) {
- // Try to generate a type unit without creating a skeleton DIE in this CU.
- if (DICompositeType const *CTy = dyn_cast<DICompositeType>(&Ty)) {
- MDString const *TypeId = CTy->getRawIdentifier();
- if (DD.generateTypeUnits() && TypeId && !Ty.isForwardDecl())
- if (DD.getOrCreateDwarfTypeUnit(CU, TypeId->getString(), CTy))
- return;
- }
- // We couldn't or shouldn't add a type unit so create the DIE normally.
- CU.getOrCreateTypeDIE(&Ty);
-}
-
// Emit all Dwarf sections that should come prior to the content. Create
// global DIEs and emit initial debug info sections. This is invoked by
// the target AsmPrinter.
CU.getOrCreateGlobalVariableDIE(GV, sortGlobalExprs(GVMap[GV]));
}
- for (auto *Ty : CUNode->getEnumTypes()) {
- // The enum types array by design contains pointers to
- // MDNodes rather than DIRefs. Unique them here.
- createMaybeUnusedType(*this, CU, *Ty);
- }
+ for (auto *Ty : CUNode->getEnumTypes())
+ CU.getOrCreateTypeDIE(cast<DIType>(Ty));
+
for (auto *Ty : CUNode->getRetainedTypes()) {
// The retained types array by design contains pointers to
// MDNodes rather than DIRefs. Unique them here.
if (DIType *RT = dyn_cast<DIType>(Ty))
// There is no point in force-emitting a forward declaration.
- createMaybeUnusedType(*this, CU, *RT);
+ CU.getOrCreateTypeDIE(RT);
}
// Emit imported_modules last so that the relevant context is already
// available.
SkeletonHolder.computeSizeAndOffsets();
}
-
// Emit all Dwarf sections that should come after the content.
void DwarfDebug::endModule() {
// Terminate the pending line table.
void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
StringRef Identifier, DIE &RefDie,
const DICompositeType *CTy) {
- bool TopLevelType = TypeUnitsUnderConstruction.empty();
- if (auto Signature = getOrCreateDwarfTypeUnit(CU, Identifier, CTy)) {
- CU.addDIETypeSignature(RefDie, *Signature);
- } else if (TopLevelType) {
- // Construct this type in the CU directly.
- // This is inefficient because all the dependent types will be rebuilt
- // from scratch, including building them in type units, discovering that
- // they depend on addresses, throwing them out and rebuilding them.
- CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
- }
-}
-
-Optional<uint64_t>
-DwarfDebug::getOrCreateDwarfTypeUnit(DwarfCompileUnit &CU, StringRef Identifier,
- const DICompositeType *CTy) {
// Fast path if we're building some type units and one has already used the
// address pool we know we're going to throw away all this work anyway, so
// don't bother building dependent types.
if (!TypeUnitsUnderConstruction.empty() && AddrPool.hasBeenUsed())
- return None;
+ return;
auto Ins = TypeSignatures.insert(std::make_pair(CTy, 0));
- if (!Ins.second)
- return Ins.first->second;
+ if (!Ins.second) {
+ CU.addDIETypeSignature(RefDie, Ins.first->second);
+ return;
+ }
bool TopLevelType = TypeUnitsUnderConstruction.empty();
AddrPool.resetUsedFlag();
// the type that used an address.
for (const auto &TU : TypeUnitsToAdd)
TypeSignatures.erase(TU.second);
- return None;
+
+ // Construct this type in the CU directly.
+ // This is inefficient because all the dependent types will be rebuilt
+ // from scratch, including building them in type units, discovering that
+ // they depend on addresses, throwing them out and rebuilding them.
+ CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
+ return;
}
// If the type wasn't dependent on fission addresses, finish adding the type
InfoHolder.emitUnit(TU.first.get(), useSplitDwarf());
}
}
- return Signature;
+ CU.addDIETypeSignature(RefDie, Signature);
}
DwarfDebug::NonTypeUnitContext::NonTypeUnitContext(DwarfDebug *DD)