[lld] [lld][ELF] Merge equivalent symbols found during ICF (PR #139493)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat May 17 21:59:05 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:
This change was not in #134342 . I have tried to understand why the logic is so complex.
Looks like https://reviews.llvm.org/D34094 , while supporting MergeInputSection, also introduced the untested condition for InputSection
```
if (isa<InputSection>(DA->Section))
return DA->Value + AddA == DB->Value + AddB;
```
I feel that we should switch to the safer `da->value == db->value && addA == addB`, which likely doesn't lose anything (I believe it's difficult for clang emitted code to utilize the relaxed condition.)
https://github.com/llvm/llvm-project/pull/139493
More information about the llvm-commits
mailing list