From 2f9bdd8c9fffe4646d33a85349f55b43f795a253 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 27 May 2015 20:52:32 +0000 Subject: There is only one current section. Both MCStreamer and MCObjectStreamer were maintaining a current section variable and they were slightly out of sync. I don't think this was observable, but was inefficient and error prone. Changing this requires a few cascading changes: * SwitchSection has to call ChangeSection earlier for ChangeSection to see the old section. * With that change, ChangeSection cannot call EmitLabel, since during ChangeSection we are still in the old section. * When the object streamer requires a begin label, just reused the existing generic support for begin labels instead of calling EmitLabel directly. llvm-svn: 238357 --- llvm/lib/MC/MCObjectStreamer.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'llvm/lib/MC/MCObjectStreamer.cpp') diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 176f5e7..1f6c3ac 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -29,7 +29,7 @@ MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, : MCStreamer(Context), Assembler(new MCAssembler(Context, TAB, *Emitter_, *TAB.createObjectWriter(OS), OS)), - CurSectionData(nullptr), EmitEHFrame(true), EmitDebugFrame(false) {} + EmitEHFrame(true), EmitDebugFrame(false) {} MCObjectStreamer::~MCObjectStreamer() { delete &Assembler->getBackend(); @@ -42,8 +42,9 @@ void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) { if (PendingLabels.size()) { if (!F) { F = new MCDataFragment(); - CurSectionData->getFragmentList().insert(CurInsertionPoint, F); - F->setParent(CurSectionData); + MCSection *CurSection = getCurrentSectionData(); + CurSection->getFragmentList().insert(CurInsertionPoint, F); + F->setParent(CurSection); } for (MCSymbolData *SD : PendingLabels) { SD->setFragment(F); @@ -79,7 +80,6 @@ bool MCObjectStreamer::emitAbsoluteSymbolDiff(const MCSymbol *Hi, void MCObjectStreamer::reset() { if (Assembler) Assembler->reset(); - CurSectionData = nullptr; CurInsertionPoint = MCSection::iterator(); EmitEHFrame = true; EmitDebugFrame = false; @@ -212,7 +212,6 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section, flushPendingLabels(nullptr); bool Created = getAssembler().registerSection(*Section); - CurSectionData = Section; int64_t IntSubsection = 0; if (Subsection && @@ -221,7 +220,7 @@ bool MCObjectStreamer::changeSectionImpl(MCSection *Section, if (IntSubsection < 0 || IntSubsection > 8192) report_fatal_error("Subsection number out of range"); CurInsertionPoint = - CurSectionData->getSubsectionInsertionPoint(unsigned(IntSubsection)); + Section->getSubsectionInsertionPoint(unsigned(IntSubsection)); return Created; } -- cgit v1.1