mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-01 06:46:34 +00:00
Use toString to stringize sections and files.
Differential Revision: https://reviews.llvm.org/D43251 llvm-svn: 325065
This commit is contained in:
parent
7d67dd118a
commit
2d9e7a8956
@ -391,11 +391,9 @@ void ICF<ELFT>::forEachClass(std::function<void(size_t, size_t)> Fn) {
|
||||
++Cnt;
|
||||
}
|
||||
|
||||
static void print(const Twine &Prefix, InputSection *S) {
|
||||
if (!Config->PrintIcfSections)
|
||||
return;
|
||||
std::string File = S->File ? S->File->getName() : "<internal>";
|
||||
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 @@ template <class ELFT> void ICF<ELFT>::run() {
|
||||
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]);
|
||||
}
|
||||
});
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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"
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user