mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 07:30:31 +00:00
Simplify arange output.
Move SectionMap to its only user (emitDebugARanges) and reorder to save a call to sort. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
138aa39eac
commit
4b2e78ecac
@ -490,9 +490,6 @@ void DwarfDebug::beginModule() {
|
||||
|
||||
// Tell MMI that we have debug info.
|
||||
MMI->setDebugInfoAvailability(true);
|
||||
|
||||
// Prime section data.
|
||||
SectionMap[Asm->getObjFileLowering().getTextSection()];
|
||||
}
|
||||
|
||||
void DwarfDebug::finishVariableDefinitions() {
|
||||
@ -608,53 +605,6 @@ void DwarfDebug::finalizeModuleInfo() {
|
||||
SkeletonHolder.computeSizeAndOffsets();
|
||||
}
|
||||
|
||||
void DwarfDebug::endSections() {
|
||||
// Filter labels by section.
|
||||
for (const SymbolCU &SCU : ArangeLabels) {
|
||||
if (SCU.Sym->isInSection()) {
|
||||
// Make a note of this symbol and it's section.
|
||||
const MCSection *Section = &SCU.Sym->getSection();
|
||||
if (!Section->getKind().isMetadata())
|
||||
SectionMap[Section].push_back(SCU);
|
||||
} else {
|
||||
// Some symbols (e.g. common/bss on mach-o) can have no section but still
|
||||
// appear in the output. This sucks as we rely on sections to build
|
||||
// arange spans. We can do it without, but it's icky.
|
||||
SectionMap[nullptr].push_back(SCU);
|
||||
}
|
||||
}
|
||||
|
||||
// Build a list of sections used.
|
||||
std::vector<const MCSection *> Sections;
|
||||
for (const auto &it : SectionMap) {
|
||||
const MCSection *Section = it.first;
|
||||
Sections.push_back(Section);
|
||||
}
|
||||
|
||||
// Sort the sections into order.
|
||||
// This is only done to ensure consistent output order across different runs.
|
||||
std::sort(Sections.begin(), Sections.end(), SectionSort);
|
||||
|
||||
// Add terminating symbols for each section.
|
||||
for (unsigned ID = 0, E = Sections.size(); ID != E; ID++) {
|
||||
const MCSection *Section = Sections[ID];
|
||||
MCSymbol *Sym = nullptr;
|
||||
|
||||
if (Section) {
|
||||
// We can't call MCSection::getLabelEndName, as it's only safe to do so
|
||||
// if we know the section name up-front. For user-created sections, the
|
||||
// resulting label may not be valid to use as a label. (section names can
|
||||
// use a greater set of characters on some systems)
|
||||
Sym = Asm->GetTempSymbol("debug_end", ID);
|
||||
Asm->OutStreamer.SwitchSection(Section);
|
||||
Asm->OutStreamer.EmitLabel(Sym);
|
||||
}
|
||||
|
||||
// Insert a final terminator.
|
||||
SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
|
||||
}
|
||||
}
|
||||
|
||||
// Emit all Dwarf sections that should come after the content.
|
||||
void DwarfDebug::endModule() {
|
||||
assert(CurFn == nullptr);
|
||||
@ -666,10 +616,6 @@ void DwarfDebug::endModule() {
|
||||
if (!DwarfInfoSectionSym)
|
||||
return;
|
||||
|
||||
// End any existing sections.
|
||||
// TODO: Does this need to happen?
|
||||
endSections();
|
||||
|
||||
// Finalize the debug info for the module.
|
||||
finalizeModuleInfo();
|
||||
|
||||
@ -1805,13 +1751,26 @@ struct ArangeSpan {
|
||||
// Emit a debug aranges section, containing a CU lookup for any
|
||||
// address we can tie back to a CU.
|
||||
void DwarfDebug::emitDebugARanges() {
|
||||
// Start the dwarf aranges section.
|
||||
Asm->OutStreamer.SwitchSection(
|
||||
Asm->getObjFileLowering().getDwarfARangesSection());
|
||||
// Provides a unique id per text section.
|
||||
DenseMap<const MCSection *, SmallVector<SymbolCU, 8>> SectionMap;
|
||||
|
||||
typedef DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> SpansType;
|
||||
// Prime section data.
|
||||
SectionMap[Asm->getObjFileLowering().getTextSection()];
|
||||
|
||||
SpansType Spans;
|
||||
// Filter labels by section.
|
||||
for (const SymbolCU &SCU : ArangeLabels) {
|
||||
if (SCU.Sym->isInSection()) {
|
||||
// Make a note of this symbol and it's section.
|
||||
const MCSection *Section = &SCU.Sym->getSection();
|
||||
if (!Section->getKind().isMetadata())
|
||||
SectionMap[Section].push_back(SCU);
|
||||
} else {
|
||||
// Some symbols (e.g. common/bss on mach-o) can have no section but still
|
||||
// appear in the output. This sucks as we rely on sections to build
|
||||
// arange spans. We can do it without, but it's icky.
|
||||
SectionMap[nullptr].push_back(SCU);
|
||||
}
|
||||
}
|
||||
|
||||
// Build a list of sections used.
|
||||
std::vector<const MCSection *> Sections;
|
||||
@ -1824,7 +1783,27 @@ void DwarfDebug::emitDebugARanges() {
|
||||
// This is only done to ensure consistent output order across different runs.
|
||||
std::sort(Sections.begin(), Sections.end(), SectionSort);
|
||||
|
||||
// Build a set of address spans, sorted by CU.
|
||||
// Add terminating symbols for each section.
|
||||
for (unsigned ID = 0, E = Sections.size(); ID != E; ID++) {
|
||||
const MCSection *Section = Sections[ID];
|
||||
MCSymbol *Sym = nullptr;
|
||||
|
||||
if (Section) {
|
||||
// We can't call MCSection::getLabelEndName, as it's only safe to do so
|
||||
// if we know the section name up-front. For user-created sections, the
|
||||
// resulting label may not be valid to use as a label. (section names can
|
||||
// use a greater set of characters on some systems)
|
||||
Sym = Asm->GetTempSymbol("debug_end", ID);
|
||||
Asm->OutStreamer.SwitchSection(Section);
|
||||
Asm->OutStreamer.EmitLabel(Sym);
|
||||
}
|
||||
|
||||
// Insert a final terminator.
|
||||
SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
|
||||
}
|
||||
|
||||
DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans;
|
||||
|
||||
for (const MCSection *Section : Sections) {
|
||||
SmallVector<SymbolCU, 8> &List = SectionMap[Section];
|
||||
if (List.size() < 2)
|
||||
@ -1875,6 +1854,10 @@ void DwarfDebug::emitDebugARanges() {
|
||||
}
|
||||
}
|
||||
|
||||
// Start the dwarf aranges section.
|
||||
Asm->OutStreamer.SwitchSection(
|
||||
Asm->getObjFileLowering().getDwarfARangesSection());
|
||||
|
||||
unsigned PtrSize = Asm->getDataLayout().getPointerSize();
|
||||
|
||||
// Build a list of CUs used.
|
||||
|
@ -201,10 +201,6 @@ class DwarfDebug : public AsmPrinterHandler {
|
||||
// Size of each symbol emitted (for those symbols that have a specific size).
|
||||
DenseMap<const MCSymbol *, uint64_t> SymSize;
|
||||
|
||||
// Provides a unique id per text section.
|
||||
typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
|
||||
SectionMapType SectionMap;
|
||||
|
||||
LexicalScopes LScopes;
|
||||
|
||||
// Collection of abstract variables.
|
||||
@ -371,10 +367,6 @@ class DwarfDebug : public AsmPrinterHandler {
|
||||
/// processed.
|
||||
void finalizeModuleInfo();
|
||||
|
||||
/// \brief Emit labels to close any remaining sections that have been left
|
||||
/// open.
|
||||
void endSections();
|
||||
|
||||
/// \brief Emit the debug info section.
|
||||
void emitDebugInfo();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user