Index: ELF/ICF.cpp =================================================================== --- ELF/ICF.cpp +++ ELF/ICF.cpp @@ -425,17 +425,11 @@ log("ICF needed " + Twine(Cnt) + " iterations"); auto Print = [&](const Twine &Prefix, size_t I) { - if (!Config->PrintIcfSections && !errorHandler().Verbose) + if (!Config->PrintIcfSections) return; - std::string Filename = - Sections[I]->File ? Sections[I]->File->getName() : ""; - std::string S = (Prefix + " section '" + Sections[I]->Name + - "' from file '" + Filename + "'") - .str(); - if (Config->PrintIcfSections) - message(S); - else - log(S); + InputSection *S = Sections[I]; + std::string File = S->File ? S->File->getName() : ""; + message(Prefix + " section '" + S->Name + "' from file '" + File + "'"); }; // Merge sections by the equivalence class. Index: test/ELF/icf-absolute.s =================================================================== --- test/ELF/icf-absolute.s +++ test/ELF/icf-absolute.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # 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 --verbose 2>&1 | FileCheck %s +# 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 Index: test/ELF/icf-comdat.s =================================================================== --- test/ELF/icf-comdat.s +++ test/ELF/icf-comdat.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s +# 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]] Index: test/ELF/icf-i386.s =================================================================== --- test/ELF/icf-i386.s +++ test/ELF/icf-i386.s @@ -2,7 +2,7 @@ # This test is to make sure that we can handle implicit addends properly. # RUN: llvm-mc -filetype=obj -triple=i386-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s +# 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]] Index: test/ELF/icf-merge-sec.s =================================================================== --- test/ELF/icf-merge-sec.s +++ test/ELF/icf-merge-sec.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # 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 --verbose 2>&1 | FileCheck %s +# 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 Index: test/ELF/icf-merge.s =================================================================== --- test/ELF/icf-merge.s +++ test/ELF/icf-merge.s @@ -2,13 +2,13 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge.s -o %t1 -# RUN: ld.lld %t %t1 -o %t1.out --icf=all --verbose 2>&1 | FileCheck %s +# RUN: ld.lld %t %t1 -o %t1.out --icf=all --print-icf-sections | FileCheck %s # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge2.s -o %t2 -# RUN: ld.lld %t %t2 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s +# RUN: ld.lld %t %t2 -o %t3.out --icf=all --print-icf-sections | FileCheck --check-prefix=NOMERGE %s # 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 --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s +# 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 Index: test/ELF/icf1.s =================================================================== --- test/ELF/icf1.s +++ test/ELF/icf1.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s +# 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]] Index: test/ELF/icf2.s =================================================================== --- test/ELF/icf2.s +++ test/ELF/icf2.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 # 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 --verbose 2>&1 | FileCheck %s +# 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 Index: test/ELF/icf7.s =================================================================== --- test/ELF/icf7.s +++ test/ELF/icf7.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s +# 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:'.*']] Index: test/ELF/icf9.s =================================================================== --- test/ELF/icf9.s +++ test/ELF/icf9.s @@ -2,7 +2,7 @@ ### Make sure that we do not merge data. # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose --print-icf-sections 2>&1 | FileCheck %s # RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=SEC %s # SEC: .rodata PROGBITS 0000000000200120 000120 000002 00 A 0 0 1 @@ -11,7 +11,8 @@ # CHECK-NOT: selected section '.rodata.d2' # We do merge rodata if passed --icf-data -# RUN: ld.lld %t -o %t2 --icf=all --verbose --ignore-data-address-equality 2>&1 | FileCheck --check-prefix=DATA %s +# 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:'.*']]