Index: llvm/lib/Transforms/IPO/FunctionImport.cpp =================================================================== --- llvm/lib/Transforms/IPO/FunctionImport.cpp +++ llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -618,10 +618,12 @@ if (Function *F = dyn_cast(&GV)) { F->deleteBody(); F->clearMetadata(); + F->setComdat(nullptr); } else if (GlobalVariable *V = dyn_cast(&GV)) { V->setInitializer(nullptr); V->setLinkage(GlobalValue::ExternalLinkage); V->clearMetadata(); + V->setComdat(nullptr); } else // For now we don't resolve or drop aliases. Once we do we'll // need to add support here for creating either a function or Index: llvm/test/LTO/Resolution/X86/not-prevailing.ll =================================================================== --- llvm/test/LTO/Resolution/X86/not-prevailing.ll +++ llvm/test/LTO/Resolution/X86/not-prevailing.ll @@ -24,7 +24,8 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" -define weak i32 @foo() { +$foo = comdat any +define weak i32 @foo() comdat { ret i32 65 }