Index: lld/ELF/ICF.cpp =================================================================== --- lld/ELF/ICF.cpp +++ lld/ELF/ICF.cpp @@ -391,13 +391,6 @@ ++Cnt; } -static void print(const Twine &Prefix, InputSection *S) { - if (!Config->PrintIcfSections) - return; - std::string File = S->File ? S->File->getName() : ""; - message(Prefix + " section '" + S->Name + "' from file '" + File + "'"); -} - // The main function of ICF. template void ICF::run() { // Collect sections to merge. @@ -435,9 +428,11 @@ forEachClassRange(0, Sections.size(), [&](size_t Begin, size_t End) { if (End - Begin == 1) return; - print("selected", Sections[Begin]); + if (Config->PrintIcfSections) + message("selected section " + toString(Sections[Begin])); for (size_t I = Begin + 1; I < End; ++I) { - print(" removing identical", Sections[I]); + if (Config->PrintIcfSections) + message(" removing identical section " + toString(Sections[I])); Sections[Begin]->replace(Sections[I]); } }); Index: lld/test/ELF/icf-absolute.s =================================================================== --- lld/test/ELF/icf-absolute.s +++ lld/test/ELF/icf-absolute.s @@ -4,8 +4,8 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-absolute.s -o %t2 # RUN: ld.lld %t %t2 -o %t3 --icf=all --print-icf-sections | FileCheck %s -# CHECK: selected section '.text.f1' from file -# CHECK: removing identical section '.text.f2' from file +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) .globl _start, f1, f2 _start: Index: lld/test/ELF/icf-comdat.s =================================================================== --- lld/test/ELF/icf-comdat.s +++ lld/test/ELF/icf-comdat.s @@ -3,8 +3,8 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | FileCheck %s -# CHECK: selected section '.text.f1' from file [[T:'.*']] -# CHECK: removing identical section '.text.f2' from file [[T]] +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) .globl _start, f1, f2 _start: Index: lld/test/ELF/icf-i386.s =================================================================== --- lld/test/ELF/icf-i386.s +++ lld/test/ELF/icf-i386.s @@ -4,9 +4,9 @@ # RUN: llvm-mc -filetype=obj -triple=i386-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections 2>&1 | FileCheck %s -# CHECK: selected section '.text.f1' from file [[T:'.*']] -# CHECK: removing identical section '.text.f2' from file [[T]] -# CHECK-NOT: removing identical section '.text.f3' from file [[T]] +# CHECK: selected section: {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) +# CHECK-NOT: removing identical section {{.*}}:(.text.f3) .globl _start, f1, f2, f3 _start: Index: lld/test/ELF/icf-merge-sec.s =================================================================== --- lld/test/ELF/icf-merge-sec.s +++ lld/test/ELF/icf-merge-sec.s @@ -4,8 +4,8 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge-sec.s -o %t2 # RUN: ld.lld %t %t2 -o %t3 --icf=all --print-icf-sections | FileCheck %s -# CHECK: selected section '.text.f1' from file -# CHECK: removing identical section '.text.f2' from file +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) .section .rodata.str,"aMS",@progbits,1 .asciz "foo" Index: lld/test/ELF/icf-merge.s =================================================================== --- lld/test/ELF/icf-merge.s +++ lld/test/ELF/icf-merge.s @@ -10,10 +10,10 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge3.s -o %t3 # RUN: ld.lld %t %t3 -o %t3.out --icf=all --print-icf-sections | FileCheck --check-prefix=NOMERGE %s -# CHECK: selected section '.text.f1' from file -# CHECK: removing identical section '.text.f2' from file +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) -# NOMERGE-NOT: selected section '.text.f +# NOMERGE-NOT: selected section {{.*}}:(.text.f) .section .rodata.str,"aMS",@progbits,1 foo: Index: lld/test/ELF/icf1.s =================================================================== --- lld/test/ELF/icf1.s +++ lld/test/ELF/icf1.s @@ -3,8 +3,8 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | FileCheck %s -# CHECK: selected section '.text.f1' from file [[T:'.*']] -# CHECK: removing identical section '.text.f2' from file [[T]] +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) .globl _start, f1, f2 _start: Index: lld/test/ELF/icf2.s =================================================================== --- lld/test/ELF/icf2.s +++ lld/test/ELF/icf2.s @@ -4,8 +4,8 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/icf2.s -o %t2 # RUN: ld.lld %t1 %t2 -o %t --icf=all --print-icf-sections 2>&1 | FileCheck %s -# CHECK: selected section '.text.f1' from file -# CHECK: removing identical section '.text.f2' from file +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) .globl _start, f1, f2 _start: Index: lld/test/ELF/icf7.s =================================================================== --- lld/test/ELF/icf7.s +++ lld/test/ELF/icf7.s @@ -4,8 +4,8 @@ # RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | FileCheck %s # RUN: llvm-objdump -t %t2 | FileCheck -check-prefix=ALIGN %s -# CHECK: selected section '.text.f1' from file [[T:'.*']] -# CHECK: removing identical section '.text.f2' from file [[T]] +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f2) # ALIGN: 0000000000201000 .text 00000000 _start # ALIGN: 0000000000201100 .text 00000000 f1 Index: lld/test/ELF/icf9.s =================================================================== --- lld/test/ELF/icf9.s +++ lld/test/ELF/icf9.s @@ -7,16 +7,16 @@ # SEC: .rodata PROGBITS 0000000000200120 000120 000002 00 A 0 0 1 -# CHECK-NOT: selected section '.rodata.d1' -# CHECK-NOT: selected section '.rodata.d2' +# CHECK-NOT: selected section {{.*}}:(.rodata.d1) +# CHECK-NOT: selected section {{.*}}:(.rodata.d2) # We do merge rodata if passed --icf-data # RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections --ignore-data-address-equality | \ # RUN: FileCheck --check-prefix=DATA %s # RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=DATA-SEC %s -# DATA: selected section '.rodata.d1' from file [[T:'.*']] -# DATA: removing identical section '.rodata.d2' from file [[T]] +# DATA: selected section {{.*}}:(.rodata.d1) +# DATA: removing identical section {{.*}}:(.rodata.d2) # DATA-SEC: .rodata PROGBITS 0000000000200120 000120 000001 00 A 0 0 1 Index: lld/test/ELF/print-icf.s =================================================================== --- lld/test/ELF/print-icf.s +++ lld/test/ELF/print-icf.s @@ -6,13 +6,13 @@ # RUN: ld.lld %t %t1 -o %t2 --icf=all --no-print-icf-sections --print-icf-sections | FileCheck %s # RUN: ld.lld %t %t1 -o %t2 --icf=all --print-icf-sections --no-print-icf-sections | FileCheck -allow-empty -check-prefix=PRINT %s -# CHECK: selected section '.text.f2' from file [[T:'.*']] -# CHECK: removing identical section '.text.f4' from file [[T]] -# CHECK: removing identical section '.text.f7' from file [[T1:'.*']] -# CHECK: selected section '.text.f1' from file [[T]] -# CHECK: removing identical section '.text.f3' from file [[T]] -# CHECK: removing identical section '.text.f5' from file [[T]] -# CHECK: removing identical section '.text.f6' from file [[T1]] +# CHECK: selected section {{.*}}:(.text.f2) +# CHECK: removing identical section {{.*}}:(.text.f4) +# CHECK: removing identical section {{.*}}:(.text.f7) +# CHECK: selected section {{.*}}:(.text.f1) +# CHECK: removing identical section {{.*}}:(.text.f3) +# CHECK: removing identical section {{.*}}:(.text.f5) +# CHECK: removing identical section {{.*}}:(.text.f6) # PRINT-NOT: selected # PRINT-NOT: removing