[PATCH] D88830: [LLD][ELF] Improve ICF for relocations to sections via "aliases"

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 18:04:24 PDT 2020


MaskRay added a comment.

The description can be shortened a bit. The important part is that `variableEq` returns false if two relocations reference a pair of aliased symbols in an ineligible section.



================
Comment at: lld/ELF/ICF.cpp:227
     for (size_t i = begin; i < mid; ++i)
-      sections[i]->eqClass[next] = mid;
+      sections[i]->eqClass[next] = eqClass;
 
----------------
Here this actually computes non-hash IDs. Clearing the MSB (the original code) is better.


================
Comment at: lld/ELF/ICF.cpp:358
 
     // Ineligible sections are in the special equivalence class 0.
     // They can never be the same in terms of the equivalence class.
----------------
This comment is stale. This code may be deletable.


================
Comment at: lld/ELF/ICF.cpp:476
     part.ehFrame->iterateFDEWithLSDA<ELFT>(
-        [&](InputSection &s) { s.eqClass[0] = ++uniqueId; });
+        [&](InputSection &s) { s.eqClass[0] = s.eqClass[1] = ++uniqueId; });
 
----------------
Same comment: this is unneeded. combineRelocHashes updates eqClass[1]


================
Comment at: lld/ELF/ICF.cpp:485
+      else
+        s->eqClass[0] = s->eqClass[1] = ++uniqueId;
+    }
----------------
This needs a comment. Ineligible sections are assigned unique IDs so that two sections referencing different ineligible sections can be separated.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88830/new/

https://reviews.llvm.org/D88830



More information about the llvm-commits mailing list