[PATCH] D43336: [ELF] Add ICF test case to symbol-ordering-file-warnings.s

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 10:30:21 PST 2018


LGTM

The warning is reasonable since whatever heuristic we use for handling
ICF it will be impossible to order the symbols in the way specified in
the order file.

Cheers,
Rafael

James Henderson via Phabricator <reviews at reviews.llvm.org> writes:

> jhenderson created this revision.
> jhenderson added reviewers: ruiu, rafael, grimar.
> Herald added subscribers: arichardson, emaste.
>
> I noticed that I had missed his particular test case. I think it's simple enough, but others might have some thoughts on what should happen if two identical symbols have been folded, and one or both are in the order file, so hence the review request.
>
>
> Repository:
>   rLLD LLVM Linker
>
> https://reviews.llvm.org/D43336
>
> Files:
>   test/ELF/symbol-ordering-file-warnings.s
>
>
> Index: test/ELF/symbol-ordering-file-warnings.s
> ===================================================================
> --- test/ELF/symbol-ordering-file-warnings.s
> +++ test/ELF/symbol-ordering-file-warnings.s
> @@ -37,6 +37,12 @@
>  # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-gc.txt --gc-sections --unresolved-symbols=ignore-all 2>&1 | \
>  # RUN:   FileCheck %s --check-prefixes=WARN,GC
>  
> +# Check that a warning is emitted for the symbol removed due to --icf.
> +# RUN: echo "icf1" > %t-order-icf.txt
> +# RUN: echo "icf2" >> %t-order-icf.txt
> +# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-icf.txt --icf=all --unresolved-symbols=ignore-all 2>&1 | \
> +# RUN:   FileCheck %s --check-prefixes=WARN,ICF
> +
>  # Check that a warning is emitted for symbols discarded due to a linker script /DISCARD/ section.
>  # RUN: echo "discard" > %t-order-discard.txt
>  # RUN: echo "SECTIONS { /DISCARD/ : { *(.text.discard) } }" > %t.script
> @@ -101,6 +107,7 @@
>  # WARN-NOT:    warning:
>  # MISSING:     warning: symbol ordering file: no such symbol: missing
>  # MISSING2:    warning: symbol ordering file: no such symbol: missing_sym
> +# ICF:         warning: {{.*}}1.o: unable to order discarded symbol: icf2
>  # COMDAT:      warning: {{.*}}1.o: unable to order discarded symbol: comdat
>  # COMDAT-NEXT: warning: {{.*}}2.o: unable to order discarded symbol: comdat
>  # MULTI:       warning: {{.*}}2.o: unable to order absolute symbol: multi
> @@ -129,12 +136,23 @@
>  glob_or_wk:
>    nop
>  
> -.text
> +.section .text._start,"ax", at progbits
>  .global _start
>  _start:
>    movq  %rax, absolute
>    callq shared
>  
> +.section .text.icf1,"ax", at progbits
> +.global icf1
> +icf1:
> +    ret
> +
> +.section .text.icf2,"ax", at progbits
> +.global icf2
> +icf2:
> +    ret
> +
>  # This is a "good" instance of the symbol
> +.section .text.multi,"ax", at progbits
>  multi:
>    nop
>
>
> Index: test/ELF/symbol-ordering-file-warnings.s
> ===================================================================
> --- test/ELF/symbol-ordering-file-warnings.s
> +++ test/ELF/symbol-ordering-file-warnings.s
> @@ -37,6 +37,12 @@
>  # RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-gc.txt --gc-sections --unresolved-symbols=ignore-all 2>&1 | \
>  # RUN:   FileCheck %s --check-prefixes=WARN,GC
>  
> +# Check that a warning is emitted for the symbol removed due to --icf.
> +# RUN: echo "icf1" > %t-order-icf.txt
> +# RUN: echo "icf2" >> %t-order-icf.txt
> +# RUN: ld.lld %t1.o -o %t --symbol-ordering-file %t-order-icf.txt --icf=all --unresolved-symbols=ignore-all 2>&1 | \
> +# RUN:   FileCheck %s --check-prefixes=WARN,ICF
> +
>  # Check that a warning is emitted for symbols discarded due to a linker script /DISCARD/ section.
>  # RUN: echo "discard" > %t-order-discard.txt
>  # RUN: echo "SECTIONS { /DISCARD/ : { *(.text.discard) } }" > %t.script
> @@ -101,6 +107,7 @@
>  # WARN-NOT:    warning:
>  # MISSING:     warning: symbol ordering file: no such symbol: missing
>  # MISSING2:    warning: symbol ordering file: no such symbol: missing_sym
> +# ICF:         warning: {{.*}}1.o: unable to order discarded symbol: icf2
>  # COMDAT:      warning: {{.*}}1.o: unable to order discarded symbol: comdat
>  # COMDAT-NEXT: warning: {{.*}}2.o: unable to order discarded symbol: comdat
>  # MULTI:       warning: {{.*}}2.o: unable to order absolute symbol: multi
> @@ -129,12 +136,23 @@
>  glob_or_wk:
>    nop
>  
> -.text
> +.section .text._start,"ax", at progbits
>  .global _start
>  _start:
>    movq  %rax, absolute
>    callq shared
>  
> +.section .text.icf1,"ax", at progbits
> +.global icf1
> +icf1:
> +    ret
> +
> +.section .text.icf2,"ax", at progbits
> +.global icf2
> +icf2:
> +    ret
> +
>  # This is a "good" instance of the symbol
> +.section .text.multi,"ax", at progbits
>  multi:
>    nop


More information about the llvm-commits mailing list