Revert previous patch while I debug the darwin bootstrap failure.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 28 Nov 2010 16:22:59 +0000 (16:22 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 28 Nov 2010 16:22:59 +0000 (16:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120246 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCObjectStreamer.h
lib/MC/MCELFStreamer.cpp
lib/MC/MCMachOStreamer.cpp
lib/MC/MCObjectStreamer.cpp
lib/MC/WinCOFFStreamer.cpp

index ccfba43319535f0202668bce5021d87febb2c96d..8c21c10522c1cc55c8786418c5a9c46676da7286 100644 (file)
@@ -60,7 +60,6 @@ public:
   /// @name MCStreamer Interface
   /// @{
 
-  virtual void EmitLabel(MCSymbol *Symbol);
   virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0);
   virtual void EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace = 0);
   virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
index 0286991c106827fe17f389aeb23590dbdcd2b446..2e0d85a1e2db8e369864794c664d0c7d4f9ab5a0 100644 (file)
@@ -189,13 +189,26 @@ void MCELFStreamer::InitSections() {
 }
 
 void MCELFStreamer::EmitLabel(MCSymbol *Symbol) {
-  MCObjectStreamer::EmitLabel(Symbol);
+  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+
+  Symbol->setSection(*CurSection);
+
+  MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
 
   const MCSectionELF &Section =
     static_cast<const MCSectionELF&>(Symbol->getSection());
-  MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
   if (Section.getFlags() & MCSectionELF::SHF_TLS)
     SetType(SD, ELF::STT_TLS);
+
+  // FIXME: This is wasteful, we don't necessarily need to create a data
+  // fragment. Instead, we should mark the symbol as pointing into the data
+  // fragment if it exists, otherwise we should just queue the label and set its
+  // fragment pointer when we emit the next fragment.
+  MCDataFragment *F = getOrCreateDataFragment();
+
+  assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
+  SD.setFragment(F);
+  SD.setOffset(F->getContents().size());
 }
 
 void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
index 02a1f089e80de0fd01b0365a170c8bb770604b02..3f93604caafe0b916d903417e3c4e82a85270305 100644 (file)
@@ -105,6 +105,14 @@ void MCMachOStreamer::InitSections() {
 }
 
 void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
+  // TODO: This is almost exactly the same as WinCOFFStreamer. Consider merging
+  // into MCObjectStreamer.
+  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+  assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
+  assert(CurSection && "Cannot emit before setting section!");
+
+  Symbol->setSection(*CurSection);
+
   MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
 
   // We have to create a new fragment if this is an atom defining symbol,
@@ -112,7 +120,14 @@ void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
   if (getAssembler().isSymbolLinkerVisible(SD.getSymbol()))
     new MCDataFragment(getCurrentSectionData());
 
-  MCObjectStreamer::EmitLabel(Symbol);
+  // FIXME: This is wasteful, we don't necessarily need to create a data
+  // fragment. Instead, we should mark the symbol as pointing into the data
+  // fragment if it exists, otherwise we should just queue the label and set its
+  // fragment pointer when we emit the next fragment.
+  MCDataFragment *F = getOrCreateDataFragment();
+  assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
+  SD.setFragment(F);
+  SD.setOffset(F->getContents().size());
 
   // This causes the reference type flag to be cleared. Darwin 'as' was "trying"
   // to clear the weak reference and weak definition bits too, but the
index 1b5c0784d290a35287c5c960568e29d75beafd25..a40c75465808edde81906d907fe8a55699849233 100644 (file)
@@ -14,7 +14,6 @@
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCDwarf.h"
 #include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCSymbol.h"
 #include "llvm/Target/TargetAsmBackend.h"
 using namespace llvm;
 
@@ -76,25 +75,6 @@ const MCExpr *MCObjectStreamer::AddValueSymbols(const MCExpr *Value) {
   return Value;
 }
 
-void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
-  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
-  assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
-  assert(CurSection && "Cannot emit before setting section!");
-
-  Symbol->setSection(*CurSection);
-
-  MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
-
-  // FIXME: This is wasteful, we don't necessarily need to create a data
-  // fragment. Instead, we should mark the symbol as pointing into the data
-  // fragment if it exists, otherwise we should just queue the label and set its
-  // fragment pointer when we emit the next fragment.
-  MCDataFragment *F = getOrCreateDataFragment();
-  assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
-  SD.setFragment(F);
-  SD.setOffset(F->getContents().size());
-}
-
 void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value,
                                         unsigned AddrSpace) {
   new MCLEBFragment(*Value, false, getCurrentSectionData());
index 1754ed309576de607ba7dd86006fa159a405f1ba..cba71882676aef2b873dbd820981f0c15b7fe453 100644 (file)
@@ -49,6 +49,7 @@ public:
   // MCStreamer interface
 
   virtual void InitSections();
+  virtual void EmitLabel(MCSymbol *Symbol);
   virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
   virtual void EmitThumbFunc(MCSymbol *Func);
   virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
@@ -174,6 +175,28 @@ void WinCOFFStreamer::InitSections() {
   SetSectionText();
 }
 
+void WinCOFFStreamer::EmitLabel(MCSymbol *Symbol) {
+  // TODO: This is copied almost exactly from the MachOStreamer. Consider
+  // merging into MCObjectStreamer?
+  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
+  assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
+  assert(CurSection && "Cannot emit before setting section!");
+
+  Symbol->setSection(*CurSection);
+
+  MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
+
+  // FIXME: This is wasteful, we don't necessarily need to create a data
+  // fragment. Instead, we should mark the symbol as pointing into the data
+  // fragment if it exists, otherwise we should just queue the label and set its
+  // fragment pointer when we emit the next fragment.
+  MCDataFragment *DF = getOrCreateDataFragment();
+
+  assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
+  SD.setFragment(DF);
+  SD.setOffset(DF->getContents().size());
+}
+
 void WinCOFFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
   llvm_unreachable("not implemented");
 }