[lld-macho][nfc] Don't use `stubsHelperIndex` in ICF hash

The existing hashing of stubsHelperIndex has mostly been a no-op* for
some time now (ever since we made ICF run before dylib symbols get their
stubs indices assigned). I guess we could consider hashing the name +
filename of the DylibSymbol instead, but I'm not sure the overhead's
worth it... moreover, LLD/ELF only hashes their Defined symbols as well.

*: Technically it does change the hash value since stubsHelperIndex is
initialized to `UINT32_MAX` by default. But since all stubsHelperIndex
values are the same at when ICF runs, they don't add any useful
information to the hash.
This commit is contained in:
Jez Ng 2022-03-07 03:02:40 -05:00
parent 7028799ca3
commit 112135e774
1 changed files with 3 additions and 4 deletions

View File

@ -278,9 +278,7 @@ void ICF::run() {
uint64_t hash = isec->icfEqClass[icfPass % 2];
for (const Reloc &r : isec->relocs) {
if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
if (auto *dylibSym = dyn_cast<DylibSymbol>(sym))
hash += dylibSym->stubsHelperIndex;
else if (auto *defined = dyn_cast<Defined>(sym)) {
if (auto *defined = dyn_cast<Defined>(sym)) {
if (defined->isec) {
if (auto referentIsec =
dyn_cast<ConcatInputSection>(defined->isec))
@ -291,8 +289,9 @@ void ICF::run() {
} else {
hash += defined->value;
}
} else if (!isa<Undefined>(sym)) // ICF runs before Undefined diags.
} else if (!isa<Undefined>(sym)) { // ICF runs before Undefined diags
llvm_unreachable("foldIdenticalSections symbol kind");
}
}
}
// Set MSB to 1 to avoid collisions with non-hashed classes.