The unnamedaddr property of a function is lost when using
`-fwhole-program-vtables` and thinlto which causes size increase under linker's
safe icf mode.
The size increase of chrome on Linux when switching from all icf to safe icf
drops from 5 MB to 3 MB after this change, and from 6 MB to 4 MB on Windows.
There is a repro:
```
# a.h
struct A {
virtual int f();
virtual int g();
};
# a.cpp
#include "a.h"
int A::f() { return 10; }
int A::g() { return 10; }
# main.cpp
#include "a.h"
int g(A* a) {
return a->f();
}
int main(int argv, char** args) {
A a;
return g(&a);
}
$ clang++ -O2 -ffunction-sections -flto=thin -fwhole-program-vtables -fsplit-lto-unit -c main.cpp -o main.o && clang++ -Wl,--icf=safe -fuse-ld=lld -flto=thin main.o -o a.out && llvm-readobj -t a.out | grep -A 1 -e _ZN1A1fEv -e _ZN1A1gEv
Name: _ZN1A1fEv (480)
Value: 0x201830
--
Name: _ZN1A1gEv (490)
Value: 0x201840
```
Differential Revision: https://reviews.llvm.org/D100498
|
||
|---|---|---|
| .. | ||
| x86 | ||
| associated.ll | ||
| cfi-debug-info-cloned-type-references-global-value.ll | ||
| cfi-functions-canonical-jump-tables.ll | ||
| circular-reference.ll | ||
| comdat.ll | ||
| filter-alias.ll | ||
| function-alias.ll | ||
| new-pm.ll | ||
| no-type-md.ll | ||
| pr33536.ll | ||
| split-dsolocal.ll | ||
| split-internal-typeid.ll | ||
| split-internal1.ll | ||
| split-internal2.ll | ||
| split-used.ll | ||
| split-vfunc-internal.ll | ||
| split-vfunc.ll | ||
| split.ll | ||
| symver.ll | ||
| unsplittable.ll | ||