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 | eae4742d81ef598dc2000312ad2471c4632bcb83 (patch) | |
tree | 77cf6a27563f2b975f9802bf64076e0f08eba0a9 /llvm/lib/LTO/LTO.cpp | |
parent | a8301fce51cf6f55f53a3b8d1d61230a451a3153 (diff) | |
download | llvm-eae4742d81ef598dc2000312ad2471c4632bcb83.zip llvm-eae4742d81ef598dc2000312ad2471c4632bcb83.tar.gz llvm-eae4742d81ef598dc2000312ad2471c4632bcb83.tar.bz2 |
[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
llvm-svn: 338100
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 32b48dd..68d210c 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/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); |