mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Add DwarfUnit::isDwoUnit and use it to generalize string creation
Currently we only need to emit skeleton strings into the CU header and we do this by explicitly calling "addLocalString". With gmlt-in-fission, we'll be emitting a bunch of other strings from other codepaths where it's not statically known that these strings will be local or not. Introduce a virtual function to indicate whether this unit is a DWO unit or not (I'm not sure if we have a good term for this, the opposite/alternative to 'skeleton' unit) and use that to generalize the string emission logic so that strings can be correctly emitted in both the skeleton and dwo unit when in split dwarf mode. And to demonstrate that this works, switch the existing special callers of addLocalString in the skeleton builder to addString - and they still work. Yay. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1fcc568ebb
commit
67177d320d
@ -836,4 +836,8 @@ void DwarfCompileUnit::applySubprogramAttributesToDefinition(DISubprogram SP,
|
|||||||
DIBuilder::LineTablesOnly);
|
DIBuilder::LineTablesOnly);
|
||||||
addGlobalName(SP.getName(), SPDie, Context);
|
addGlobalName(SP.getName(), SPDie, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DwarfCompileUnit::isDwoUnit() const {
|
||||||
|
return DD->useSplitDwarf() && Skeleton;
|
||||||
|
}
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
@ -53,6 +53,8 @@ class DwarfCompileUnit : public DwarfUnit {
|
|||||||
std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
|
std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
|
||||||
bool Abstract);
|
bool Abstract);
|
||||||
|
|
||||||
|
bool isDwoUnit() const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DwarfCompileUnit(unsigned UID, DICompileUnit Node, AsmPrinter *A,
|
DwarfCompileUnit(unsigned UID, DICompileUnit Node, AsmPrinter *A,
|
||||||
DwarfDebug *DW, DwarfFile *DWU);
|
DwarfDebug *DW, DwarfFile *DWU);
|
||||||
|
@ -362,6 +362,8 @@ DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
|||||||
DwarfCompileUnit &NewCU = *OwnedUnit;
|
DwarfCompileUnit &NewCU = *OwnedUnit;
|
||||||
DIE &Die = NewCU.getUnitDie();
|
DIE &Die = NewCU.getUnitDie();
|
||||||
InfoHolder.addUnit(std::move(OwnedUnit));
|
InfoHolder.addUnit(std::move(OwnedUnit));
|
||||||
|
if (useSplitDwarf())
|
||||||
|
NewCU.setSkeleton(constructSkeletonCU(NewCU));
|
||||||
|
|
||||||
// LTO with assembly output shares a single line table amongst multiple CUs.
|
// LTO with assembly output shares a single line table amongst multiple CUs.
|
||||||
// To avoid the compilation directory being ambiguous, let the line table
|
// To avoid the compilation directory being ambiguous, let the line table
|
||||||
@ -398,11 +400,10 @@ DwarfCompileUnit &DwarfDebug::constructDwarfCompileUnit(DICompileUnit DIUnit) {
|
|||||||
NewCU.addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
|
NewCU.addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
|
||||||
dwarf::DW_FORM_data1, RVer);
|
dwarf::DW_FORM_data1, RVer);
|
||||||
|
|
||||||
if (useSplitDwarf()) {
|
if (useSplitDwarf())
|
||||||
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoDWOSection(),
|
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoDWOSection(),
|
||||||
DwarfInfoDWOSectionSym);
|
DwarfInfoDWOSectionSym);
|
||||||
NewCU.setSkeleton(constructSkeletonCU(NewCU));
|
else
|
||||||
} else
|
|
||||||
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
|
NewCU.initSection(Asm->getObjFileLowering().getDwarfInfoSection(),
|
||||||
DwarfInfoSectionSym);
|
DwarfInfoSectionSym);
|
||||||
|
|
||||||
@ -2041,11 +2042,11 @@ void DwarfDebug::emitDebugRanges() {
|
|||||||
|
|
||||||
void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
|
void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
|
||||||
std::unique_ptr<DwarfUnit> NewU) {
|
std::unique_ptr<DwarfUnit> NewU) {
|
||||||
NewU->addLocalString(Die, dwarf::DW_AT_GNU_dwo_name,
|
NewU->addString(Die, dwarf::DW_AT_GNU_dwo_name,
|
||||||
U.getCUNode().getSplitDebugFilename());
|
U.getCUNode().getSplitDebugFilename());
|
||||||
|
|
||||||
if (!CompilationDir.empty())
|
if (!CompilationDir.empty())
|
||||||
NewU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
|
NewU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
|
||||||
|
|
||||||
addGnuPubAttributes(*NewU, Die);
|
addGnuPubAttributes(*NewU, Die);
|
||||||
|
|
||||||
|
@ -201,10 +201,14 @@ void DwarfUnit::addSInt(DIELoc &Die, Optional<dwarf::Form> Form,
|
|||||||
/// table.
|
/// table.
|
||||||
void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
|
void DwarfUnit::addString(DIE &Die, dwarf::Attribute Attribute,
|
||||||
StringRef String) {
|
StringRef String) {
|
||||||
|
if (!isDwoUnit())
|
||||||
if (!DD->useSplitDwarf())
|
|
||||||
return addLocalString(Die, Attribute, String);
|
return addLocalString(Die, Attribute, String);
|
||||||
|
|
||||||
|
addIndexedString(Die, Attribute, String);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DwarfUnit::addIndexedString(DIE &Die, dwarf::Attribute Attribute,
|
||||||
|
StringRef String) {
|
||||||
unsigned idx = DU->getStringPool().getIndex(*Asm, String);
|
unsigned idx = DU->getStringPool().getIndex(*Asm, String);
|
||||||
DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
|
DIEValue *Value = new (DIEValueAllocator) DIEInteger(idx);
|
||||||
DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
|
DIEValue *Str = new (DIEValueAllocator) DIEString(Value, String);
|
||||||
@ -1632,3 +1636,8 @@ void DwarfTypeUnit::emitHeader(const MCSymbol *ASectionSym) const {
|
|||||||
sizeof(Ty->getOffset()));
|
sizeof(Ty->getOffset()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DwarfTypeUnit::isDwoUnit() const {
|
||||||
|
// Since there are no skeleton type units, all type units are dwo type units
|
||||||
|
// when split DWARF is being used.
|
||||||
|
return DD->useSplitDwarf();
|
||||||
|
}
|
||||||
|
@ -127,6 +127,12 @@ protected:
|
|||||||
DwarfDebug *DW, DwarfFile *DWU);
|
DwarfDebug *DW, DwarfFile *DWU);
|
||||||
|
|
||||||
void initSection(const MCSection *Section);
|
void initSection(const MCSection *Section);
|
||||||
|
|
||||||
|
/// Add a string attribute data and value.
|
||||||
|
void addLocalString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
|
||||||
|
|
||||||
|
void addIndexedString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DwarfUnit();
|
virtual ~DwarfUnit();
|
||||||
|
|
||||||
@ -209,10 +215,6 @@ public:
|
|||||||
/// addString - Add a string attribute data and value.
|
/// addString - Add a string attribute data and value.
|
||||||
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
|
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str);
|
||||||
|
|
||||||
/// addLocalString - Add a string attribute data and value.
|
|
||||||
void addLocalString(DIE &Die, dwarf::Attribute Attribute,
|
|
||||||
StringRef Str);
|
|
||||||
|
|
||||||
/// addLabel - Add a Dwarf label attribute data and value.
|
/// addLabel - Add a Dwarf label attribute data and value.
|
||||||
void addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
|
void addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form,
|
||||||
const MCSymbol *Label);
|
const MCSymbol *Label);
|
||||||
@ -412,15 +414,19 @@ private:
|
|||||||
/// If this is a named finished type then include it in the list of types for
|
/// If this is a named finished type then include it in the list of types for
|
||||||
/// the accelerator tables.
|
/// the accelerator tables.
|
||||||
void updateAcceleratorTables(DIScope Context, DIType Ty, const DIE &TyDIE);
|
void updateAcceleratorTables(DIScope Context, DIType Ty, const DIE &TyDIE);
|
||||||
|
|
||||||
|
virtual bool isDwoUnit() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DwarfTypeUnit : public DwarfUnit {
|
class DwarfTypeUnit : public DwarfUnit {
|
||||||
private:
|
|
||||||
uint64_t TypeSignature;
|
uint64_t TypeSignature;
|
||||||
const DIE *Ty;
|
const DIE *Ty;
|
||||||
DwarfCompileUnit &CU;
|
DwarfCompileUnit &CU;
|
||||||
MCDwarfDwoLineTable *SplitLineTable;
|
MCDwarfDwoLineTable *SplitLineTable;
|
||||||
|
|
||||||
|
unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
|
||||||
|
bool isDwoUnit() const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DwarfTypeUnit(unsigned UID, DwarfCompileUnit &CU, AsmPrinter *A,
|
DwarfTypeUnit(unsigned UID, DwarfCompileUnit &CU, AsmPrinter *A,
|
||||||
DwarfDebug *DW, DwarfFile *DWU,
|
DwarfDebug *DW, DwarfFile *DWU,
|
||||||
@ -438,9 +444,6 @@ public:
|
|||||||
}
|
}
|
||||||
using DwarfUnit::initSection;
|
using DwarfUnit::initSection;
|
||||||
DwarfCompileUnit &getCU() override { return CU; }
|
DwarfCompileUnit &getCU() override { return CU; }
|
||||||
|
|
||||||
protected:
|
|
||||||
unsigned getOrCreateSourceID(StringRef File, StringRef Directory) override;
|
|
||||||
};
|
};
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user