[PATCH] D29021: [ELF] - Stop handling local symbols in a special way.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 09:50:01 PST 2017


ruiu added inline comments.


================
Comment at: lld/trunk/ELF/SyntheticSections.cpp:1073-1077
+    std::stable_sort(GlobBegin, Symbols.end(), [](const SymbolTableEntry &L,
+                                                  const SymbolTableEntry &R) {
+      return L.Symbol->symbol()->computeBinding() == STB_LOCAL &&
+             R.Symbol->symbol()->computeBinding() != STB_LOCAL;
+    });
----------------
You can use stable_partition here.


================
Comment at: lld/trunk/ELF/SyntheticSections.cpp:1104-1109
+template <class ELFT>
+size_t SymbolTableSection<ELFT>::getSymbolIndex(SymbolBody *Body) {
+  auto I = llvm::find_if(
+      Symbols, [&](const SymbolTableEntry &E) { return E.Symbol == Body; });
+  return I - Symbols.begin() + 1;
+}
----------------
This is a linear scan, so this makes the algorithm O(n^2), right? Did you verify that that is not a problem? Anyway, it needs comment as always -- you should explain that this is O(n^2) but in practice it is not an issue because blah blah (if that's the case.)


Repository:
  rL LLVM

https://reviews.llvm.org/D29021





More information about the llvm-commits mailing list