From 7b90efbece7770e4717c14b67e6e29fdc67eeb80 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 9 Feb 2018 17:55:09 +0000 Subject: [PATCH] Do not print out removed ICF sections for -verbose. GNU gold doesn't print out ICF sections for -verbose. It only shows them for -print-icf-sections. We printed out them for -verbose because we didn't have -print-icf-sections. Now that we have the option, there's no reason to print out for -verbose. Differential Revision: https://reviews.llvm.org/D43100 llvm-svn: 324755 --- lld/ELF/ICF.cpp | 14 ++++---------- lld/test/ELF/icf-absolute.s | 2 +- lld/test/ELF/icf-comdat.s | 2 +- lld/test/ELF/icf-i386.s | 2 +- lld/test/ELF/icf-merge-sec.s | 2 +- lld/test/ELF/icf-merge.s | 6 +++--- lld/test/ELF/icf1.s | 2 +- lld/test/ELF/icf2.s | 2 +- lld/test/ELF/icf7.s | 2 +- lld/test/ELF/icf9.s | 5 +++-- 10 files changed, 17 insertions(+), 22 deletions(-) diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index 9ea9c48..61b6dd4 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -425,17 +425,11 @@ template void ICF::run() { 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. diff --git a/lld/test/ELF/icf-absolute.s b/lld/test/ELF/icf-absolute.s index 42d2ebe..e2def02 100644 --- a/lld/test/ELF/icf-absolute.s +++ b/lld/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 diff --git a/lld/test/ELF/icf-comdat.s b/lld/test/ELF/icf-comdat.s index 029088c2..a221076 100644 --- a/lld/test/ELF/icf-comdat.s +++ b/lld/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]] diff --git a/lld/test/ELF/icf-i386.s b/lld/test/ELF/icf-i386.s index c00739b..d60004d 100644 --- a/lld/test/ELF/icf-i386.s +++ b/lld/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]] diff --git a/lld/test/ELF/icf-merge-sec.s b/lld/test/ELF/icf-merge-sec.s index 14114f0..92b8bbe 100644 --- a/lld/test/ELF/icf-merge-sec.s +++ b/lld/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 diff --git a/lld/test/ELF/icf-merge.s b/lld/test/ELF/icf-merge.s index e5cb8be..0cb1d81 100644 --- a/lld/test/ELF/icf-merge.s +++ b/lld/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 diff --git a/lld/test/ELF/icf1.s b/lld/test/ELF/icf1.s index fe20703..e6ceda9 100644 --- a/lld/test/ELF/icf1.s +++ b/lld/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]] diff --git a/lld/test/ELF/icf2.s b/lld/test/ELF/icf2.s index 9bebfb8..b98a887 100644 --- a/lld/test/ELF/icf2.s +++ b/lld/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 diff --git a/lld/test/ELF/icf7.s b/lld/test/ELF/icf7.s index 3e78c99..e806cc8 100644 --- a/lld/test/ELF/icf7.s +++ b/lld/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:'.*']] diff --git a/lld/test/ELF/icf9.s b/lld/test/ELF/icf9.s index 652fb36..4d6b8f0 100644 --- a/lld/test/ELF/icf9.s +++ b/lld/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:'.*']] -- 2.7.4