summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCContext.cpp28
-rw-r--r--llvm/lib/MC/MCDwarf.cpp17
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp8
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp6
4 files changed, 24 insertions, 35 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 0a13c9e6edb..bbff9b7c6a5 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -77,7 +77,7 @@ void MCContext::reset() {
CompilationDir.clear();
MainFileName.clear();
MCDwarfLineTablesCUMap.clear();
- SectionStartEndSyms.clear();
+ SectionsForRanges.clear();
MCGenDwarfLabelEntries.clear();
DwarfDebugFlags = StringRef();
DwarfCompileUnitID = 0;
@@ -437,27 +437,17 @@ bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) {
return !MCDwarfFiles[FileNumber].Name.empty();
}
-/// finalizeDwarfSections - Emit end symbols for each non-empty code section.
-/// Also remove empty sections from SectionStartEndSyms, to avoid generating
+/// Remove empty sections from SectionStartEndSyms, to avoid generating
/// useless debug info for them.
void MCContext::finalizeDwarfSections(MCStreamer &MCOS) {
- MCContext &context = MCOS.getContext();
-
- auto sec = SectionStartEndSyms.begin();
- while (sec != SectionStartEndSyms.end()) {
- assert(sec->second.first && "Start symbol must be set by now");
- MCOS.SwitchSection(sec->first);
- if (MCOS.mayHaveInstructions()) {
- MCSymbol *SectionEndSym = context.createTempSymbol();
- MCOS.EmitLabel(SectionEndSym);
- sec->second.second = SectionEndSym;
- ++sec;
- } else {
- MapVector<const MCSection *, std::pair<MCSymbol *, MCSymbol *>>::iterator
- to_erase = sec;
- sec = SectionStartEndSyms.erase(to_erase);
- }
+ std::vector<const MCSection *> Keep;
+ for (const MCSection *Sec : SectionsForRanges) {
+ MCOS.SwitchSection(Sec); // FIXME: pass the section to mayHaveInstructions
+ if (MCOS.mayHaveInstructions())
+ Keep.push_back(Sec);
}
+ SectionsForRanges.clear();
+ SectionsForRanges.insert(Keep.begin(), Keep.end());
}
void MCContext::reportFatalError(SMLoc Loc, const Twine &Msg) const {
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 74eee83b73f..ad70d61dccb 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -610,9 +610,9 @@ static void EmitGenDwarfAranges(MCStreamer *MCOS,
// Now emit the table of pairs of PointerSize'ed values for the section
// addresses and sizes.
- for (const auto &sec : Sections) {
- MCSymbol *StartSymbol = sec.second.first;
- MCSymbol *EndSymbol = sec.second.second;
+ for (const MCSection *Sec : Sections) {
+ MCSymbol *StartSymbol = Sec->getBeginSymbol();
+ MCSymbol *EndSymbol = Sec->getEndSymbol(context);
assert(StartSymbol && "StartSymbol must not be NULL");
assert(EndSymbol && "EndSymbol must not be NULL");
@@ -699,8 +699,8 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
const auto TextSection = Sections.begin();
assert(TextSection != Sections.end() && "No text section found");
- MCSymbol *StartSymbol = TextSection->second.first;
- MCSymbol *EndSymbol = TextSection->second.second;
+ MCSymbol *StartSymbol = (*TextSection)->getBeginSymbol();
+ MCSymbol *EndSymbol = (*TextSection)->getEndSymbol(context);
assert(StartSymbol && "StartSymbol must not be NULL");
assert(EndSymbol && "EndSymbol must not be NULL");
@@ -805,10 +805,9 @@ static void EmitGenDwarfRanges(MCStreamer *MCOS) {
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfRangesSection());
- for (const auto &sec : Sections) {
-
- MCSymbol *StartSymbol = sec.second.first;
- MCSymbol *EndSymbol = sec.second.second;
+ for (const MCSection *Sec : Sections) {
+ MCSymbol *StartSymbol = Sec->getBeginSymbol();
+ MCSymbol *EndSymbol = Sec->getEndSymbol(context);
assert(StartSymbol && "StartSymbol must not be NULL");
assert(EndSymbol && "EndSymbol must not be NULL");
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 5b5cc5fae2a..da3fc72057e 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -632,10 +632,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
if (getContext().getGenDwarfForAssembly()) {
MCSymbol *SectionStartSym = getContext().createTempSymbol();
getStreamer().EmitLabel(SectionStartSym);
- auto InsertResult = getContext().addGenDwarfSection(
- getStreamer().getCurrentSection().first);
- assert(InsertResult.second && ".text section should not have debug info yet");
- InsertResult.first->second.first = SectionStartSym;
+ const MCSection *Sec = getStreamer().getCurrentSection().first;
+ bool InsertResult = getContext().addGenDwarfSection(Sec);
+ assert(InsertResult && ".text section should not have debug info yet");
+ Sec->setBeginSymbol(SectionStartSym);
getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective(
0, StringRef(), getContext().getMainFileName()));
}
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index d99a6c4836b..6b0a7785517 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -532,14 +532,14 @@ EndStmt:
getStreamer().SwitchSection(ELFSection, Subsection);
if (getContext().getGenDwarfForAssembly()) {
- auto InsertResult = getContext().addGenDwarfSection(ELFSection);
- if (InsertResult.second) {
+ bool InsertResult = getContext().addGenDwarfSection(ELFSection);
+ if (InsertResult) {
if (getContext().getDwarfVersion() <= 2)
Warning(loc, "DWARF2 only supports one section per compilation unit");
MCSymbol *SectionStartSymbol = getContext().createTempSymbol();
getStreamer().EmitLabel(SectionStartSymbol);
- InsertResult.first->second.first = SectionStartSymbol;
+ ELFSection->setBeginSymbol(SectionStartSymbol);
}
}
OpenPOWER on IntegriCloud