summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-21 01:59:39 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-21 01:59:39 +0000
commitbda3c97c16916c6a0b94b01f59acbc98b845e7b6 (patch)
tree339b70f7a990ae6e5fcab669525a1c2f2bedce91 /llvm/lib/Linker/LinkModules.cpp
parentc196531ef304725afdf1de11bbb544639ef56b80 (diff)
downloadbcm5719-llvm-bda3c97c16916c6a0b94b01f59acbc98b845e7b6.tar.gz
bcm5719-llvm-bda3c97c16916c6a0b94b01f59acbc98b845e7b6.zip
ThinLTO/ModuleLinker: add a flag to not always pull-in linkonce when performing importing
Summary: The function importer already decided what symbols need to be pulled in. Also these magically added ones will not be in the export list for the source module, which can confuse the internalizer for instance. Reviewers: tejohnson, rafael Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D19096 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266948
Diffstat (limited to 'llvm/lib/Linker/LinkModules.cpp')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index cd3cd52f7ad..8ed885649ca 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -45,6 +45,9 @@ class ModuleLinker {
/// to Add.
void addLazyFor(GlobalValue &GV, IRMover::ValueAdder Add);
+ bool shouldLinkReferencedLinkOnce() {
+ return !(Flags & Linker::DontForceLinkLinkonceODR);
+ }
bool shouldOverrideFromSrc() { return Flags & Linker::OverrideFromSrc; }
bool shouldLinkOnlyNeeded() { return Flags & Linker::LinkOnlyNeeded; }
bool shouldInternalizeLinkedSymbols() {
@@ -413,6 +416,12 @@ bool ModuleLinker::linkIfNeeded(GlobalValue &GV) {
}
void ModuleLinker::addLazyFor(GlobalValue &GV, IRMover::ValueAdder Add) {
+ if (!shouldLinkReferencedLinkOnce())
+ // For ThinLTO we don't import more than what was required.
+ // The client has to guarantee that the linkonce will be availabe at link
+ // time (by promoting it to weak for instance).
+ return;
+
// Add these to the internalize list
if (!GV.hasLinkOnceLinkage())
return;
OpenPOWER on IntegriCloud