Skip to content

Commit

Permalink
Disallow assigning symbol a null section.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
espindola committed Oct 3, 2015
1 parent 092a1f7 commit ac4ccba
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 14 deletions.
6 changes: 0 additions & 6 deletions lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions lib/MC/MCMachOStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions lib/MC/MCStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
2 changes: 0 additions & 2 deletions lib/MC/WinCOFFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ac4ccba

Please sign in to comment.