Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit cf894f6

Browse files
committed
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 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@324755 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent dc7a9f3 commit cf894f6

File tree

10 files changed

+17
-22
lines changed

10 files changed

+17
-22
lines changed

ELF/ICF.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,11 @@ template <class ELFT> void ICF<ELFT>::run() {
425425
log("ICF needed " + Twine(Cnt) + " iterations");
426426

427427
auto Print = [&](const Twine &Prefix, size_t I) {
428-
if (!Config->PrintIcfSections && !errorHandler().Verbose)
428+
if (!Config->PrintIcfSections)
429429
return;
430-
std::string Filename =
431-
Sections[I]->File ? Sections[I]->File->getName() : "<internal>";
432-
std::string S = (Prefix + " section '" + Sections[I]->Name +
433-
"' from file '" + Filename + "'")
434-
.str();
435-
if (Config->PrintIcfSections)
436-
message(S);
437-
else
438-
log(S);
430+
InputSection *S = Sections[I];
431+
std::string File = S->File ? S->File->getName() : "<internal>";
432+
message(Prefix + " section '" + S->Name + "' from file '" + File + "'");
439433
};
440434

441435
// Merge sections by the equivalence class.

test/ELF/icf-absolute.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-absolute.s -o %t2
5-
# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s
5+
# RUN: ld.lld %t %t2 -o %t3 --icf=all --print-icf-sections | FileCheck %s
66

77
# CHECK: selected section '.text.f1' from file
88
# CHECK: removing identical section '.text.f2' from file

test/ELF/icf-comdat.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# REQUIRES: x86
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4-
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
4+
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | FileCheck %s
55

66
# CHECK: selected section '.text.f1' from file [[T:'.*']]
77
# CHECK: removing identical section '.text.f2' from file [[T]]

test/ELF/icf-i386.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This test is to make sure that we can handle implicit addends properly.
33

44
# RUN: llvm-mc -filetype=obj -triple=i386-unknown-linux %s -o %t
5-
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
5+
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections 2>&1 | FileCheck %s
66

77
# CHECK: selected section '.text.f1' from file [[T:'.*']]
88
# CHECK: removing identical section '.text.f2' from file [[T]]

test/ELF/icf-merge-sec.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge-sec.s -o %t2
5-
# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s
5+
# RUN: ld.lld %t %t2 -o %t3 --icf=all --print-icf-sections | FileCheck %s
66

77
# CHECK: selected section '.text.f1' from file
88
# CHECK: removing identical section '.text.f2' from file

test/ELF/icf-merge.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge.s -o %t1
5-
# RUN: ld.lld %t %t1 -o %t1.out --icf=all --verbose 2>&1 | FileCheck %s
5+
# RUN: ld.lld %t %t1 -o %t1.out --icf=all --print-icf-sections | FileCheck %s
66

77
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge2.s -o %t2
8-
# RUN: ld.lld %t %t2 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s
8+
# RUN: ld.lld %t %t2 -o %t3.out --icf=all --print-icf-sections | FileCheck --check-prefix=NOMERGE %s
99

1010
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge3.s -o %t3
11-
# RUN: ld.lld %t %t3 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s
11+
# RUN: ld.lld %t %t3 -o %t3.out --icf=all --print-icf-sections | FileCheck --check-prefix=NOMERGE %s
1212

1313
# CHECK: selected section '.text.f1' from file
1414
# CHECK: removing identical section '.text.f2' from file

test/ELF/icf1.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# REQUIRES: x86
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4-
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
4+
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | FileCheck %s
55

66
# CHECK: selected section '.text.f1' from file [[T:'.*']]
77
# CHECK: removing identical section '.text.f2' from file [[T]]

test/ELF/icf2.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/icf2.s -o %t2
5-
# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose 2>&1 | FileCheck %s
5+
# RUN: ld.lld %t1 %t2 -o %t --icf=all --print-icf-sections 2>&1 | FileCheck %s
66

77
# CHECK: selected section '.text.f1' from file
88
# CHECK: removing identical section '.text.f2' from file

test/ELF/icf7.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# REQUIRES: x86
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4-
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
4+
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | FileCheck %s
55
# RUN: llvm-objdump -t %t2 | FileCheck -check-prefix=ALIGN %s
66

77
# CHECK: selected section '.text.f1' from file [[T:'.*']]

test/ELF/icf9.s

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Make sure that we do not merge data.
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
5-
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
5+
# RUN: ld.lld %t -o %t2 --icf=all --verbose --print-icf-sections 2>&1 | FileCheck %s
66
# RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=SEC %s
77

88
# SEC: .rodata PROGBITS 0000000000200120 000120 000002 00 A 0 0 1
@@ -11,7 +11,8 @@
1111
# CHECK-NOT: selected section '.rodata.d2'
1212

1313
# We do merge rodata if passed --icf-data
14-
# RUN: ld.lld %t -o %t2 --icf=all --verbose --ignore-data-address-equality 2>&1 | FileCheck --check-prefix=DATA %s
14+
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections --ignore-data-address-equality | \
15+
# RUN: FileCheck --check-prefix=DATA %s
1516
# RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=DATA-SEC %s
1617

1718
# DATA: selected section '.rodata.d1' from file [[T:'.*']]

0 commit comments

Comments
 (0)