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

Pranav Kant via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 13:00:58 PDT 2025


================
@@ -286,9 +313,14 @@ bool ICF<ELFT>::constantEq(const InputSection *secA, Relocs<RelTy> ra,
     // Relocations referring to InputSections are constant-equal if their
     // section offsets are equal.
     if (isa<InputSection>(da->section)) {
-      if (da->value + addA == db->value + addB)
+      if (da->value + addA == db->value + addB) {
----------------
pranavk wrote:

I think `da->value + addA == db->value + addB` is more readable. I can read it as if the address resolves to the same place, sections are considered same. It also takes care of section folding for more cases. Changing it to `da->value == db->value && addA == addB` would exclude some cases.

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


More information about the llvm-commits mailing list