mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 20:26:07 +00:00
DebugInfo: Use the comp_dir of the referencing type units when building debug_line.dwo
This isn't a complete fix - it falls back to non-comp_dir when multiple compile units are in play. Adding a map of comp_dir to table is part of the more general solution, but I gave up (in the short term) when I realized I'd also have to calculate the size of each type unit so as to produce correct DW_AT_stmt_list attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -195,6 +195,9 @@ struct MCDwarfLineTableHeader {
|
|||||||
class MCDwarfDwoLineTable {
|
class MCDwarfDwoLineTable {
|
||||||
MCDwarfLineTableHeader Header;
|
MCDwarfLineTableHeader Header;
|
||||||
public:
|
public:
|
||||||
|
void setCompilationDir(StringRef CompilationDir) {
|
||||||
|
Header.CompilationDir = CompilationDir;
|
||||||
|
}
|
||||||
unsigned getFile(StringRef Directory, StringRef FileName) {
|
unsigned getFile(StringRef Directory, StringRef FileName) {
|
||||||
return Header.getFile(Directory, FileName);
|
return Header.getFile(Directory, FileName);
|
||||||
}
|
}
|
||||||
|
@@ -680,8 +680,7 @@ void DwarfDebug::addGnuPubAttributes(DwarfUnit *U, DIE *D) const {
|
|||||||
|
|
||||||
// Create new DwarfCompileUnit for the given metadata node with tag
|
// Create new DwarfCompileUnit for the given metadata node with tag
|
||||||
// DW_TAG_compile_unit.
|
// DW_TAG_compile_unit.
|
||||||
DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit,
|
DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
||||||
bool Singular) {
|
|
||||||
StringRef FN = DIUnit.getFilename();
|
StringRef FN = DIUnit.getFilename();
|
||||||
CompilationDir = DIUnit.getDirectory();
|
CompilationDir = DIUnit.getDirectory();
|
||||||
|
|
||||||
@@ -689,7 +688,7 @@ DwarfCompileUnit *DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit,
|
|||||||
DwarfCompileUnit *NewCU = new DwarfCompileUnit(
|
DwarfCompileUnit *NewCU = new DwarfCompileUnit(
|
||||||
InfoHolder.getUnits().size(), Die, DIUnit, Asm, this, &InfoHolder);
|
InfoHolder.getUnits().size(), Die, DIUnit, Asm, this, &InfoHolder);
|
||||||
InfoHolder.addUnit(NewCU);
|
InfoHolder.addUnit(NewCU);
|
||||||
if (!Asm->OutStreamer.hasRawTextSupport() || Singular)
|
if (!Asm->OutStreamer.hasRawTextSupport() || SingleCU)
|
||||||
Asm->OutStreamer.getContext().setMCLineTableCompilationDir(
|
Asm->OutStreamer.getContext().setMCLineTableCompilationDir(
|
||||||
NewCU->getUniqueID(), CompilationDir);
|
NewCU->getUniqueID(), CompilationDir);
|
||||||
|
|
||||||
@@ -822,13 +821,11 @@ void DwarfDebug::beginModule() {
|
|||||||
// Emit initial sections so we can reference labels later.
|
// Emit initial sections so we can reference labels later.
|
||||||
emitSectionLabels();
|
emitSectionLabels();
|
||||||
|
|
||||||
auto Operands = CU_Nodes->operands();
|
SingleCU = CU_Nodes->getNumOperands() == 1;
|
||||||
|
|
||||||
bool SingleCU = std::next(Operands.begin()) == Operands.end();
|
for (MDNode *N : CU_Nodes->operands()) {
|
||||||
|
|
||||||
for (MDNode *N : Operands) {
|
|
||||||
DICompileUnit CUNode(N);
|
DICompileUnit CUNode(N);
|
||||||
DwarfCompileUnit *CU = constructDwarfCompileUnit(CUNode, SingleCU);
|
DwarfCompileUnit *CU = constructDwarfCompileUnit(CUNode);
|
||||||
DIArray ImportedEntities = CUNode.getImportedEntities();
|
DIArray ImportedEntities = CUNode.getImportedEntities();
|
||||||
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
|
for (unsigned i = 0, e = ImportedEntities.getNumElements(); i != e; ++i)
|
||||||
ScopesWithImportedEntities.push_back(std::make_pair(
|
ScopesWithImportedEntities.push_back(std::make_pair(
|
||||||
@@ -2712,6 +2709,14 @@ void DwarfDebug::emitDebugStrDWO() {
|
|||||||
OffSec, StrSym);
|
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,
|
void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
|
||||||
StringRef Identifier, DIE *RefDie,
|
StringRef Identifier, DIE *RefDie,
|
||||||
DICompositeType CTy) {
|
DICompositeType CTy) {
|
||||||
@@ -2728,9 +2733,9 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
|
DIE *UnitDie = new DIE(dwarf::DW_TAG_type_unit);
|
||||||
DwarfTypeUnit *NewTU = new DwarfTypeUnit(
|
DwarfTypeUnit *NewTU =
|
||||||
InfoHolder.getUnits().size(), UnitDie, CU, Asm, this, &InfoHolder,
|
new DwarfTypeUnit(InfoHolder.getUnits().size(), UnitDie, CU, Asm, this,
|
||||||
useSplitDwarf() ? &SplitTypeUnitFileTable : nullptr);
|
&InfoHolder, getDwoLineTable(CU));
|
||||||
TU = NewTU;
|
TU = NewTU;
|
||||||
InfoHolder.addUnit(NewTU);
|
InfoHolder.addUnit(NewTU);
|
||||||
|
|
||||||
|
@@ -467,10 +467,18 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
// Holder for the skeleton information.
|
// Holder for the skeleton information.
|
||||||
DwarfFile SkeletonHolder;
|
DwarfFile SkeletonHolder;
|
||||||
|
|
||||||
// Store file names for type units under fission in a line table header that
|
/// Store file names for type units under fission in a line table header that
|
||||||
// will be emitted into debug_line.dwo.
|
/// 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;
|
MCDwarfDwoLineTable SplitTypeUnitFileTable;
|
||||||
|
|
||||||
|
// True iff there are multiple CUs in this module.
|
||||||
|
bool SingleCU;
|
||||||
|
|
||||||
|
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
|
||||||
|
|
||||||
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
|
||||||
|
|
||||||
const SmallVectorImpl<DwarfUnit *> &getUnits() {
|
const SmallVectorImpl<DwarfUnit *> &getUnits() {
|
||||||
@@ -618,8 +626,7 @@ class DwarfDebug : public AsmPrinterHandler {
|
|||||||
|
|
||||||
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
||||||
/// DW_TAG_compile_unit.
|
/// DW_TAG_compile_unit.
|
||||||
DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit,
|
DwarfCompileUnit *constructDwarfCompileUnit(DICompileUnit DIUnit);
|
||||||
bool Singular);
|
|
||||||
|
|
||||||
/// \brief Construct subprogram DIE.
|
/// \brief Construct subprogram DIE.
|
||||||
void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
|
void constructSubprogramDIE(DwarfCompileUnit *TheCU, const MDNode *N);
|
||||||
|
@@ -143,6 +143,7 @@
|
|||||||
; FISSION: Line table prologue
|
; FISSION: Line table prologue
|
||||||
; FISSION: opcode_base: 1
|
; FISSION: opcode_base: 1
|
||||||
; FISSION-NOT: standard_opcode_lengths
|
; FISSION-NOT: standard_opcode_lengths
|
||||||
|
; FISSION-NOT: include_directories
|
||||||
; FISSION-NOT: file_names[
|
; FISSION-NOT: file_names[
|
||||||
; FISSION: file_names{{.*}} bar.h
|
; FISSION: file_names{{.*}} bar.h
|
||||||
; FISSION: file_names{{.*}} bar.cpp
|
; FISSION: file_names{{.*}} bar.cpp
|
||||||
|
Reference in New Issue
Block a user