From 42e032376898ce867355515a2af51748bc9d7668 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 24 Mar 2016 14:58:44 +0000 Subject: Fix resolution of linkonce symbols in comdats. After comdat processing, the symbols still go through regular symbol resolution. We were not doing it for linkonce symbols since they are lazy linked. This fixes pr27044. llvm-svn: 264288 --- llvm/lib/Linker/LinkModules.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Linker/LinkModules.cpp') diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 9ee3fb32e21..f6e0f060cc0 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -566,8 +566,14 @@ bool ModuleLinker::run() { const Comdat *SC = GV->getComdat(); if (!SC) continue; - for (GlobalValue *GV2 : LazyComdatMembers[SC]) - ValuesToLink.insert(GV2); + for (GlobalValue *GV2 : LazyComdatMembers[SC]) { + GlobalValue *DGV = getLinkedToGlobal(GV2); + bool LinkFromSrc = true; + if (DGV && shouldLinkFromSource(LinkFromSrc, *DGV, *GV2)) + return true; + if (LinkFromSrc) + ValuesToLink.insert(GV2); + } } if (shouldInternalizeLinkedSymbols()) { -- cgit v1.2.3