[PATCH] D107988: [Linker] Import IFuncs

Itay Bookstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 12 11:48:12 PDT 2021


nextsilicon-itay-bookstein created this revision.
nextsilicon-itay-bookstein added reviewers: tejohnson, respindola.
Herald added a subscriber: hiraditya.
nextsilicon-itay-bookstein requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When importing symbols from another module, also import GlobalIFuncs.

Author: Itay Bookstein <itay.bookstein at nextsilicon.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107988

Files:
  llvm/lib/Linker/LinkModules.cpp
  llvm/test/Linker/Inputs/ifunc.ll
  llvm/test/Linker/ifunc.ll


Index: llvm/test/Linker/ifunc.ll
===================================================================
--- /dev/null
+++ 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() {
Index: llvm/test/Linker/Inputs/ifunc.ll
===================================================================
--- /dev/null
+++ llvm/test/Linker/Inputs/ifunc.ll
@@ -0,0 +1,10 @@
+ at foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*)
+ at 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
+}
Index: llvm/lib/Linker/LinkModules.cpp
===================================================================
--- llvm/lib/Linker/LinkModules.cpp
+++ 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107988.366058.patch
Type: text/x-patch
Size: 1462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210812/17b67ec6/attachment.bin>


More information about the llvm-commits mailing list