]> granicus.if.org Git - llvm/commit
[ThinLTO] Fix handling of weak interposable symbols
authorTeresa Johnson <tejohnson@google.com>
Fri, 23 Aug 2019 15:18:58 +0000 (15:18 +0000)
committerTeresa Johnson <tejohnson@google.com>
Fri, 23 Aug 2019 15:18:58 +0000 (15:18 +0000)
commit5fc15cac7f90c28f4fe3187e2a2d1c4e50011877
tree1481c08235be8a4f88210fc3b1ecb5839a456039
parent7b27133646ab5015079413d64d278e84389cfa0b
[ThinLTO] Fix handling of weak interposable symbols

Summary:
Keep aliasees alive if their alias is live, otherwise we end up with an
alias to a declaration, which is invalid. This can happen when the
aliasee is weak and non-prevailing.

This fix exposed the fact that we were then attempting to internalize
the weak symbol, which was not exported as it was not prevailing. We
should not internalize interposable symbols in general, unless this is
the prevailing copy, since it can lead to incorrect inlining and other
optimizations. Most of the changes in this patch are due to the
restructuring required to pass down the prevailing callback.

Finally, while implementing the test cases, I found that in the case of
a weak aliasee that is still marked not live because its alias isn't
live, after dropping the definition we incorrectly marked the
declaration with weak linkage when resolving prevailing symbols in the
module. This was due to some special case handling for symbols marked
WeakLinkage in the summary located before instead of after a subsequent
check for the symbol being a declaration. It turns out that we don't
actually need this special case handling any more (looking back at the
history, when that was added the code was structured quite differently)
- we will correctly mark with weak linkage further below when the
definition hasn't been dropped.

Fixes PR42542.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, dang, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66264

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369766 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/LTO/LTO.h
lib/LTO/LTO.cpp
lib/LTO/ThinLTOCodeGenerator.cpp
lib/Transforms/IPO/FunctionImport.cpp
test/LTO/Resolution/X86/not-prevailing-weak-aliasee.ll [new file with mode: 0644]
test/ThinLTO/X86/Inputs/internalize.ll [new file with mode: 0644]
test/ThinLTO/X86/internalize.ll