Do not put internal symbols into the symbol table. This shrinks the symbol

table for archives in common cases, and prevents trying to resolve a
external reference with an internal reference.  This shrinks the libpython.a
symbol table from 126302 to 19770 bytes.

llvm-svn: 20151
This commit is contained in:
Chris Lattner 2005-02-13 17:42:11 +00:00
parent 38a3ba0234
commit 1b9f9c5f67
1 changed files with 10 additions and 20 deletions

View File

@ -328,28 +328,18 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
}
}
namespace {
void getSymbols(Module*M, std::vector<std::string>& symbols) {
static void getSymbols(Module*M, std::vector<std::string>& symbols) {
// Loop over global variables
for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) {
if (GI->hasInitializer()) {
std::string name ( GI->getName() );
if (!name.empty()) {
symbols.push_back(name);
}
}
}
for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI)
if (GI->hasInitializer() && !GI->hasInternalLinkage())
if (!GI->getName().empty())
symbols.push_back(GI->getName());
//Loop over functions
for (Module::iterator FI = M->begin(), FE=M->end(); FI != FE; ++FI) {
if (!FI->isExternal()) {
std::string name ( FI->getName() );
if (!name.empty()) {
symbols.push_back(name);
}
}
}
}
// Loop over functions.
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI)
if (!FI->isExternal() && !FI->hasInternalLinkage())
if (!FI->getName().empty())
symbols.push_back(FI->getName());
}
// Get just the externally visible defined symbols from the bytecode