Do not put internal symbols into the symbol table. This shrinks the symbol
authorChris Lattner <sabre@nondot.org>
Sun, 13 Feb 2005 17:42:11 +0000 (17:42 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 13 Feb 2005 17:42:11 +0000 (17:42 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20151 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/ReaderWrappers.cpp

index 9b8491327fa41a1287798c3854fa4c2793b387ce..ce54b7a4e256e491642eab11517bf392a1a0f5f8 100644 (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);
-      }
-    }
-  }
-
-  //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);
-      }
-    }
-  }
-}
+  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() && !FI->hasInternalLinkage())
+      if (!FI->getName().empty())
+        symbols.push_back(FI->getName());
 }
 
 // Get just the externally visible defined symbols from the bytecode