[PATCH] D106228: [LTO] Add SelectionKind to IRSymtab and use it in ld.lld/LLVMgold

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 17 15:41:21 PDT 2021


MaskRay created this revision.
MaskRay added a reviewer: tejohnson.
Herald added subscribers: ormris, wenlei, steven_wu, hiraditya, arichardson, inglorion, sbc100, emaste.
MaskRay requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

In PGO, a C++ external linkage function `foo` has a private counter
`__profc_foo` and a private `__profd_foo` in a `comdat noduplicates`.

A `__attribute__((weak))` function `foo` has a weak hidden counter `__profc_foo`
and a private `__profd_foo` in a `comdat noduplicates`.

In `ld.lld a.o b.o`, say a.o defines an external linkage `foo` and b.o
defines a weak `foo`. Currently we treat `comdat noduplicates` as `comdat any`,
ld.lld will incorrectly consider `b.o:__profc_foo` non-prevailing.  In the worst
case `b.o:__profd_foo` is retained and `b.o:__profc_foo` isn't there will be
dangling reference causing an `undefined hidden symbol` error.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106228

Files:
  lld/COFF/InputFiles.cpp
  lld/ELF/InputFiles.cpp
  lld/test/ELF/lto/comdat-noduplicates.ll
  lld/wasm/InputFiles.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Object/IRSymtab.h
  llvm/lib/Object/IRSymtab.cpp
  llvm/test/LTO/Resolution/X86/symtab.ll
  llvm/test/Object/X86/irsymtab.ll
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106228.359587.patch
Type: text/x-patch
Size: 13619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210717/0ec58fd8/attachment.bin>


More information about the llvm-commits mailing list