diff options
author | Zequan Wu <zequanwu@google.com> | 2021-04-14 10:42:50 -0700 |
---|---|---|
committer | Zequan Wu <zequanwu@google.com> | 2021-04-19 14:04:58 -0700 |
commit | e28435caf63b1d2437538c2b581bf005d3c57fb2 (patch) | |
tree | 89ad9dbe65d6e14ae5fa50093f744aa487613485 /llvm/lib/CodeGen/MachineModuleInfo.cpp | |
parent | cc2b62a06e616c6406b0f1387625b50d3d0639ad (diff) | |
download | llvm-e28435caf63b1d2437538c2b581bf005d3c57fb2.zip llvm-e28435caf63b1d2437538c2b581bf005d3c57fb2.tar.gz llvm-e28435caf63b1d2437538c2b581bf005d3c57fb2.tar.bz2 |
[ThinLTO] Copy UnnamedAddr when spliting module.
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
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
0 files changed, 0 insertions, 0 deletions