[llvm] r249220 - Disallow assigning symbol a null section.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 17:18:14 PDT 2015
Author: rafael
Date: Fri Oct 2 19:18:14 2015
New Revision: 249220
URL: http://llvm.org/viewvc/llvm-project?rev=249220&view=rev
Log:
Disallow assigning symbol a null section.
They are constructed without one and they can't go back, so this was
effectively dead code.
Modified:
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=249220&r1=249219&r2=249220&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Oct 2 19:18:14 2015
@@ -533,9 +533,6 @@ void MCAsmStreamer::emitELFSize(MCSymbol
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(MCS
/// @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;
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=249220&r1=249219&r2=249220&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Fri Oct 2 19:18:14 2015
@@ -384,8 +384,6 @@ void MCMachOStreamer::EmitCommonSymbol(M
// 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);
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=249220&r1=249219&r2=249220&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Fri Oct 2 19:18:14 2015
@@ -189,10 +189,8 @@ void MCStreamer::InitSections(bool NoExe
}
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'.
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=249220&r1=249219&r2=249220&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Fri Oct 2 19:18:14 2015
@@ -214,8 +214,6 @@ void MCWinCOFFStreamer::EmitCommonSymbol
Size = std::max(Size, static_cast<uint64_t>(ByteAlignment));
}
- AssignSection(Symbol, nullptr);
-
getAssembler().registerSymbol(*Symbol);
Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
More information about the llvm-commits
mailing list