Skip to content

Commit 530aa7e

Browse files
nextsilicon-itay-booksteinMaskRay
authored andcommitted
[Linker] Import GlobalIFunc when importing symbols from another module
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D107988
1 parent db0af39 commit 530aa7e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

llvm/lib/Linker/LinkModules.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ bool ModuleLinker::run() {
526526
if (linkIfNeeded(GA))
527527
return true;
528528

529+
for (GlobalIFunc &GI : SrcM->ifuncs())
530+
if (linkIfNeeded(GI))
531+
return true;
532+
529533
for (unsigned I = 0; I < ValuesToLink.size(); ++I) {
530534
GlobalValue *GV = ValuesToLink[I];
531535
const Comdat *SC = GV->getComdat();

llvm/test/Linker/ifunc.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; RUN: split-file %s %t
2+
; RUN: llvm-link %t/a.ll %t/b.ll -S -o - | FileCheck %s
3+
4+
;; Check that ifuncs are linked in properly.
5+
6+
; CHECK-DAG: @foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*)
7+
; CHECK-DAG: define internal void ()* @foo_resolve() {
8+
9+
; CHECK-DAG: @bar = ifunc void (), bitcast (void ()* ()* @bar_resolve to void ()*)
10+
; CHECK-DAG: define internal void ()* @bar_resolve() {
11+
12+
;--- a.ll
13+
declare void @bar()
14+
15+
;--- b.ll
16+
@foo = ifunc void (), bitcast (void ()* ()* @foo_resolve to void ()*)
17+
@bar = ifunc void (), bitcast (void ()* ()* @bar_resolve to void ()*)
18+
19+
define internal void ()* @foo_resolve() {
20+
ret void ()* null
21+
}
22+
23+
define internal void ()* @bar_resolve() {
24+
ret void ()* null
25+
}

0 commit comments

Comments
 (0)