Simplify handleAnonymousVersion even more.
authorRui Ueyama <ruiu@google.com>
Thu, 17 Nov 2016 03:19:34 +0000 (03:19 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 17 Nov 2016 03:19:34 +0000 (03:19 +0000)
We used to create a vector contantaining all version definitions
with wildcards because doing that was efficient. All patterns were
compiled to a regexp and matched against symbol names. Because
a regexp can be converted to a DFA, matching against union of patterns
is as cheap as matching against one patter.

We are no longer converting them to regexp. Our own glob pattern
handler doesn't do such optimization. Therefore, creating a vector
no longer makes sense.

llvm-svn: 287196

lld/ELF/SymbolTable.cpp

index 949e7fc..268196d 100644 (file)
@@ -634,18 +634,15 @@ SymbolTable<ELFT>::findAllDemangled(const StringMatcher &M) {
 // in the form of { global: foo; bar; local *; }. So, local is default.
 // In this function, we make specified symbols global.
 template <class ELFT> void SymbolTable<ELFT>::handleAnonymousVersion() {
-  std::vector<StringRef> Patterns;
   for (SymbolVersion &Ver : Config->VersionScriptGlobals) {
     if (hasWildcard(Ver.Name)) {
-      Patterns.push_back(Ver.Name);
+      for (SymbolBody *B : findAll(StringMatcher({Ver.Name})))
+        B->symbol()->VersionId = VER_NDX_GLOBAL;
       continue;
     }
     if (SymbolBody *B = find(Ver.Name))
       B->symbol()->VersionId = VER_NDX_GLOBAL;
   }
-  if (!Patterns.empty())
-    for (SymbolBody *B : findAll(StringMatcher(Patterns)))
-      B->symbol()->VersionId = VER_NDX_GLOBAL;
 }
 
 // Set symbol versions to symbols. This function handles patterns