[llvm] [llvm-nm] Improve performance while faking symbols from function starts (PR #162755)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 9 18:08:06 PDT 2025


================
@@ -1615,12 +1616,11 @@ static void dumpSymbolsFromDLInfoMachO(MachOObjectFile &MachO,
     }
     // See if these addresses are already in the symbol table.
     unsigned FunctionStartsAdded = 0;
+    SmallSet<uint64_t, 32> SymbolAddresses;
+    for (unsigned J = 0; J < SymbolList.size(); ++J)
+      SymbolAddresses.insert(SymbolList[J].Address);
     for (uint64_t f = 0; f < FoundFns.size(); f++) {
-      bool found = false;
-      for (unsigned J = 0; J < SymbolList.size() && !found; ++J) {
-        if (SymbolList[J].Address == FoundFns[f] + BaseSegmentAddress)
-          found = true;
-      }
+      bool found = SymbolAddresses.contains(FoundFns[f] + BaseSegmentAddress);
       // See this address is not already in the symbol table fake up an
----------------
ellishg wrote:

Not your change, but I think we can improve this comment's wording

```diff
-      // See this address is not already in the symbol table fake up an
+      // See if this address is already in the symbol table, otherwise fake up an
```

https://github.com/llvm/llvm-project/pull/162755


More information about the llvm-commits mailing list