mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Generalize ownership/passing semantics to allow dsymutil to own abbreviations via unique_ptr
While still allowing CodeGen/AsmPrinter in llvm to own them using a bump ptr allocator. (might be nice to replace the pointers there with something that at least automatically calls their dtors, if that's necessary/useful, rather than having it done explicitly (I think a typed BumpPtrAllocator already does this, or maybe a unique_ptr with a custom deleter, etc)) llvm-svn: 253409
This commit is contained in:
parent
51f7706708
commit
133cb3aa66
@ -453,7 +453,16 @@ public:
|
||||
void emitCFIInstruction(const MCCFIInstruction &Inst) const;
|
||||
|
||||
/// \brief Emit Dwarf abbreviation table.
|
||||
void emitDwarfAbbrevs(const std::vector<DIEAbbrev *>& Abbrevs) const;
|
||||
template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
|
||||
// For each abbreviation.
|
||||
for (const auto &Abbrev : Abbrevs)
|
||||
emitDwarfAbbrev(*Abbrev);
|
||||
|
||||
// Mark end of abbreviations.
|
||||
EmitULEB128(0, "EOM(3)");
|
||||
}
|
||||
|
||||
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
|
||||
|
||||
/// \brief Recursively emit Dwarf DIE tree.
|
||||
void emitDwarfDIE(const DIE &Die) const;
|
||||
|
@ -281,17 +281,10 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AsmPrinter::emitDwarfAbbrevs(const std::vector<DIEAbbrev *>& Abbrevs) const {
|
||||
// For each abbreviation.
|
||||
for (const DIEAbbrev *Abbrev : Abbrevs) {
|
||||
// Emit the abbreviations code (base 1 index.)
|
||||
EmitULEB128(Abbrev->getNumber(), "Abbreviation Code");
|
||||
void AsmPrinter::emitDwarfAbbrev(const DIEAbbrev &Abbrev) const {
|
||||
// Emit the abbreviations code (base 1 index.)
|
||||
EmitULEB128(Abbrev.getNumber(), "Abbreviation Code");
|
||||
|
||||
// Emit the abbreviations data.
|
||||
Abbrev->Emit(this);
|
||||
}
|
||||
|
||||
// Mark end of abbreviations.
|
||||
EmitULEB128(0, "EOM(3)");
|
||||
// Emit the abbreviations data.
|
||||
Abbrev.Emit(this);
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ public:
|
||||
|
||||
/// \brief Emit the abbreviation table \p Abbrevs to the
|
||||
/// debug_abbrev section.
|
||||
void emitAbbrevs(const std::vector<DIEAbbrev *> &Abbrevs);
|
||||
void emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs);
|
||||
|
||||
/// \brief Emit the string table described by \p Pool.
|
||||
void emitStrings(const NonRelocatableStringpool &Pool);
|
||||
@ -683,7 +683,8 @@ void DwarfStreamer::emitCompileUnitHeader(CompileUnit &Unit) {
|
||||
|
||||
/// \brief Emit the \p Abbrevs array as the shared abbreviation table
|
||||
/// for the linked Dwarf file.
|
||||
void DwarfStreamer::emitAbbrevs(const std::vector<DIEAbbrev *> &Abbrevs) {
|
||||
void DwarfStreamer::emitAbbrevs(
|
||||
const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs) {
|
||||
MS->SwitchSection(MOFI->getDwarfAbbrevSection());
|
||||
Asm->emitDwarfAbbrevs(Abbrevs);
|
||||
}
|
||||
@ -1111,11 +1112,6 @@ public:
|
||||
: OutputFilename(OutputFilename), Options(Options),
|
||||
BinHolder(Options.Verbose), LastCIEOffset(0) {}
|
||||
|
||||
~DwarfLinker() {
|
||||
for (auto *Abbrev : Abbreviations)
|
||||
delete Abbrev;
|
||||
}
|
||||
|
||||
/// \brief Link the contents of the DebugMap.
|
||||
bool link(const DebugMap &);
|
||||
|
||||
@ -1379,7 +1375,7 @@ private:
|
||||
/// \brief Storage for the unique Abbreviations.
|
||||
/// This is passed to AsmPrinter::emitDwarfAbbrevs(), thus it cannot
|
||||
/// be changed to a vecot of unique_ptrs.
|
||||
std::vector<DIEAbbrev *> Abbreviations;
|
||||
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
|
||||
|
||||
/// \brief Compute and emit debug_ranges section for \p Unit, and
|
||||
/// patch the attributes referencing it.
|
||||
@ -2282,10 +2278,10 @@ void DwarfLinker::AssignAbbrev(DIEAbbrev &Abbrev) {
|
||||
} else {
|
||||
// Add to abbreviation list.
|
||||
Abbreviations.push_back(
|
||||
new DIEAbbrev(Abbrev.getTag(), Abbrev.hasChildren()));
|
||||
llvm::make_unique<DIEAbbrev>(Abbrev.getTag(), Abbrev.hasChildren()));
|
||||
for (const auto &Attr : Abbrev.getData())
|
||||
Abbreviations.back()->AddAttribute(Attr.getAttribute(), Attr.getForm());
|
||||
AbbreviationsSet.InsertNode(Abbreviations.back(), InsertToken);
|
||||
AbbreviationsSet.InsertNode(Abbreviations.back().get(), InsertToken);
|
||||
// Assign the unique abbreviation number.
|
||||
Abbrev.setNumber(Abbreviations.size());
|
||||
Abbreviations.back()->setNumber(Abbreviations.size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user