From c0a0363d5c269dc955c48345bf6b8e39d1c49e8b Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 25 May 2016 18:36:22 +0000 Subject: [IR] Copy comdats in GlobalObject::copyAttributesFrom This is probably correct for all uses except cross-module IR linking, where we need to move the comdat from the source module to the destination module. Fixes PR27870. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D20631 llvm-svn: 270743 --- llvm/lib/Linker/IRMover.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Linker') diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 0d37ad1c657..9a2cedfc59e 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -622,6 +622,11 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV, NewGV->copyAttributesFrom(SGV); + // Don't copy the comdat, it's from the original module. We'll handle it + // later. + if (auto *NewGO = dyn_cast(NewGV)) + NewGO->setComdat(nullptr); + // Remove these copied constants in case this stays a declaration, since // they point to the source module. If the def is linked the values will // be mapped in during linkFunctionBody. -- cgit v1.2.3