[lld] r287196 - Simplify handleAnonymousVersion even more.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 16 19:19:34 PST 2016


Author: ruiu
Date: Wed Nov 16 21:19:34 2016
New Revision: 287196

URL: http://llvm.org/viewvc/llvm-project?rev=287196&view=rev
Log:
Simplify handleAnonymousVersion even more.

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.

Modified:
    lld/trunk/ELF/SymbolTable.cpp

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=287196&r1=287195&r2=287196&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Nov 16 21:19:34 2016
@@ -634,18 +634,15 @@ SymbolTable<ELFT>::findAllDemangled(cons
 // 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




More information about the llvm-commits mailing list