// Create new DwarfCompileUnit for the given metadata node with tag
// DW_TAG_compile_unit.
-DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit,
- bool Singular) {
+DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
StringRef FN = DIUnit.getFilename();
CompilationDir = DIUnit.getDirectory();
DwarfCompileUnit *NewCU = new DwarfCompileUnit(
InfoHolder.getUnits().size(), Die, DIUnit, Asm, this, &InfoHolder);
InfoHolder.addUnit(NewCU);
- if (!Asm->OutStreamer.hasRawTextSupport() || Singular)
+ if (!Asm->OutStreamer.hasRawTextSupport() || SingleCU)
Asm->OutStreamer.getContext().setMCLineTableCompilationDir(
NewCU->getUniqueID(), CompilationDir);
// Emit initial sections so we can reference labels later.
emitSectionLabels();
- auto Operands = CU_Nodes->operands();
+ SingleCU = CU_Nodes->getNumOperands() == 1;
- bool SingleCU = std::next(Operands.begin()) == Operands.end();
-
- for (MDNode *N : Operands) {
+ for (MDNode *N : CU_Nodes->operands()) {
DICompileUnit CUNode(N);
- DwarfCompileUnit *CU = constructDwarfCompileUnit(CUNode, SingleCU);
+ DwarfCompileUnit *CU = constructDwarfCompileUnit(CUNode);
DIArray ImportedEntities = CUNode.getImportedEntities();
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
ScopesWithImportedEntities.push_back(std::make_pair(
OffSec, StrSym);
}
+MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) {
+ if (!useSplitDwarf())
+ return nullptr;
+ if (SingleCU)
+ SplitTypeUnitFileTable.setCompilationDir(CU.getCUNode().getDirectory());
+ return &SplitTypeUnitFileTable;
+}
+
void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
StringRef Identifier, DIE *RefDie,
DICompositeType CTy) {
}
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
- DwarfTypeUnit *NewTU = new DwarfTypeUnit(
- InfoHolder.getUnits().size(), UnitDie, CU, Asm, this, &InfoHolder,
- useSplitDwarf() ? &SplitTypeUnitFileTable : nullptr);
+ DwarfTypeUnit *NewTU =
+ new DwarfTypeUnit(InfoHolder.getUnits().size(), UnitDie, CU, Asm, this,
+ &InfoHolder, getDwoLineTable(CU));
TU = NewTU;
InfoHolder.addUnit(NewTU);
// Holder for the skeleton information.
DwarfFile SkeletonHolder;
- // Store file names for type units under fission in a line table header that
- // will be emitted into debug_line.dwo.
+ /// Store file names for type units under fission in a line table header that
+ /// will be emitted into debug_line.dwo.
+ // FIXME: replace this with a map from comp_dir to table so that we can emit
+ // multiple tables during LTO each of which uses directory 0, referencing the
+ // comp_dir of all the type units that use it.
MCDwarfDwoLineTable SplitTypeUnitFileTable;
+ // True iff there are multiple CUs in this module.
+ bool SingleCU;
+
+ MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
+
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
const SmallVectorImpl<DwarfUnit *> &getUnits() {
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
/// DW_TAG_compile_unit.
- DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit,
- bool Singular);
+ DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
/// \brief Construct subprogram DIE.
void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);