diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-08-15 21:00:04 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-08-15 21:00:04 +0000 |
commit | 6107a4195d84279bb71f58b4b7d9b76384b43af0 (patch) | |
tree | 864988697f07c3179bfaa0f44990d8cc5f64c43f /llvm/lib/Transforms | |
parent | c80c15bd501d9a7c3d356599f33dd7c92a7ea013 (diff) | |
download | bcm5719-llvm-6107a4195d84279bb71f58b4b7d9b76384b43af0.tar.gz bcm5719-llvm-6107a4195d84279bb71f58b4b7d9b76384b43af0.zip |
[ThinLTO] Remove functions resolved to available_externally from comdats
Summary:
thinLTOResolveWeakForLinkerModule needs to drop any preempted weak symbols
that were converted to available_externally from comdats, otherwise we
will get a verification failure (since available_externally is a
declaration for the linker, and no declarations can be in a comdat).
Reviewers: mehdi_amini
Subscribers: llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D23015
llvm-svn: 278739
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index c9d008ebd38..4b429d88215 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -493,6 +493,15 @@ void llvm::thinLTOResolveWeakForLinkerModule( DEBUG(dbgs() << "ODR fixing up linkage for `" << GV.getName() << "` from " << GV.getLinkage() << " to " << NewLinkage << "\n"); GV.setLinkage(NewLinkage); + // Remove functions converted to available_externally 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()) { + assert(GO->hasAvailableExternallyLinkage() && + "Expected comdat on definition (possibly available external)"); + GO->setComdat(nullptr); + } }; // Process functions and global now |