[PATCH] D43420: Use toString to print out garbage-collected sections.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 16:09:52 PST 2018
LGTM
Thanks,
Rafael
Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:
> ruiu created this revision.
> ruiu added reviewers: sbc100, rafael.
> Herald added subscribers: arichardson, emaste.
>
> Currently, archive file name is missing in this message. In general,
> we should avoid constructing strings in an ad-hoc manner and instead
> use toString() to get consistent output strings.
>
>
> https://reviews.llvm.org/D43420
>
> Files:
> lld/ELF/MarkLive.cpp
> lld/test/ELF/comdat.s
> lld/test/ELF/emit-relocs-gc.s
> lld/test/ELF/gc-sections-print.s
> lld/test/ELF/linkerscript/discard-print-gc.s
>
>
> Index: lld/test/ELF/linkerscript/discard-print-gc.s
> ===================================================================
> --- lld/test/ELF/linkerscript/discard-print-gc.s
> +++ lld/test/ELF/linkerscript/discard-print-gc.s
> @@ -15,5 +15,5 @@
> .section .foo,"a"
> .quad 0
>
> -# CHECK: removing unused section from '.foo'
> -# QUIET-NOT: removing unused section from '.foo'
> +# CHECK: removing unused section {{.*}}:(.foo)
> +# QUIET-NOT: removing unused section {{.*}}:(.foo)
> Index: lld/test/ELF/gc-sections-print.s
> ===================================================================
> --- lld/test/ELF/gc-sections-print.s
> +++ lld/test/ELF/gc-sections-print.s
> @@ -2,8 +2,8 @@
> # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> # RUN: ld.lld %t --gc-sections --print-gc-sections -o %t2 2>&1 | FileCheck -check-prefix=PRINT %s
>
> -# PRINT: removing unused section from '.text.x' in file
> -# PRINT-NEXT: removing unused section from '.text.y' in file
> +# PRINT: removing unused section {{.*}}:(.text.x)
> +# PRINT-NEXT: removing unused section {{.*}}:(.text.y)
>
> # RUN: ld.lld %t --gc-sections --print-gc-sections --no-print-gc-sections -o %t2 >& %t.log
> # RUN: echo >> %t.log
> Index: lld/test/ELF/emit-relocs-gc.s
> ===================================================================
> --- lld/test/ELF/emit-relocs-gc.s
> +++ lld/test/ELF/emit-relocs-gc.s
> @@ -11,8 +11,8 @@
> ## .rela.text because we keep .text.
> # RUN: ld.lld --gc-sections --emit-relocs --print-gc-sections %t.o -o %t \
> # RUN: | FileCheck --check-prefix=MSG %s
> -# MSG: removing unused section from '.bar' in file
> -# MSG: removing unused section from '.rela.bar' in file
> +# MSG: removing unused section {{.*}}.o:(.bar)
> +# MSG: removing unused section {{.*}}.o:(.rela.bar)
> # RUN: llvm-objdump %t -section-headers | FileCheck %s --check-prefix=GC
> # GC-NOT: rela.bar
> # GC: rela.text
> Index: lld/test/ELF/comdat.s
> ===================================================================
> --- lld/test/ELF/comdat.s
> +++ lld/test/ELF/comdat.s
> @@ -9,10 +9,10 @@
> // reclaimed sections on stderr.
> // RUN: ld.lld --gc-sections --print-gc-sections -shared %t.o %t.o %t2.o -o %t \
> // RUN: 2>&1 | FileCheck --check-prefix=GC %s
> -// GC: removing unused section from '.text' in file
> -// GC: removing unused section from '.text3' in file
> -// GC: removing unused section from '.text' in file
> -// GC: removing unused section from '.text' in file
> +// GC: removing unused section {{.*}}.o:(.text)
> +// GC: removing unused section {{.*}}.o:(.text3)
> +// GC: removing unused section {{.*}}.o:(.text)
> +// GC: removing unused section {{.*}}.o:(.text)
>
> .section .text2,"axG", at progbits,foo,comdat,unique,0
> foo:
> Index: lld/ELF/MarkLive.cpp
> ===================================================================
> --- lld/ELF/MarkLive.cpp
> +++ lld/ELF/MarkLive.cpp
> @@ -305,8 +305,7 @@
> if (Config->PrintGcSections)
> for (InputSectionBase *Sec : InputSections)
> if (!Sec->Live)
> - message("removing unused section from '" + Sec->Name + "' in file '" +
> - Sec->File->getName() + "'");
> + message("removing unused section " + toString(Sec));
> }
>
> template void elf::markLive<ELF32LE>();
>
>
> Index: lld/test/ELF/linkerscript/discard-print-gc.s
> ===================================================================
> --- lld/test/ELF/linkerscript/discard-print-gc.s
> +++ lld/test/ELF/linkerscript/discard-print-gc.s
> @@ -15,5 +15,5 @@
> .section .foo,"a"
> .quad 0
>
> -# CHECK: removing unused section from '.foo'
> -# QUIET-NOT: removing unused section from '.foo'
> +# CHECK: removing unused section {{.*}}:(.foo)
> +# QUIET-NOT: removing unused section {{.*}}:(.foo)
> Index: lld/test/ELF/gc-sections-print.s
> ===================================================================
> --- lld/test/ELF/gc-sections-print.s
> +++ lld/test/ELF/gc-sections-print.s
> @@ -2,8 +2,8 @@
> # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> # RUN: ld.lld %t --gc-sections --print-gc-sections -o %t2 2>&1 | FileCheck -check-prefix=PRINT %s
>
> -# PRINT: removing unused section from '.text.x' in file
> -# PRINT-NEXT: removing unused section from '.text.y' in file
> +# PRINT: removing unused section {{.*}}:(.text.x)
> +# PRINT-NEXT: removing unused section {{.*}}:(.text.y)
>
> # RUN: ld.lld %t --gc-sections --print-gc-sections --no-print-gc-sections -o %t2 >& %t.log
> # RUN: echo >> %t.log
> Index: lld/test/ELF/emit-relocs-gc.s
> ===================================================================
> --- lld/test/ELF/emit-relocs-gc.s
> +++ lld/test/ELF/emit-relocs-gc.s
> @@ -11,8 +11,8 @@
> ## .rela.text because we keep .text.
> # RUN: ld.lld --gc-sections --emit-relocs --print-gc-sections %t.o -o %t \
> # RUN: | FileCheck --check-prefix=MSG %s
> -# MSG: removing unused section from '.bar' in file
> -# MSG: removing unused section from '.rela.bar' in file
> +# MSG: removing unused section {{.*}}.o:(.bar)
> +# MSG: removing unused section {{.*}}.o:(.rela.bar)
> # RUN: llvm-objdump %t -section-headers | FileCheck %s --check-prefix=GC
> # GC-NOT: rela.bar
> # GC: rela.text
> Index: lld/test/ELF/comdat.s
> ===================================================================
> --- lld/test/ELF/comdat.s
> +++ lld/test/ELF/comdat.s
> @@ -9,10 +9,10 @@
> // reclaimed sections on stderr.
> // RUN: ld.lld --gc-sections --print-gc-sections -shared %t.o %t.o %t2.o -o %t \
> // RUN: 2>&1 | FileCheck --check-prefix=GC %s
> -// GC: removing unused section from '.text' in file
> -// GC: removing unused section from '.text3' in file
> -// GC: removing unused section from '.text' in file
> -// GC: removing unused section from '.text' in file
> +// GC: removing unused section {{.*}}.o:(.text)
> +// GC: removing unused section {{.*}}.o:(.text3)
> +// GC: removing unused section {{.*}}.o:(.text)
> +// GC: removing unused section {{.*}}.o:(.text)
>
> .section .text2,"axG", at progbits,foo,comdat,unique,0
> foo:
> Index: lld/ELF/MarkLive.cpp
> ===================================================================
> --- lld/ELF/MarkLive.cpp
> +++ lld/ELF/MarkLive.cpp
> @@ -305,8 +305,7 @@
> if (Config->PrintGcSections)
> for (InputSectionBase *Sec : InputSections)
> if (!Sec->Live)
> - message("removing unused section from '" + Sec->Name + "' in file '" +
> - Sec->File->getName() + "'");
> + message("removing unused section " + toString(Sec));
> }
>
> template void elf::markLive<ELF32LE>();
More information about the llvm-commits
mailing list