[PATCH] D71649: [PPC32] Emit R_PPC_PLTREL24 for calls to dso_local ifunc
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 11:31:47 PST 2019
MaskRay updated this revision to Diff 234937.
MaskRay added a comment.
Rename ifunc-dsolocal.ll as ifunc.ll because we also test non-dsolocal cases.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71649/new/
https://reviews.llvm.org/D71649
Files:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/ifunc.ll
Index: llvm/test/CodeGen/PowerPC/ifunc.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/ifunc.ll
@@ -0,0 +1,25 @@
+; RUN: llc %s -o - -mtriple=powerpc | FileCheck --check-prefix=REL %s
+; RUN: llc %s -o - -mtriple=powerpc -relocation-model=pic | FileCheck --check-prefix=PLTREL %s
+; RUN: llc %s -o - -mtriple=powerpc64 | FileCheck --check-prefix=REL %s
+; RUN: llc %s -o - -mtriple=powerpc64 -relocation-model=pic | FileCheck --check-prefix=REL %s
+
+ at ifunc1 = dso_local ifunc void(), i8*()* @resolver
+ at ifunc2 = ifunc void(), i8*()* @resolver
+
+define i8* @resolver() { ret i8* null }
+
+define void @foo() #0 {
+ ; REL: bl ifunc1{{$}}
+ ; REL: bl ifunc2{{$}}
+ ; PLTREL: bl ifunc1 at PLT+32768
+ ; PLTREL: bl ifunc2 at PLT+32768
+ call void @ifunc1()
+ call void @ifunc2()
+ ret void
+}
+
+;; Use Secure PLT ABI for PPC32.
+attributes #0 = { "target-features"="+secure-plt" }
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"PIC Level", i32 2}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -5102,9 +5102,10 @@
auto isLocalCallee = [&]() {
const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
const Module *Mod = DAG.getMachineFunction().getFunction().getParent();
+ const GlobalValue *GV = G ? G->getGlobal() : nullptr;
- return DAG.getTarget().shouldAssumeDSOLocal(*Mod,
- G ? G->getGlobal() : nullptr);
+ return DAG.getTarget().shouldAssumeDSOLocal(*Mod, GV) &&
+ !dyn_cast_or_null<GlobalIFunc>(GV);
};
// The PLT is only used in 32-bit ELF PIC mode. Attempting to use the PLT in
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71649.234937.patch
Type: text/x-patch
Size: 1830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191220/df271fa7/attachment.bin>
More information about the llvm-commits
mailing list