Index: ELF/ICF.cpp =================================================================== --- ELF/ICF.cpp +++ ELF/ICF.cpp @@ -391,11 +391,9 @@ ++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 + "'"); +static void print(const Twine &S) { + if (Config->PrintIcfSections) + message(S); } // The main function of ICF. @@ -435,9 +433,9 @@ forEachClassRange(0, Sections.size(), [&](size_t Begin, size_t End) { if (End - Begin == 1) return; - print("selected", Sections[Begin]); + print("selected section " + toString(Sections[Begin])); for (size_t I = Begin + 1; I < End; ++I) { - print(" removing identical", Sections[I]); + print(" removing identical section " + toString(Sections[I])); Sections[Begin]->replace(Sections[I]); } }); Index: test/ELF/icf-absolute.s =================================================================== --- test/ELF/icf-absolute.s +++ 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: test/ELF/icf-comdat.s =================================================================== --- test/ELF/icf-comdat.s +++ 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: test/ELF/icf-i386.s =================================================================== --- test/ELF/icf-i386.s +++ 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: test/ELF/icf-merge-sec.s =================================================================== --- test/ELF/icf-merge-sec.s +++ 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: test/ELF/icf-merge.s =================================================================== --- test/ELF/icf-merge.s +++ 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: test/ELF/icf1.s =================================================================== --- test/ELF/icf1.s +++ 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: test/ELF/icf2.s =================================================================== --- test/ELF/icf2.s +++ 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: test/ELF/icf7.s =================================================================== --- test/ELF/icf7.s +++ 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: test/ELF/icf9.s =================================================================== --- test/ELF/icf9.s +++ 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: test/ELF/print-icf.s =================================================================== --- test/ELF/print-icf.s +++ 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