[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
Wed Dec 18 10:28:52 PST 2019


MaskRay updated this revision to Diff 234573.
MaskRay added a comment.

Rebase on D70570 <https://reviews.llvm.org/D70570>

-relocation-model=static should use R_PPC_REL24


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-dsolocal.ll


Index: llvm/test/CodeGen/PowerPC/ifunc-dsolocal.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/ifunc-dsolocal.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
+  ; PLTREL: bl ifunc2 at PLT
+  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);
   };
 
   bool UsePlt = Subtarget.is32BitELFABI() && !isLocalCallee();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71649.234573.patch
Type: text/x-patch
Size: 1819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191218/a8616837/attachment.bin>


More information about the llvm-commits mailing list