@@ -97,6 +97,7 @@ using namespace lld::elf;
9797namespace {
9898template <class ELFT > class ICF {
9999public:
100+ ICF (Ctx &ctx) : ctx(ctx) {}
100101 void run ();
101102
102103private:
@@ -120,6 +121,7 @@ template <class ELFT> class ICF {
120121
121122 void forEachClass (llvm::function_ref<void (size_t , size_t )> fn);
122123
124+ Ctx &ctx;
123125 SmallVector<InputSection *, 0 > sections;
124126
125127 // We repeat the main loop while `Repeat` is true.
@@ -457,7 +459,7 @@ static void combineRelocHashes(unsigned cnt, InputSection *isec,
457459 isec->eqClass [(cnt + 1 ) % 2 ] = hash | (1U << 31 );
458460}
459461
460- static void print (const Twine &s) {
462+ static void print (Ctx &ctx, const Twine &s) {
461463 if (ctx.arg .printIcfSections )
462464 message (s);
463465}
@@ -546,9 +548,9 @@ template <class ELFT> void ICF<ELFT>::run() {
546548 forEachClassRange (0 , sections.size (), [&](size_t begin, size_t end) {
547549 if (end - begin == 1 )
548550 return ;
549- print (" selected section " + toString (sections[begin]));
551+ print (ctx, " selected section " + toString (sections[begin]));
550552 for (size_t i = begin + 1 ; i < end; ++i) {
551- print (" removing identical section " + toString (sections[i]));
553+ print (ctx, " removing identical section " + toString (sections[i]));
552554 sections[begin]->replace (sections[i]);
553555
554556 // At this point we know sections merged are fully identical and hence
@@ -586,12 +588,12 @@ template <class ELFT> void ICF<ELFT>::run() {
586588}
587589
588590// ICF entry point function.
589- template <class ELFT > void elf::doIcf () {
591+ template <class ELFT > void elf::doIcf (Ctx &ctx ) {
590592 llvm::TimeTraceScope timeScope (" ICF" );
591- ICF<ELFT>().run ();
593+ ICF<ELFT>(ctx ).run ();
592594}
593595
594- template void elf::doIcf<ELF32LE>();
595- template void elf::doIcf<ELF32BE>();
596- template void elf::doIcf<ELF64LE>();
597- template void elf::doIcf<ELF64BE>();
596+ template void elf::doIcf<ELF32LE>(Ctx & );
597+ template void elf::doIcf<ELF32BE>(Ctx & );
598+ template void elf::doIcf<ELF64LE>(Ctx & );
599+ template void elf::doIcf<ELF64BE>(Ctx & );
0 commit comments