[lld] r315425 - Remove a static local varaible.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 20:34:09 PDT 2017


Author: ruiu
Date: Tue Oct 10 20:34:09 2017
New Revision: 315425

URL: http://llvm.org/viewvc/llvm-project?rev=315425&view=rev
Log:
Remove a static local varaible.

We should generally avoid static local variables.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=315425&r1=315424&r2=315425&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Oct 10 20:34:09 2017
@@ -237,17 +237,11 @@ static void sortSections(MutableArrayRef
     std::stable_sort(Vec.begin(), Vec.end(), getComparator(K));
 }
 
-static void sortBySymbolOrder(MutableArrayRef<InputSection *> Vec) {
-  if (Config->SymbolOrderingFile.empty())
-    return;
-  static llvm::DenseMap<SectionBase *, int> Order = buildSectionOrder();
-  sortByOrder(Vec, [&](InputSectionBase *S) { return Order.lookup(S); });
-}
-
 // Compute and remember which sections the InputSectionDescription matches.
 std::vector<InputSection *>
 LinkerScript::computeInputSections(const InputSectionDescription *Cmd) {
   std::vector<InputSection *> Ret;
+  DenseMap<SectionBase *, int> Order = buildSectionOrder();
 
   // Collects all sections that satisfy constraints of Cmd.
   for (const SectionPattern &Pat : Cmd->SectionPatterns) {
@@ -298,7 +292,11 @@ LinkerScript::computeInputSections(const
 
     if (Pat.SortOuter == SortSectionPolicy::Default &&
         Config->SortSection == SortSectionPolicy::Default) {
-      sortBySymbolOrder(Vec);
+
+      // If -symbol-ordering-file was given, sort accordingly.
+      // Usually, Order is empty.
+      if (!Order.empty())
+        sortByOrder(Vec, [&](InputSectionBase *S) { return Order.lookup(S); });
       continue;
     }
 




More information about the llvm-commits mailing list