[all-commits] [llvm/llvm-project] e28435: [ThinLTO] Copy UnnamedAddr when spliting module.

ZequanWu via All-commits all-commits at lists.llvm.org
Mon Apr 19 14:05:31 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e28435caf63b1d2437538c2b581bf005d3c57fb2
      https://github.com/llvm/llvm-project/commit/e28435caf63b1d2437538c2b581bf005d3c57fb2
  Author: Zequan Wu <zequanwu at google.com>
  Date:   2021-04-19 (Mon, 19 Apr 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll

  Log Message:
  -----------
  [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




More information about the All-commits mailing list