diff options
author | Mitch Phillips <31459023+hctim@users.noreply.github.com> | 2019-12-17 15:03:10 -0800 |
---|---|---|
committer | Mitch Phillips <31459023+hctim@users.noreply.github.com> | 2019-12-17 15:04:26 -0800 |
commit | f827aff8598873194bccdfaf469f2dde7e5620d1 (patch) | |
tree | 803d2da455415d33decf477e2303ddd4d1a6ca65 /llvm/lib/MC/MCObjectStreamer.cpp | |
parent | 6d3f43ec61a60c37963ee5f54289cf0759fb5d61 (diff) | |
download | bcm5719-llvm-f827aff8598873194bccdfaf469f2dde7e5620d1.tar.gz bcm5719-llvm-f827aff8598873194bccdfaf469f2dde7e5620d1.zip |
Revert "[ MC ] Match labels to existing fragments even when switching sections."
This reverts commit 4272372c571cd33edc77a8844b0a224ad7339138.
Caused an MSan buildbot failure. More information available in the patch
that introduced the bug: https://reviews.llvm.org/D71368
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 72 |
1 files changed, 13 insertions, 59 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index fc7fe4cb76c..6c85f2296cf 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -42,64 +42,20 @@ MCAssembler *MCObjectStreamer::getAssemblerPtr() { return nullptr; } -void MCObjectStreamer::addPendingLabel(MCSymbol* S) { - MCSection *CurSection = getCurrentSectionOnly(); - if (CurSection) { - // Register labels that have not yet been assigned to a Section. - if (!PendingLabels.empty()) { - for (MCSymbol* Sym : PendingLabels) - CurSection->addPendingLabel(Sym); - PendingLabels.clear(); - } - - // Add this label to the current Section / Subsection. - CurSection->addPendingLabel(S, CurSubsectionIdx); - - // Add this Section to the list of PendingLabelSections. - auto SecIt = std::find(PendingLabelSections.begin(), - PendingLabelSections.end(), CurSection); - if (SecIt == PendingLabelSections.end()) - PendingLabelSections.push_back(CurSection); - } - else - // There is no Section / Subsection for this label yet. - PendingLabels.push_back(S); -} - void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) { - MCSection *CurSection = getCurrentSectionOnly(); - if (!CurSection) { - assert(PendingLabels.empty()); + if (PendingLabels.empty()) return; - } - // Register labels that have not yet been assigned to a Section. - if (!PendingLabels.empty()) { - for (MCSymbol* Sym : PendingLabels) - CurSection->addPendingLabel(Sym, CurSubsectionIdx); - PendingLabels.clear(); - } - - // Associate a fragment with this label, either the supplied fragment - // or an empty data fragment. - if (F) - CurSection->flushPendingLabels(F, FOffset, CurSubsectionIdx); - else - CurSection->flushPendingLabels(nullptr, 0, CurSubsectionIdx); -} - -void MCObjectStreamer::flushPendingLabels() { - // Register labels that have not yet been assigned to a Section. - if (!PendingLabels.empty()) { + if (!F) { + F = new MCDataFragment(); MCSection *CurSection = getCurrentSectionOnly(); - assert(CurSection); - for (MCSymbol* Sym : PendingLabels) - CurSection->addPendingLabel(Sym, CurSubsectionIdx); - PendingLabels.clear(); + CurSection->getFragmentList().insert(CurInsertionPoint, F); + F->setParent(CurSection); } - - // Assign an empty data fragment to all remaining pending labels. - for (MCSection* Section : PendingLabelSections) - Section->flushPendingLabels(); + for (MCSymbol *Sym : PendingLabels) { + Sym->setFragment(F); + Sym->setOffset(FOffset); + } + PendingLabels.clear(); } // When fixup's offset is a forward declared label, e.g.: @@ -164,7 +120,6 @@ void MCObjectStreamer::reset() { EmitEHFrame = true; EmitDebugFrame = false; PendingLabels.clear(); - PendingLabelSections.clear(); MCStreamer::reset(); } @@ -282,7 +237,7 @@ void MCObjectStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { // fragment. (They will all be reassigned to a real fragment in // flushPendingLabels()) Symbol->setOffset(0); - addPendingLabel(Symbol); + PendingLabels.push_back(Symbol); } } @@ -302,7 +257,7 @@ void MCObjectStreamer::EmitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, assert(isa<MCDummyFragment>(F) && "F must either be an MCDataFragment or the pending MCDummyFragment"); assert(Offset == 0); - addPendingLabel(Symbol); + PendingLabels.push_back(Symbol); } } @@ -337,6 +292,7 @@ void MCObjectStreamer::ChangeSection(MCSection *Section, bool MCObjectStreamer::changeSectionImpl(MCSection *Section, const MCExpr *Subsection) { assert(Section && "Cannot switch to a null section!"); + flushPendingLabels(nullptr); getContext().clearDwarfLocSeen(); bool Created = getAssembler().registerSection(*Section); @@ -756,9 +712,7 @@ void MCObjectStreamer::FinishImpl() { // Dump out the dwarf file & directory tables and line tables. MCDwarfLineTable::Emit(this, getAssembler().getDWARFLinetableParams()); - // Update any remaining pending labels with empty data fragments. flushPendingLabels(); - resolvePendingFixups(); getAssembler().Finish(); } |