[llvm-commits] [llvm] r103661 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp lib/MC/MCMachOStreamer.cpp

Daniel Dunbar daniel at zuster.org
Wed May 12 15:51:27 PDT 2010


Author: ddunbar
Date: Wed May 12 17:51:27 2010
New Revision: 103661

URL: http://llvm.org/viewvc/llvm-project?rev=103661&view=rev
Log:
MC: Drop support for alignment in ZeroFill fragment, we can just use
MCAlignFragments for this.

Modified:
    llvm/trunk/include/llvm/MC/MCAssembler.h
    llvm/trunk/lib/MC/MCAssembler.cpp
    llvm/trunk/lib/MC/MCMachOStreamer.cpp

Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=103661&r1=103660&r2=103661&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Wed May 12 17:51:27 2010
@@ -359,21 +359,15 @@
   /// Size - The size of this fragment.
   uint64_t Size;
 
-  /// Alignment - The alignment for this fragment.
-  unsigned Alignment;
-
 public:
-  MCZeroFillFragment(uint64_t _Size, unsigned _Alignment, MCSectionData *SD = 0)
-    : MCFragment(FT_ZeroFill, SD),
-      Size(_Size), Alignment(_Alignment) {}
+  MCZeroFillFragment(uint64_t _Size, MCSectionData *SD = 0)
+    : MCFragment(FT_ZeroFill, SD), Size(_Size) {}
 
   /// @name Accessors
   /// @{
 
   uint64_t getSize() const { return Size; }
 
-  unsigned getAlignment() const { return Alignment; }
-
   /// @}
 
   static bool classof(const MCFragment *F) {

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=103661&r1=103660&r2=103661&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Wed May 12 17:51:27 2010
@@ -421,16 +421,7 @@
   }
 
   case MCFragment::FT_ZeroFill: {
-    MCZeroFillFragment &ZFF = cast<MCZeroFillFragment>(F);
-
-    // Align the fragment offset; it is safe to adjust the offset freely since
-    // this is only in virtual sections.
-    //
-    // FIXME: We shouldn't be doing this here.
-    Address = RoundUpToAlignment(Address, ZFF.getAlignment());
-    Layout.setFragmentOffset(&F, Address - StartAddress);
-
-    EffectiveSize = ZFF.getSize();
+    EffectiveSize = cast<MCZeroFillFragment>(F).getSize();
     break;
   }
   }
@@ -498,6 +489,8 @@
     MCAlignFragment &AF = cast<MCAlignFragment>(F);
     uint64_t Count = FragmentSize / AF.getValueSize();
 
+    assert(AF.getValueSize() && "Invalid virtual align in concrete fragment!");
+
     // FIXME: This error shouldn't actually occur (the front end should emit
     // multiple .align directives to enforce the semantics it wants), but is
     // severe enough that we want to report it. How to handle this?
@@ -912,7 +905,7 @@
   OS << "<MCZeroFillFragment ";
   this->MCFragment::dump();
   OS << "\n       ";
-  OS << " Size:" << getSize() << " Alignment:" << getAlignment() << ">";
+  OS << " Size:" << getSize() << ">";
 }
 
 void MCSectionData::dump() {

Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=103661&r1=103660&r2=103661&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Wed May 12 17:51:27 2010
@@ -321,7 +321,12 @@
 
   MCSymbolData &SD = Assembler.getOrCreateSymbolData(*Symbol);
 
-  MCFragment *F = new MCZeroFillFragment(Size, ByteAlignment, &SectData);
+  // Emit an align fragment if necessary.
+  if (ByteAlignment != 1)
+    new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, /*EmitNops=*/false,
+                        &SectData);
+
+  MCFragment *F = new MCZeroFillFragment(Size, &SectData);
   SD.setFragment(F);
   if (Assembler.isSymbolLinkerVisible(&SD))
     F->setAtom(&SD);





More information about the llvm-commits mailing list