MC: Drop support for alignment in ZeroFill fragment, we can just use
authorDaniel Dunbar <daniel@zuster.org>
Wed, 12 May 2010 22:51:27 +0000 (22:51 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 12 May 2010 22:51:27 +0000 (22:51 +0000)
MCAlignFragments for this.

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

include/llvm/MC/MCAssembler.h
lib/MC/MCAssembler.cpp
lib/MC/MCMachOStreamer.cpp

index 8bd67342009734faf6c966516884deadd3e6f576..ddf4ec958999a3adbf4b4718c0b1d73f1afbe407 100644 (file)
@@ -359,21 +359,15 @@ class MCZeroFillFragment : public MCFragment {
   /// 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) {
index 7bcce2e7e349b9659702ea84015f149e723f3a9b..fbda26b4ce8a0db2bbf2d45be7fa842dd0d5997b 100644 (file)
@@ -421,16 +421,7 @@ void MCAssembler::LayoutFragment(MCAsmLayout &Layout, MCFragment &F) {
   }
 
   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 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCAsmLayout &Layout,
     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 @@ void MCZeroFillFragment::dump() {
   OS << "<MCZeroFillFragment ";
   this->MCFragment::dump();
   OS << "\n       ";
-  OS << " Size:" << getSize() << " Alignment:" << getAlignment() << ">";
+  OS << " Size:" << getSize() << ">";
 }
 
 void MCSectionData::dump() {
index ad6ce79ff33de5dd689f764608e97082a1e01382..eb49a40707d0778c4a63ad73d2fa9396274d3fcf 100644 (file)
@@ -321,7 +321,12 @@ void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
 
   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);