[PATCH] D49622: ELF: Make sections with KeepUnique bit eligible for ICF.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 20 16:41:38 PDT 2018
pcc added inline comments.
================
Comment at: lld/ELF/ICF.cpp:471
return;
- print("selected section " + toString(Sections[Begin]));
- for (size_t I = Begin + 1; I < End; ++I) {
+ InputSection *Target = nullptr;
+ bool SeenUnique = false, Replaced = false;
----------------
ruiu wrote:
> I guess this could be a bit simpler:
>
> for (size_t I = Begin + 1; I < End; ++I) {
> if (Sections[Begin]->KeepUnique && Sections[I]->KeepUnique)
> Begin = I;
> else
> Sections[Begin]->replace(Sections[I]);
> }
It doesn't look like this is correct. With this input:
```
.globl _start
_start:
call f1
call f2
call f3
.section .text.f1,"ax"
.globl f1
f1:
ret
.section .text.f2,"ax"
.globl f2
f2:
ret
.section .text.f3,"ax"
.globl f3
f3:
ret
```
I get:
```
$ ra/bin/ld.lld foo.o --icf=all --print-icf-sections --keep-unique=f2 --keep-unique=f3
$ nm a.out
000000000020100f T f1
000000000020100f T f2
000000000020100f T f3
0000000000201000 T _start
```
I'll add some comments to my version.
https://reviews.llvm.org/D49622
More information about the llvm-commits
mailing list