[lld] [lld] Merge equivalent symbols found during ICF (PR #134342)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 15 00:19:43 PDT 2025


================
@@ -333,6 +333,28 @@ bool ICF<ELFT>::equalsConstant(const InputSection *a, const InputSection *b) {
              : constantEq(a, ra.relas, b, rb.relas);
 }
 
+template <class RelTy>
+static SmallVector<Symbol *> getReloc(const InputSection *sec,
----------------
MaskRay wrote:

> > Around line 581, symbolMap.insert(std::make_pair(replacedSyms[i], syms[i])); inside forEachClassRange (parallel) looks like unsafe concurrent updates of the unordered map.
> 
> `forEachClassRange` is not parallel as far as I can see. `forEachClass` is parallel which is why I couldn't do this inside of `variablesEq`. So there should be no concurrent update to the map.

OK, I see. I am concerned that this introduces an implicit restriction on making the loop parallel, but I don't have good alternative suggestion yet.

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


More information about the llvm-commits mailing list