[lld] 112135e - [lld-macho][nfc] Don't use `stubsHelperIndex` in ICF hash
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 09:36:48 PST 2022
Author: Jez Ng
Date: 2022-03-07T12:36:28-05:00
New Revision: 112135e77444e8c8106efa77416af09f4b9a5012
URL: https://github.com/llvm/llvm-project/commit/112135e77444e8c8106efa77416af09f4b9a5012
DIFF: https://github.com/llvm/llvm-project/commit/112135e77444e8c8106efa77416af09f4b9a5012.diff
LOG: [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.
Added:
Modified:
lld/MachO/ICF.cpp
Removed:
################################################################################
diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 885cb827c7940..11c48f292c6df 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -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.
More information about the llvm-commits
mailing list