[llvm] r237913 - Avoid unnecessary section switching. NFC.

Rafael Espindola rafael.espindola at gmail.com
Thu May 21 10:00:40 PDT 2015


Author: rafael
Date: Thu May 21 12:00:40 2015
New Revision: 237913

URL: http://llvm.org/viewvc/llvm-project?rev=237913&view=rev
Log:
Avoid unnecessary section switching. NFC.

Modified:
    llvm/trunk/include/llvm/MC/MCObjectStreamer.h
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/lib/MC/MCContext.cpp

Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=237913&r1=237912&r2=237913&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Thu May 21 12:00:40 2015
@@ -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();
   }
 };
 

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=237913&r1=237912&r2=237913&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Thu May 21 12:00:40 2015
@@ -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

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=237913&r1=237912&r2=237913&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Thu May 21 12:00:40 2015
@@ -442,8 +442,7 @@ bool MCContext::isValidDwarfFileNumber(u
 void MCContext::finalizeDwarfSections(MCStreamer &MCOS) {
   std::vector<const MCSection *> 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();





More information about the llvm-commits mailing list