[llvm] 0c454df - [MC] Make changeSection private

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 21:01:56 PDT 2024


Author: Fangrui Song
Date: 2024-06-27T21:01:52-07:00
New Revision: 0c454df448c1edd1ce65573b8343721636cc541b

URL: https://github.com/llvm/llvm-project/commit/0c454df448c1edd1ce65573b8343721636cc541b
DIFF: https://github.com/llvm/llvm-project/commit/0c454df448c1edd1ce65573b8343721636cc541b.diff

LOG: [MC] Make changeSection private

Using changeSection externally would cause `CurFrag` to be out of sync
of `SectionStack`. Remove some uses from MipsTargetStreamer.cpp.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCStreamer.h
    llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index a8ca438cb39ba..20328a41cfbd8 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -255,6 +255,10 @@ class MCStreamer {
   /// discussion for future inclusion.
   bool AllowAutoPadding = false;
 
+  /// This is called by popSection and switchSection, if the current
+  /// section changes.
+  virtual void changeSection(MCSection *, uint32_t);
+
 protected:
   MCFragment *CurFrag = nullptr;
 
@@ -410,12 +414,6 @@ class MCStreamer {
     return SymbolOrdering.lookup(Sym);
   }
 
-  /// Update streamer for a new active section.
-  ///
-  /// This is called by popSection and switchSection, if the current
-  /// section changes.
-  virtual void changeSection(MCSection *, uint32_t);
-
   /// Save the current and previous section on the section stack.
   void pushSection() {
     SectionStack.push_back(

diff  --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
index 2f39d091d86d7..3093b9fddc73a 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
@@ -894,11 +894,11 @@ void MipsTargetELFStreamer::finish() {
 
   // .bss, .text and .data are always at least 16-byte aligned.
   MCSection &TextSection = *OFI.getTextSection();
-  S.changeSection(&TextSection);
+  S.switchSection(&TextSection);
   MCSection &DataSection = *OFI.getDataSection();
-  S.changeSection(&DataSection);
+  S.switchSection(&DataSection);
   MCSection &BSSSection = *OFI.getBSSSection();
-  S.changeSection(&BSSSection);
+  S.switchSection(&BSSSection);
 
   TextSection.ensureMinAlignment(Align(16));
   DataSection.ensureMinAlignment(Align(16));


        


More information about the llvm-commits mailing list