diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -526,6 +526,10 @@ if (linkIfNeeded(GA)) return true; + for (GlobalIFunc &GI : SrcM->ifuncs()) + if (linkIfNeeded(GI)) + return true; + for (unsigned I = 0; I < ValuesToLink.size(); ++I) { GlobalValue *GV = ValuesToLink[I]; const Comdat *SC = GV->getComdat(); diff --git a/llvm/test/Linker/Inputs/ifunc.ll b/llvm/test/Linker/Inputs/ifunc.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Linker/Inputs/ifunc.ll @@ -0,0 +1,10 @@ +@foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*) +@bar = ifunc void (), bitcast (void ()* ()* @bar_resolve to void ()*) + +define internal void ()* @foo_resolve() { + ret void ()* null +} + +define internal void ()* @bar_resolve() { + ret void ()* null +} diff --git a/llvm/test/Linker/ifunc.ll b/llvm/test/Linker/ifunc.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Linker/ifunc.ll @@ -0,0 +1,8 @@ +; RUN: llvm-link %s %p/Inputs/ifunc.ll -S -o - | FileCheck %s + +; CHECK-DAG: @foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*) +; CHECK-DAG: define internal void ()* @foo_resolve() { + +declare void @bar() +; CHECK-DAG: @bar = ifunc void (), bitcast (void ()* ()* @bar_resolve to void ()*) +; CHECK-DAG: define internal void ()* @bar_resolve() {