[lld] [lld][macho] Move unwind logic from equalsVariable to equalsConstant (PR #165325)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 10:51:58 PST 2025
================
@@ -217,31 +239,21 @@ bool ICF::equalsVariable(const ConcatInputSection *ia,
}
return isecA->icfEqClass[icfPass % 2] == isecB->icfEqClass[icfPass % 2];
};
- if (!std::equal(ia->relocs.begin(), ia->relocs.end(), ib->relocs.begin(), f))
+ if (!llvm::equal(ia->relocs, ib->relocs, f))
return false;
- // If there are symbols with associated unwind info, check that the unwind
- // info matches. For simplicity, we only handle the case where there are only
- // symbols at offset zero within the section (which is typically the case with
- // .subsections_via_symbols.)
+ // Compare unwind info equivalence classes.
auto hasUnwind = [](Defined *d) { return d->unwindEntry() != nullptr; };
const auto *itA = llvm::find_if(ia->symbols, hasUnwind);
- const auto *itB = llvm::find_if(ib->symbols, hasUnwind);
- if (itA == ia->symbols.end())
- return itB == ib->symbols.end();
- if (itB == ib->symbols.end())
- return false;
- const Defined *da = *itA;
- const Defined *db = *itB;
- if (da->unwindEntry()->icfEqClass[icfPass % 2] !=
- db->unwindEntry()->icfEqClass[icfPass % 2] ||
- da->value != 0 || db->value != 0)
- return false;
- auto isZero = [](Defined *d) { return d->value == 0; };
- return std::find_if_not(std::next(itA), ia->symbols.end(), isZero) ==
- ia->symbols.end() &&
- std::find_if_not(std::next(itB), ib->symbols.end(), isZero) ==
- ib->symbols.end();
+ if (itA != ia->symbols.end()) {
----------------
ellishg wrote:
Minor nit to reduce indentation
```suggestion
if (itA == ia->symbols.end())
return true;
```
Then I think we can end with
```
return da->unwindEntry()->icfEqClass[icfPass % 2] == db->unwindEntry()->icfEqClass[icfPass % 2];
```
https://github.com/llvm/llvm-project/pull/165325
More information about the llvm-commits
mailing list