diff options
author | Bob Haarman <llvm@inglorion.net> | 2018-07-27 05:40:29 +0000 |
---|---|---|
committer | Bob Haarman <llvm@inglorion.net> | 2018-07-27 05:40:29 +0000 |
commit | 10a832fe97fefabc503c8cb257fdb1954da8df0e (patch) | |
tree | 68fd2b876e0eafecaeebdd7259c9d77f8159f0e9 /lib/LTO/LTO.cpp | |
parent | 01a1fe5ce8b72d608f8b7c9852ea780a55492e66 (diff) |
[LTO] Don't internalize declarations
Summary:
Some links were failing with "Global is external, but doesn't have
external or weak linkage!" in ThinLTO builds with debug
information. This happened when we elide the body of a global that is
referenced by debug info. This results in a declaration, which we
would then internalize - but declarations cannot be internal. This
change avoids the problem by not internalizing these declarations.
Fixes PR38046.
Reviewers: pcc, tejohnson
Subscribers: mehdi_amini, aprantl, hiraditya, JDevlieghere, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D49777
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338100 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO/LTO.cpp')
-rw-r--r-- | lib/LTO/LTO.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp index 32b48ddfef7..68d210cb7d7 100644 --- a/lib/LTO/LTO.cpp +++ b/lib/LTO/LTO.cpp @@ -872,7 +872,8 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) { GlobalValue *GV = RegularLTO.CombinedModule->getNamedValue(R.second.IRName); // Ignore symbols defined in other partitions. - if (!GV || GV->hasLocalLinkage()) + // Also skip declarations, which are not allowed to have internal linkage. + if (!GV || GV->hasLocalLinkage() || GV->isDeclaration()) continue; GV->setUnnamedAddr(R.second.UnnamedAddr ? GlobalValue::UnnamedAddr::Global : GlobalValue::UnnamedAddr::None); |