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

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 10:51:32 PST 2022


Author: Nico Weber
Date: 2022-03-07T13:50:38-05:00
New Revision: d86d431814c836ec5579fc0b981e86c7fb81f2f2

URL: https://github.com/llvm/llvm-project/commit/d86d431814c836ec5579fc0b981e86c7fb81f2f2
DIFF: https://github.com/llvm/llvm-project/commit/d86d431814c836ec5579fc0b981e86c7fb81f2f2.diff

LOG: Revert "[lld-macho][nfc] Don't use `stubsHelperIndex` in ICF hash"

This reverts commit 112135e77444e8c8106efa77416af09f4b9a5012.
Breaks lld/test/MachO/{icf.s,cfstring-dedup.s,invalid/cfstring.s}

Added: 
    

Modified: 
    lld/MachO/ICF.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 0ca815c02b588..efcd3c07ab8ee 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -278,7 +278,9 @@ void ICF::run() {
       uint32_t hash = isec->icfEqClass[icfPass % 2];
       for (const Reloc &r : isec->relocs) {
         if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
-          if (auto *defined = dyn_cast<Defined>(sym)) {
+          if (auto *dylibSym = dyn_cast<DylibSymbol>(sym))
+            hash += dylibSym->stubsHelperIndex;
+          else if (auto *defined = dyn_cast<Defined>(sym)) {
             if (defined->isec) {
               if (auto referentIsec =
                       dyn_cast<ConcatInputSection>(defined->isec))
@@ -289,9 +291,8 @@ 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