[llvm] r238203 - Pass a MCSection to getCurrentSectionData.

Rafael Espindola rafael.espindola at gmail.com
Tue May 26 07:42:52 PDT 2015


Author: rafael
Date: Tue May 26 09:42:52 2015
New Revision: 238203

URL: http://llvm.org/viewvc/llvm-project?rev=238203&view=rev
Log:
Pass a MCSection to getCurrentSectionData.

A step towards merging MCSection and MCSectionData.

Modified:
    llvm/trunk/lib/MC/MCELFStreamer.cpp

Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=238203&r1=238202&r2=238203&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Tue May 26 09:42:52 2015
@@ -138,18 +138,17 @@ void MCELFStreamer::EmitAssemblerFlag(MC
 // 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);
 





More information about the llvm-commits mailing list