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
This commit is contained in:
Rui Ueyama
2018-02-09 17:55:09 +00:00
parent 4031ce15b8
commit 7b90efbece
10 changed files with 17 additions and 22 deletions

View File

@@ -425,17 +425,11 @@ template <class ELFT> void ICF<ELFT>::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() : "<internal>";
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() : "<internal>";
message(Prefix + " section '" + S->Name + "' from file '" + File + "'");
};
// Merge sections by the equivalence class.

View File

@@ -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

View File

@@ -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]]

View File

@@ -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]]

View File

@@ -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

View File

@@ -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

View File

@@ -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]]

View File

@@ -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

View File

@@ -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:'.*']]

View File

@@ -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:'.*']]