Index: lib/Linker/LinkModules.cpp =================================================================== --- lib/Linker/LinkModules.cpp +++ lib/Linker/LinkModules.cpp @@ -1026,6 +1026,12 @@ if (NewGV != DGV) copyGVAttributes(NewGV, SGV); + // Don't unset unnamed_addr on values with a jumptable attribute, since that + // leads to an invalid module. + if (Function *NewGVF = dyn_cast(NewGV)) + if (NewGVF->hasFnAttribute(Attribute::JumpTable)) + HasUnnamedAddr = true; + NewGV->setUnnamedAddr(HasUnnamedAddr); NewGV->setVisibility(Visibility); Index: test/Linker/jumptable-a.ll =================================================================== --- /dev/null +++ test/Linker/jumptable-a.ll @@ -0,0 +1,4 @@ +; RUN: llvm-link %s %p/jumptable-b.ll -S -o - | FileCheck %s +declare void @f() +; CHECK: ; Function Attrs: jumptable +; CHECK: define void @f() unnamed_addr #0 { Index: test/Linker/jumptable-b.ll =================================================================== --- /dev/null +++ test/Linker/jumptable-b.ll @@ -0,0 +1,4 @@ +; RUN: true +define void @f() unnamed_addr jumptable { + ret void +}