[lld] r268286 - Do not pass Symtab to markLive/doICF since Symtab is globally accessible.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 12:30:42 PDT 2016
Author: ruiu
Date: Mon May 2 14:30:42 2016
New Revision: 268286
URL: http://llvm.org/viewvc/llvm-project?rev=268286&view=rev
Log:
Do not pass Symtab to markLive/doICF since Symtab is globally accessible.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/ICF.cpp
lld/trunk/ELF/ICF.h
lld/trunk/ELF/MarkLive.cpp
lld/trunk/ELF/Writer.h
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=268286&r1=268285&r2=268286&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon May 2 14:30:42 2016
@@ -489,8 +489,8 @@ template <class ELFT> void LinkerDriver:
// Write the result to the file.
if (Config->GcSections)
- markLive<ELFT>(&Symtab);
+ markLive<ELFT>();
if (Config->ICF)
- doIcf<ELFT>(&Symtab);
+ doIcf<ELFT>();
writeResult<ELFT>(&Symtab);
}
Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=268286&r1=268285&r2=268286&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Mon May 2 14:30:42 2016
@@ -83,7 +83,7 @@ template <class ELFT> class ICF {
const InputSection<ELFT> *)>;
public:
- void run(SymbolTable<ELFT> *Symtab);
+ void run();
private:
uint64_t NextId = 1;
@@ -92,7 +92,7 @@ private:
static uint64_t relSize(InputSection<ELFT> *S);
static uint64_t getHash(InputSection<ELFT> *S);
static bool isEligible(InputSectionBase<ELFT> *Sec);
- static std::vector<InputSection<ELFT> *> getSections(SymbolTable<ELFT> *S);
+ static std::vector<InputSection<ELFT> *> getSections();
void segregate(InputSection<ELFT> **Begin, InputSection<ELFT> **End,
Comparator Eq);
@@ -146,10 +146,10 @@ template <class ELFT> bool ICF<ELFT>::is
}
template <class ELFT>
-std::vector<InputSection<ELFT> *>
-ICF<ELFT>::getSections(SymbolTable<ELFT> *Symtab) {
+std::vector<InputSection<ELFT> *> ICF<ELFT>::getSections() {
std::vector<InputSection<ELFT> *> V;
- for (const std::unique_ptr<ObjectFile<ELFT>> &F : Symtab->getObjectFiles())
+ for (const std::unique_ptr<ObjectFile<ELFT>> &F :
+ Symtab<ELFT>::X->getObjectFiles())
for (InputSectionBase<ELFT> *S : F->getSections())
if (isEligible(S))
V.push_back(cast<InputSection<ELFT>>(S));
@@ -289,11 +289,11 @@ bool ICF<ELFT>::equalsVariable(const Inp
}
// The main function of ICF.
-template <class ELFT> void ICF<ELFT>::run(SymbolTable<ELFT> *Symtab) {
+template <class ELFT> void ICF<ELFT>::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<InputSection<ELFT> *> V = getSections(Symtab);
+ std::vector<InputSection<ELFT> *> V = getSections();
for (InputSection<ELFT> *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 <class ELFT> void ICF<ELFT>::ru
}
// ICF entry point function.
-template <class ELFT> void elf::doIcf(SymbolTable<ELFT> *Symtab) {
- ICF<ELFT>().run(Symtab);
-}
+template <class ELFT> void elf::doIcf() { ICF<ELFT>().run(); }
-template void elf::doIcf(SymbolTable<ELF32LE> *);
-template void elf::doIcf(SymbolTable<ELF32BE> *);
-template void elf::doIcf(SymbolTable<ELF64LE> *);
-template void elf::doIcf(SymbolTable<ELF64BE> *);
+template void elf::doIcf<ELF32LE>();
+template void elf::doIcf<ELF32BE>();
+template void elf::doIcf<ELF64LE>();
+template void elf::doIcf<ELF64BE>();
Modified: lld/trunk/ELF/ICF.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.h?rev=268286&r1=268285&r2=268286&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.h (original)
+++ lld/trunk/ELF/ICF.h Mon May 2 14:30:42 2016
@@ -12,10 +12,7 @@
namespace lld {
namespace elf {
-
-template <class ELFT> class SymbolTable;
-
-template <class ELFT> void doIcf(SymbolTable<ELFT> *);
+template <class ELFT> void doIcf();
}
}
Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=268286&r1=268285&r2=268286&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Mon May 2 14:30:42 2016
@@ -133,7 +133,7 @@ template <class ELFT> static bool isRese
// 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 <class ELFT> void elf::markLive(SymbolTable<ELFT> *Symtab) {
+template <class ELFT> void elf::markLive() {
typedef typename ELFT::uint uintX_t;
SmallVector<InputSection<ELFT> *, 256> Q;
@@ -160,20 +160,21 @@ template <class ELFT> void elf::markLive
// Add GC root symbols.
if (Config->EntrySym)
MarkSymbol(Config->EntrySym->body());
- MarkSymbol(Symtab->find(Config->Init));
- MarkSymbol(Symtab->find(Config->Fini));
+ MarkSymbol(Symtab<ELFT>::X->find(Config->Init));
+ MarkSymbol(Symtab<ELFT>::X->find(Config->Fini));
for (StringRef S : Config->Undefined)
- MarkSymbol(Symtab->find(S));
+ MarkSymbol(Symtab<ELFT>::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<ELFT>::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<ObjectFile<ELFT>> &F : Symtab->getObjectFiles())
+ for (const std::unique_ptr<ObjectFile<ELFT>> &F :
+ Symtab<ELFT>::X->getObjectFiles())
for (InputSectionBase<ELFT> *Sec : F->getSections())
if (Sec && Sec != &InputSection<ELFT>::Discarded) {
// .eh_frame is always marked as live now, but also it can reference to
@@ -190,7 +191,7 @@ template <class ELFT> void elf::markLive
forEachSuccessor<ELFT>(Q.pop_back_val(), Enqueue);
}
-template void elf::markLive<ELF32LE>(SymbolTable<ELF32LE> *);
-template void elf::markLive<ELF32BE>(SymbolTable<ELF32BE> *);
-template void elf::markLive<ELF64LE>(SymbolTable<ELF64LE> *);
-template void elf::markLive<ELF64BE>(SymbolTable<ELF64BE> *);
+template void elf::markLive<ELF32LE>();
+template void elf::markLive<ELF32BE>();
+template void elf::markLive<ELF64LE>();
+template void elf::markLive<ELF64BE>();
Modified: lld/trunk/ELF/Writer.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=268286&r1=268285&r2=268286&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.h (original)
+++ lld/trunk/ELF/Writer.h Mon May 2 14:30:42 2016
@@ -17,7 +17,7 @@ template <class ELFT> class SymbolTable;
template <class ELFT> void writeResult(SymbolTable<ELFT> *Symtab);
-template <class ELFT> void markLive(SymbolTable<ELFT> *Symtab);
+template <class ELFT> void markLive();
}
}
More information about the llvm-commits
mailing list