From: Rui Ueyama Date: Mon, 2 May 2016 19:30:42 +0000 (+0000) Subject: Do not pass Symtab to markLive/doICF since Symtab is globally accessible. X-Git-Tag: llvmorg-3.9.0-rc1~7228 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f8d21f3874064bed5fabb0ebecf57b33489aad6;p=platform%2Fupstream%2Fllvm.git Do not pass Symtab to markLive/doICF since Symtab is globally accessible. llvm-svn: 268286 --- diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index cc78552..b8882c2 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -489,8 +489,8 @@ template void LinkerDriver::link(opt::InputArgList &Args) { // Write the result to the file. if (Config->GcSections) - markLive(&Symtab); + markLive(); if (Config->ICF) - doIcf(&Symtab); + doIcf(); writeResult(&Symtab); } diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index acb36fa..10a2603 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -83,7 +83,7 @@ template class ICF { const InputSection *)>; public: - void run(SymbolTable *Symtab); + void run(); private: uint64_t NextId = 1; @@ -92,7 +92,7 @@ private: static uint64_t relSize(InputSection *S); static uint64_t getHash(InputSection *S); static bool isEligible(InputSectionBase *Sec); - static std::vector *> getSections(SymbolTable *S); + static std::vector *> getSections(); void segregate(InputSection **Begin, InputSection **End, Comparator Eq); @@ -146,10 +146,10 @@ template bool ICF::isEligible(InputSectionBase *Sec) { } template -std::vector *> -ICF::getSections(SymbolTable *Symtab) { +std::vector *> ICF::getSections() { std::vector *> V; - for (const std::unique_ptr> &F : Symtab->getObjectFiles()) + for (const std::unique_ptr> &F : + Symtab::X->getObjectFiles()) for (InputSectionBase *S : F->getSections()) if (isEligible(S)) V.push_back(cast>(S)); @@ -289,11 +289,11 @@ bool ICF::equalsVariable(const InputSection *A, } // The main function of ICF. -template void ICF::run(SymbolTable *Symtab) { +template void ICF::run() { // Initially, we use hash values as section group IDs. Therefore, // if two sections have the same ID, they are likely (but not // guaranteed) to have the same static contents in terms of ICF. - std::vector *> V = getSections(Symtab); + std::vector *> V = getSections(); for (InputSection *S : V) // Set MSB on to avoid collisions with serial group IDs S->GroupId = getHash(S) | (uint64_t(1) << 63); @@ -337,11 +337,9 @@ template void ICF::run(SymbolTable *Symtab) { } // ICF entry point function. -template void elf::doIcf(SymbolTable *Symtab) { - ICF().run(Symtab); -} +template void elf::doIcf() { ICF().run(); } -template void elf::doIcf(SymbolTable *); -template void elf::doIcf(SymbolTable *); -template void elf::doIcf(SymbolTable *); -template void elf::doIcf(SymbolTable *); +template void elf::doIcf(); +template void elf::doIcf(); +template void elf::doIcf(); +template void elf::doIcf(); diff --git a/lld/ELF/ICF.h b/lld/ELF/ICF.h index 63ad780..502e128c 100644 --- a/lld/ELF/ICF.h +++ b/lld/ELF/ICF.h @@ -12,10 +12,7 @@ namespace lld { namespace elf { - -template class SymbolTable; - -template void doIcf(SymbolTable *); +template void doIcf(); } } diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index b605269..5b20ccc 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -133,7 +133,7 @@ template static bool isReserved(InputSectionBase *Sec) { // This is the main function of the garbage collector. // Starting from GC-root sections, this function visits all reachable // sections to set their "Live" bits. -template void elf::markLive(SymbolTable *Symtab) { +template void elf::markLive() { typedef typename ELFT::uint uintX_t; SmallVector *, 256> Q; @@ -160,20 +160,21 @@ template void elf::markLive(SymbolTable *Symtab) { // Add GC root symbols. if (Config->EntrySym) MarkSymbol(Config->EntrySym->body()); - MarkSymbol(Symtab->find(Config->Init)); - MarkSymbol(Symtab->find(Config->Fini)); + MarkSymbol(Symtab::X->find(Config->Init)); + MarkSymbol(Symtab::X->find(Config->Fini)); for (StringRef S : Config->Undefined) - MarkSymbol(Symtab->find(S)); + MarkSymbol(Symtab::X->find(S)); // Preserve externally-visible symbols if the symbols defined by this // file can interrupt other ELF file's symbols at runtime. - for (const Symbol *S : Symtab->getSymbols()) + for (const Symbol *S : Symtab::X->getSymbols()) if (S->includeInDynsym()) MarkSymbol(S->body()); // Preserve special sections and those which are specified in linker // script KEEP command. - for (const std::unique_ptr> &F : Symtab->getObjectFiles()) + for (const std::unique_ptr> &F : + Symtab::X->getObjectFiles()) for (InputSectionBase *Sec : F->getSections()) if (Sec && Sec != &InputSection::Discarded) { // .eh_frame is always marked as live now, but also it can reference to @@ -190,7 +191,7 @@ template void elf::markLive(SymbolTable *Symtab) { forEachSuccessor(Q.pop_back_val(), Enqueue); } -template void elf::markLive(SymbolTable *); -template void elf::markLive(SymbolTable *); -template void elf::markLive(SymbolTable *); -template void elf::markLive(SymbolTable *); +template void elf::markLive(); +template void elf::markLive(); +template void elf::markLive(); +template void elf::markLive(); diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h index fdd4adf..f60ac89 100644 --- a/lld/ELF/Writer.h +++ b/lld/ELF/Writer.h @@ -17,7 +17,7 @@ template class SymbolTable; template void writeResult(SymbolTable *Symtab); -template void markLive(SymbolTable *Symtab); +template void markLive(); } }