Disallow assigning symbol a null section.
authorRafael Espindola <rafael.espindola@gmail.com>
Sat, 3 Oct 2015 00:18:14 +0000 (00:18 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sat, 3 Oct 2015 00:18:14 +0000 (00:18 +0000)
They are constructed without one and they can't go back, so this was
effectively dead code.

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

lib/MC/MCAsmStreamer.cpp
lib/MC/MCMachOStreamer.cpp
lib/MC/MCStreamer.cpp
lib/MC/WinCOFFStreamer.cpp

index 0ed817c98091c1a6845ad4037825a957eb8fc281..7a30075bac95a7dcd931a5c91a452c132fb37153 100644 (file)
@@ -533,9 +533,6 @@ void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
 
 void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                                      unsigned ByteAlignment) {
-  // Common symbols do not belong to any actual section.
-  AssignSection(Symbol, nullptr);
-
   OS << "\t.comm\t";
   Symbol->print(OS, MAI);
   OS << ',' << Size;
@@ -555,9 +552,6 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
 /// @param Size - The size of the common symbol.
 void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                                           unsigned ByteAlign) {
-  // Common symbols do not belong to any actual section.
-  AssignSection(Symbol, nullptr);
-
   OS << "\t.lcomm\t";
   Symbol->print(OS, MAI);
   OS << ',' << Size;
index 33045d0fcf7b627b1d1cbb2fbd231503d81fdf4f..0f65d51bb73b8b51f95c0a4eb64ab160a5e35778 100644 (file)
@@ -384,8 +384,6 @@ void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
   // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
   assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
 
-  AssignSection(Symbol, nullptr);
-
   getAssembler().registerSymbol(*Symbol);
   Symbol->setExternal(true);
   Symbol->setCommon(Size, ByteAlignment);
index 57782eaaefcc882c1a8e06c1d17f40363303f3fd..d6b44a0297d5e2129c68653277cb18043e81eeef 100644 (file)
@@ -189,10 +189,8 @@ void MCStreamer::InitSections(bool NoExecStack) {
 }
 
 void MCStreamer::AssignSection(MCSymbol *Symbol, MCSection *Section) {
-  if (Section)
-    Symbol->setSection(*Section);
-  else
-    Symbol->setUndefined();
+  assert(Section);
+  Symbol->setSection(*Section);
 
   // As we emit symbols into a section, track the order so that they can
   // be sorted upon later. Zero is reserved to mean 'unemitted'.
index a6e0844391063f3c08d8bae00557e02c58f0640e..40c242ce86651b8391a9f4013de65fa71688d287 100644 (file)
@@ -214,8 +214,6 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
     Size = std::max(Size, static_cast<uint64_t>(ByteAlignment));
   }
 
-  AssignSection(Symbol, nullptr);
-
   getAssembler().registerSymbol(*Symbol);
   Symbol->setExternal(true);
   Symbol->setCommon(Size, ByteAlignment);