[lld] r325065 - Use toString to stringize sections and files.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 14:56:49 PST 2018


Author: ruiu
Date: Tue Feb 13 14:56:49 2018
New Revision: 325065

URL: http://llvm.org/viewvc/llvm-project?rev=325065&view=rev
Log:
Use toString to stringize sections and files.

Differential Revision: https://reviews.llvm.org/D43251

Modified:
    lld/trunk/ELF/ICF.cpp
    lld/trunk/test/ELF/icf-absolute.s
    lld/trunk/test/ELF/icf-comdat.s
    lld/trunk/test/ELF/icf-i386.s
    lld/trunk/test/ELF/icf-merge-sec.s
    lld/trunk/test/ELF/icf-merge.s
    lld/trunk/test/ELF/icf1.s
    lld/trunk/test/ELF/icf2.s
    lld/trunk/test/ELF/icf7.s
    lld/trunk/test/ELF/icf9.s
    lld/trunk/test/ELF/print-icf.s

Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Tue Feb 13 14:56:49 2018
@@ -391,11 +391,9 @@ void ICF<ELFT>::forEachClass(std::functi
   ++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>::ru
   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]);
     }
   });

Modified: lld/trunk/test/ELF/icf-absolute.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-absolute.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf-absolute.s (original)
+++ lld/trunk/test/ELF/icf-absolute.s Tue Feb 13 14:56:49 2018
@@ -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:

Modified: lld/trunk/test/ELF/icf-comdat.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-comdat.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf-comdat.s (original)
+++ lld/trunk/test/ELF/icf-comdat.s Tue Feb 13 14:56:49 2018
@@ -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:

Modified: lld/trunk/test/ELF/icf-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-i386.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf-i386.s (original)
+++ lld/trunk/test/ELF/icf-i386.s Tue Feb 13 14:56:49 2018
@@ -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:

Modified: lld/trunk/test/ELF/icf-merge-sec.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-merge-sec.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf-merge-sec.s (original)
+++ lld/trunk/test/ELF/icf-merge-sec.s Tue Feb 13 14:56:49 2018
@@ -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", at progbits,1
 .asciz "foo"

Modified: lld/trunk/test/ELF/icf-merge.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-merge.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf-merge.s (original)
+++ lld/trunk/test/ELF/icf-merge.s Tue Feb 13 14:56:49 2018
@@ -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", at progbits,1
 foo:

Modified: lld/trunk/test/ELF/icf1.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf1.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf1.s (original)
+++ lld/trunk/test/ELF/icf1.s Tue Feb 13 14:56:49 2018
@@ -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:

Modified: lld/trunk/test/ELF/icf2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf2.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf2.s (original)
+++ lld/trunk/test/ELF/icf2.s Tue Feb 13 14:56:49 2018
@@ -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:

Modified: lld/trunk/test/ELF/icf7.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf7.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf7.s (original)
+++ lld/trunk/test/ELF/icf7.s Tue Feb 13 14:56:49 2018
@@ -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

Modified: lld/trunk/test/ELF/icf9.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf9.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf9.s (original)
+++ lld/trunk/test/ELF/icf9.s Tue Feb 13 14:56:49 2018
@@ -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
 

Modified: lld/trunk/test/ELF/print-icf.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/print-icf.s?rev=325065&r1=325064&r2=325065&view=diff
==============================================================================
--- lld/trunk/test/ELF/print-icf.s (original)
+++ lld/trunk/test/ELF/print-icf.s Tue Feb 13 14:56:49 2018
@@ -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




More information about the llvm-commits mailing list