Index: llvm/trunk/lib/Linker/IRMover.cpp =================================================================== --- llvm/trunk/lib/Linker/IRMover.cpp +++ llvm/trunk/lib/Linker/IRMover.cpp @@ -640,6 +640,10 @@ } else { if (ForDefinition) NewGV = copyGlobalAliasProto(cast(SGV)); + else if (SGV->getValueType()->isFunctionTy()) + NewGV = + Function::Create(cast(TypeMap.get(SGV->getValueType())), + GlobalValue::ExternalLinkage, SGV->getName(), &DstM); else NewGV = new GlobalVariable( DstM, TypeMap.get(SGV->getValueType()), Index: llvm/trunk/test/LTO/Resolution/X86/function-alias-non-prevailing.ll =================================================================== --- llvm/trunk/test/LTO/Resolution/X86/function-alias-non-prevailing.ll +++ llvm/trunk/test/LTO/Resolution/X86/function-alias-non-prevailing.ll @@ -0,0 +1,17 @@ +; RUN: llvm-as -o %t %s +; RUN: llvm-lto2 run %t -r %t,foo, -r %t,baz,p -o %t2 -save-temps +; RUN: llvm-dis -o - %t2.0.0.preopt.bc | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64--fuchsia" + +; CHECK: declare void @foo() +@foo = weak alias void(), void()* @bar + +define internal void @bar() { + ret void +} + +define void()* @baz() { + ret void()* @foo +}