From ac4ccbae9f921897fd2fda9ecfbfef4479dadb8d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 3 Oct 2015 00:18:14 +0000 Subject: [PATCH] Disallow assigning symbol a null section. 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 | 6 ------ lib/MC/MCMachOStreamer.cpp | 2 -- lib/MC/MCStreamer.cpp | 6 ++---- lib/MC/WinCOFFStreamer.cpp | 2 -- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 0ed817c9809..7a30075bac9 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -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; diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 33045d0fcf7..0f65d51bb73 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -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); diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 57782eaaefc..d6b44a0297d 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -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'. diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index a6e08443910..40c242ce866 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -214,8 +214,6 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Size = std::max(Size, static_cast(ByteAlignment)); } - AssignSection(Symbol, nullptr); - getAssembler().registerSymbol(*Symbol); Symbol->setExternal(true); Symbol->setCommon(Size, ByteAlignment);