[PATCH] D121051: [lld-macho][nfc] Track # of ICF calls to `equals*` methods
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 5 09:50:58 PST 2022
int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added projects: lld-macho, All.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is debug code that is disabled by default. It'll provide a easy way
to figure out the impact (if any) of tweaking ICF's hashing algorithm
(since a poor quality hash will result in many more `equals*` calls).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121051
Files:
lld/MachO/ICF.cpp
Index: lld/MachO/ICF.cpp
===================================================================
--- lld/MachO/ICF.cpp
+++ lld/MachO/ICF.cpp
@@ -23,6 +23,8 @@
using namespace lld;
using namespace lld::macho;
+constexpr bool verboseDiagnostics = false;
+
class ICF {
public:
ICF(std::vector<ConcatInputSection *> &inputs);
@@ -47,6 +49,8 @@
unsigned icfPass = 0;
std::atomic<bool> icfRepeat{false};
+ std::atomic<uint64_t> equalsConstantCount{0};
+ std::atomic<uint64_t> equalsVariableCount{0};
};
ICF::ICF(std::vector<ConcatInputSection *> &inputs) {
@@ -87,6 +91,8 @@
// except references to other ConcatInputSections.
bool ICF::equalsConstant(const ConcatInputSection *ia,
const ConcatInputSection *ib) {
+ if (verboseDiagnostics)
+ ++equalsConstantCount;
// We can only fold within the same OutputSection.
if (ia->parent != ib->parent)
return false;
@@ -157,6 +163,8 @@
// handled by equalsConstant().
bool ICF::equalsVariable(const ConcatInputSection *ia,
const ConcatInputSection *ib) {
+ if (verboseDiagnostics)
+ ++equalsVariableCount;
assert(ia->relocs.size() == ib->relocs.size());
auto f = [this](const Reloc &ra, const Reloc &rb) {
// We already filtered out mismatching values/addends in equalsConstant.
@@ -305,6 +313,10 @@
});
} while (icfRepeat);
log("ICF needed " + Twine(icfPass) + " iterations");
+ if (verboseDiagnostics) {
+ log("equalsConstant() called " + Twine(equalsConstantCount) + " times");
+ log("equalsVariable() called " + Twine(equalsVariableCount) + " times");
+ }
// Fold sections within equivalence classes
forEachClass([&](size_t begin, size_t end) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121051.413223.patch
Type: text/x-patch
Size: 1718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220305/ad80d9b8/attachment.bin>
More information about the llvm-commits
mailing list