From: Rafael Espindola Date: Thu, 21 May 2015 17:00:40 +0000 (+0000) Subject: Avoid unnecessary section switching. NFC. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=e0376b0782dc8da097cae2b47ec758c4787fdd95 Avoid unnecessary section switching. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237913 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h index 1a1222562f1..c990534e538 100644 --- a/include/llvm/MC/MCObjectStreamer.h +++ b/include/llvm/MC/MCObjectStreamer.h @@ -147,8 +147,8 @@ public: bool emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) override; - bool mayHaveInstructions() const override { - return getCurrentSectionData()->hasInstructions(); + bool mayHaveInstructions(const MCSection &Sec) const override { + return Assembler->getOrCreateSectionData(Sec).hasInstructions(); } }; diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 3dec9491a26..9f679c2482f 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -728,7 +728,7 @@ public: /// \brief Finish emission of machine code. void Finish(); - virtual bool mayHaveInstructions() const { return true; } + virtual bool mayHaveInstructions(const MCSection &Sec) const { return true; } }; /// Create a dummy machine code streamer, which does nothing. This is useful for diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index bbff9b7c6a5..cbc130f6bfa 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -442,8 +442,7 @@ bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) { void MCContext::finalizeDwarfSections(MCStreamer &MCOS) { std::vector Keep; for (const MCSection *Sec : SectionsForRanges) { - MCOS.SwitchSection(Sec); // FIXME: pass the section to mayHaveInstructions - if (MCOS.mayHaveInstructions()) + if (MCOS.mayHaveInstructions(*Sec)) Keep.push_back(Sec); } SectionsForRanges.clear();