Avoid unnecessary section switching. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 21 May 2015 17:00:40 +0000 (17:00 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 21 May 2015 17:00:40 +0000 (17:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237913 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCObjectStreamer.h
include/llvm/MC/MCStreamer.h
lib/MC/MCContext.cpp

index 1a1222562f15efcdc91cbeb61b6b3462d837a4c7..c990534e53839fdc6037a05fadc0342212014638 100644 (file)
@@ -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();
   }
 };
 
index 3dec9491a265312b603849327c76ccd998b0bb15..9f679c2482fbd3149acba35eb5485a973e606022 100644 (file)
@@ -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
index bbff9b7c6a555a317a3086c647094cf1df4ea47b..cbc130f6bfa9c52a85c5bf7fbda9d109f0218633 100644 (file)
@@ -442,8 +442,7 @@ bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) {
 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();