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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 19:25:22 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) {
----------------
MaskRay wrote:

> Changing it to `da->value == db->value && addA == addB` would exclude some cases.

The excluded cases are likely negligible. This condition is for InputSection (non merge string), where symbols defined not at offset 0 in -ffunction-sections -fdata-sections code are extremely rare. I don't know a case LLVM codegen would do this. 

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


More information about the llvm-commits mailing list