@@ -459,11 +459,6 @@ static void combineRelocHashes(unsigned cnt, InputSection *isec,
459
459
isec->eqClass [(cnt + 1 ) % 2 ] = hash | (1U << 31 );
460
460
}
461
461
462
- static void print (Ctx &ctx, const Twine &s) {
463
- if (ctx.arg .printIcfSections )
464
- Msg (ctx) << s;
465
- }
466
-
467
462
// The main function of ICF.
468
463
template <class ELFT > void ICF<ELFT>::run() {
469
464
// Compute isPreemptible early. We may add more symbols later, so this loop
@@ -544,13 +539,16 @@ template <class ELFT> void ICF<ELFT>::run() {
544
539
545
540
Log (ctx) << " ICF needed " << cnt << " iterations" ;
546
541
542
+ auto print = [&ctx = ctx]() -> ELFSyncStream {
543
+ return {ctx, ctx.arg .printIcfSections ? DiagLevel::Msg : DiagLevel::None};
544
+ };
547
545
// Merge sections by the equivalence class.
548
546
forEachClassRange (0 , sections.size (), [&](size_t begin, size_t end) {
549
547
if (end - begin == 1 )
550
548
return ;
551
- print (ctx, " selected section " + toStr (ctx, sections[begin])) ;
549
+ print () << " selected section " << sections[begin];
552
550
for (size_t i = begin + 1 ; i < end; ++i) {
553
- print (ctx, " removing identical section " + toStr (ctx, sections[i])) ;
551
+ print () << " removing identical section " << sections[i];
554
552
sections[begin]->replace (sections[i]);
555
553
556
554
// At this point we know sections merged are fully identical and hence
0 commit comments