diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-02-08 18:47:20 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-02-08 18:47:20 +0000 |
commit | d7e88e515c19ccf7ca21d01f1762697a67e1da8e (patch) | |
tree | d3d3b67ac83886fbddbbb4c52623554783b5e978 /llvm/lib/Linker/LinkModules.cpp | |
parent | 73fe6ce1187f5b4ec2636e5cb3c5120660fcb1e8 (diff) | |
download | bcm5719-llvm-d7e88e515c19ccf7ca21d01f1762697a67e1da8e.tar.gz bcm5719-llvm-d7e88e515c19ccf7ca21d01f1762697a67e1da8e.zip |
[ThinLTO] Remove imported available externally defs from comdats.
Summary:
Available externally definitions are considered declarations for the
linker and eventually dropped. As such they are not allowed to be
in comdats. Remove any such imported functions from comdats.
Reviewers: rafael
Subscribers: davidxl, llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D16120
llvm-svn: 260122
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index a9b8ef2470b..4bb4b3f4f23 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -722,9 +722,21 @@ void ThinLTOGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) { GV.setVisibility(GlobalValue::HiddenVisibility); if (isModuleExporting()) NewExportedValues.insert(&GV); - return; + } else + GV.setLinkage(getLinkage(&GV)); + + // Remove functions imported as available externally defs from comdats, + // as this is a declaration for the linker, and will be dropped eventually. + // It is illegal for comdats to contain declarations. + auto *GO = dyn_cast_or_null<GlobalObject>(&GV); + if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) { + // The IRMover should not have placed any imported declarations in + // a comdat, so the only declaration that should be in a comdat + // at this point would be a definition imported as available_externally. + assert(GO->hasAvailableExternallyLinkage() && + "Expected comdat on definition (possibly available external)"); + GO->setComdat(nullptr); } - GV.setLinkage(getLinkage(&GV)); } void ThinLTOGlobalProcessing::processGlobalsForThinLTO() { |