diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-06-19 12:16:55 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-06-19 12:16:55 +0000 |
commit | 284a750c5ff95a29cd8cc9130d3eb7ec6d25e352 (patch) | |
tree | 38c934be221f58276592baa899f0514b9ac2d46b /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 9fb676a2543434ed0df96649195a0529b23a8dea (diff) | |
download | bcm5719-llvm-284a750c5ff95a29cd8cc9130d3eb7ec6d25e352.tar.gz bcm5719-llvm-284a750c5ff95a29cd8cc9130d3eb7ec6d25e352.zip |
Make all temporary symbols unnamed.
What this does is make all symbols that would otherwise start with a .L
(or L on MachO) unnamed.
Some of these symbols still show up in the symbol table, but we can just
make them unnamed.
In order to make sure we produce identical results when going thought assembly,
all .L (not just the compiler produced ones), are now unnamed.
Running llc on llvm-as.opt.bc, the peak memory usage goes from 208.24MB to
205.57MB.
llvm-svn: 240130
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 0765937d0ea..bbf0b2b69d3 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -786,10 +786,15 @@ void ELFObjectWriter::computeSymbolTable( Renames.count(&Symbol))) continue; + if (Symbol.isTemporary() && Symbol.isUndefined()) + Ctx.reportFatalError(SMLoc(), "Undefined temporary"); + ELFSymbolData MSD; MSD.Symbol = cast<MCSymbolELF>(&Symbol); bool Local = Symbol.getBinding() == ELF::STB_LOCAL; + assert(Local || !Symbol.isTemporary()); + if (Symbol.isAbsolute()) { MSD.SectionIndex = ELF::SHN_ABS; } else if (Symbol.isCommon()) { @@ -888,9 +893,11 @@ void ELFObjectWriter::computeSymbolTable( unsigned Index = FileNames.size() + 1; for (ELFSymbolData &MSD : LocalSymbolData) { - unsigned StringIndex = MSD.Symbol->getType() == ELF::STT_SECTION - ? 0 - : StrTabBuilder.getOffset(MSD.Name); + unsigned StringIndex; + if (MSD.Symbol->getType() == ELF::STT_SECTION || MSD.Name.empty()) + StringIndex = 0; + else + StringIndex = StrTabBuilder.getOffset(MSD.Name); MSD.Symbol->setIndex(Index++); writeSymbol(Writer, StringIndex, MSD, Layout); } |