[PATCH] D92673: [ThinLTO] Remove unused symbol declarations when possible

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 11:16:19 PST 2020


tejohnson created this revision.
tejohnson added a reviewer: wmi.
Herald added subscribers: wenlei, arphaman, steven_wu, hiraditya, inglorion, Prazek.
tejohnson requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Follow on to D42816 <https://reviews.llvm.org/D42816> which dropped declarations of dead symbols. With
this change we also drop declarations which were never defined in this
module, but which are also unused after dead symbols are removed. These
symbols may or may not be dead in their defining modules.

Removing the unused declarations will prevent indirect call promotion in
the ThinLTO Backend from adding a new reference to a symbol, which can
result in linker unsats if that symbol was in fact dead and therefore
removed in its defining module. This can happen when we compile with a
sample profile collected from one binary but used for another, which may
have profiled targets that aren't used in the new binary.

Some test changes occur as a result (for whole program devirtualization,
we end up with a cast if there is no declaration in the module, for ICP
tests we may need to add a direct call to keep the declaration around).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92673

Files:
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/LTO/Resolution/X86/load-sample-prof-icp.ll
  llvm/test/ThinLTO/X86/cfi-devirt.ll
  llvm/test/ThinLTO/X86/devirt-after-icp.ll
  llvm/test/ThinLTO/X86/index-const-prop-alias.ll
  llvm/test/ThinLTO/X86/index-const-prop-dead.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92673.309589.patch
Type: text/x-patch
Size: 6584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201204/1c40b171/attachment.bin>


More information about the llvm-commits mailing list