Lines Matching defs:ICF
1 //===- ICF.cpp ------------------------------------------------------------===//
9 #include "ICF.h"
31 class ICF {
33 ICF(std::vector<ConcatInputSection *> &inputs);
36 using EqualsFn = bool (ICF::*)(const ConcatInputSection *,
50 // ICF needs a copy of the inputs vector because its equivalence-class
60 ICF::ICF(std::vector<ConcatInputSection *> &inputs) {
64 // ICF = Identical Code Folding
75 // __TEXT,__unwind_info). Note that we don't yet run ICF on __TEXT,__const,
79 // thus ineligible for ICF.
86 // data, none of its sections are eligible for ICF.
88 // Please see the large block comment in lld/ELF/ICF.cpp for an explanation
96 bool ICF::equalsConstant(const ConcatInputSection *ia,
130 // ICF runs before Undefineds are treated (and potentially converted into
188 bool ICF::equalsVariable(const ConcatInputSection *ia,
248 size_t ICF::findBoundary(size_t begin, size_t end) {
257 void ICF::forEachClassRange(size_t begin, size_t end,
272 void ICF::applySafeThunksToRange(size_t begin, size_t end) {
279 // When creating a unique ICF thunk, use the first section as the section that
312 void ICF::forEachClass(llvm::function_ref<void(size_t, size_t)> func) {
340 void ICF::run() {
359 // ICF runs before Undefined diags
380 segregate(begin, end, &ICF::equalsConstant);
387 segregate(begin, end, &ICF::equalsVariable);
390 log("ICF needed " + Twine(icfPass) + " iterations");
410 // For ICF level safe_thunks, replace keepUnique function bodies with
411 // thunks. For all other ICF levles, directly merge the functions.
431 void ICF::segregate(size_t begin, size_t end, EqualsFn equals) {
489 "thunk-folded ICF symbol expected to be on a ConcatInputSection");
509 llvm_unreachable("could not find body symbol for ICF-generated thunk");
513 // The ICF equivalence-class segregation algorithm relies on pre-computed
520 // If an InputSection is ineligible for ICF, we give it a unique ID to force
526 // ICF::segregate()
560 // Some sections have embedded addends that foil ICF's hashing / equality
561 // checks. (We can ignore embedded addends when doing ICF because the same
583 // with the small-integer unique IDs for ICF-ineligible sections
588 ICF(foldable).run();