Pass a MCSection to getCurrentSectionData.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 26 May 2015 14:42:52 +0000 (14:42 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 26 May 2015 14:42:52 +0000 (14:42 +0000)
A step towards merging MCSection and MCSectionData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238203 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCELFStreamer.cpp

index b6778c4ab83171ade2e1ef455c4b5b9019c70a28..110dd3338bdade01feff237347ac92d65002e5b9 100644 (file)
@@ -138,18 +138,17 @@ void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
 // If bundle aligment is used and there are any instructions in the section, it
 // needs to be aligned to at least the bundle size.
 static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
-                                           MCSectionData *SD) {
-  if (!SD)
-    return;
-  MCSection &Section = SD->getSection();
-  if (Assembler.isBundlingEnabled() && Section.hasInstructions() &&
-      Section.getAlignment() < Assembler.getBundleAlignSize())
-    Section.setAlignment(Assembler.getBundleAlignSize());
+                                           MCSection *Section) {
+  if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions() &&
+      Section->getAlignment() < Assembler.getBundleAlignSize())
+    Section->setAlignment(Assembler.getBundleAlignSize());
 }
 
 void MCELFStreamer::ChangeSection(MCSection *Section,
                                   const MCExpr *Subsection) {
-  MCSectionData *CurSection = getCurrentSectionData();
+  MCSectionData *CurSectionData = getCurrentSectionData();
+  MCSection *CurSection =
+      CurSectionData ? &CurSectionData->getSection() : nullptr;
   if (CurSection && isBundleLocked())
     report_fatal_error("Unterminated .bundle_lock when changing a section");
 
@@ -660,7 +659,10 @@ void MCELFStreamer::Flush() {
 
 void MCELFStreamer::FinishImpl() {
   // Ensure the last section gets aligned if necessary.
-  setSectionAlignmentForBundling(getAssembler(), getCurrentSectionData());
+  MCSectionData *CurSectionData = getCurrentSectionData();
+  MCSection *CurSection =
+      CurSectionData ? &CurSectionData->getSection() : nullptr;
+  setSectionAlignmentForBundling(getAssembler(), CurSection);
 
   EmitFrames(nullptr);