From f2e71244c6274984c33df9a58a78fcf71218ee21 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 23 Mar 2016 21:16:33 +0000 Subject: Fix logic for which symbols to keep with comdats. If a comdat is dropped, all symbols in it are dropped. If a comdat is kept, the symbols survive to pass regular symbol resolution. With this patch we do that for all global symbols. The added test is a copy of test/tools/gold/X86/comdat.ll that we now pass. llvm-svn: 264192 --- llvm/lib/Linker/LinkModules.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Linker/LinkModules.cpp') diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 8eeccb369df..d3c3ea34e6d 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -422,9 +422,8 @@ bool ModuleLinker::linkIfNeeded(GlobalValue &GV) { bool LinkFromSrc; Comdat::SelectionKind SK; std::tie(SK, LinkFromSrc) = ComdatsChosen[SC]; - if (LinkFromSrc) - ValuesToLink.insert(&GV); - return false; + if (!LinkFromSrc) + return false; } bool LinkFromSrc = true; @@ -565,7 +564,8 @@ bool ModuleLinker::run() { if (!SC) continue; for (GlobalValue *GV2 : ComdatMembers[SC]) - ValuesToLink.insert(GV2); + if (GV2->hasInternalLinkage()) + ValuesToLink.insert(GV2); } if (shouldInternalizeLinkedSymbols()) { -- cgit v1.2.3