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
This commit is contained in:
Rafael Espindola 2015-10-03 00:18:14 +00:00
parent 092a1f7acc
commit ac4ccbae9f
4 changed files with 2 additions and 14 deletions

View File

@ -533,9 +533,6 @@ void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) { unsigned ByteAlignment) {
// Common symbols do not belong to any actual section.
AssignSection(Symbol, nullptr);
OS << "\t.comm\t"; OS << "\t.comm\t";
Symbol->print(OS, MAI); Symbol->print(OS, MAI);
OS << ',' << Size; OS << ',' << Size;
@ -555,9 +552,6 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
/// @param Size - The size of the common symbol. /// @param Size - The size of the common symbol.
void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlign) { unsigned ByteAlign) {
// Common symbols do not belong to any actual section.
AssignSection(Symbol, nullptr);
OS << "\t.lcomm\t"; OS << "\t.lcomm\t";
Symbol->print(OS, MAI); Symbol->print(OS, MAI);
OS << ',' << Size; OS << ',' << Size;

View 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. // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol); getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true); Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment); Symbol->setCommon(Size, ByteAlignment);

View File

@ -189,10 +189,8 @@ void MCStreamer::InitSections(bool NoExecStack) {
} }
void MCStreamer::AssignSection(MCSymbol *Symbol, MCSection *Section) { void MCStreamer::AssignSection(MCSymbol *Symbol, MCSection *Section) {
if (Section) assert(Section);
Symbol->setSection(*Section); Symbol->setSection(*Section);
else
Symbol->setUndefined();
// As we emit symbols into a section, track the order so that they can // As we emit symbols into a section, track the order so that they can
// be sorted upon later. Zero is reserved to mean 'unemitted'. // be sorted upon later. Zero is reserved to mean 'unemitted'.

View File

@ -214,8 +214,6 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Size = std::max(Size, static_cast<uint64_t>(ByteAlignment)); Size = std::max(Size, static_cast<uint64_t>(ByteAlignment));
} }
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol); getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true); Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment); Symbol->setCommon(Size, ByteAlignment);