diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp --- a/lld/MachO/ICF.cpp +++ b/lld/MachO/ICF.cpp @@ -23,6 +23,8 @@ using namespace lld; using namespace lld::macho; +static constexpr bool verboseDiagnostics = false; + class ICF { public: ICF(std::vector &inputs); @@ -47,6 +49,8 @@ unsigned icfPass = 0; std::atomic icfRepeat{false}; + std::atomic equalsConstantCount{0}; + std::atomic equalsVariableCount{0}; }; ICF::ICF(std::vector &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; @@ -159,6 +165,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. @@ -307,6 +315,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) {