[llvm] [PowerPC] Handle CALL_RM like CALL for 32-bit ELF (PR #72758)
George Koehler via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 18 14:26:18 PST 2023
https://github.com/kernigh updated https://github.com/llvm/llvm-project/pull/72758
>From b34f3c376360c07c03326acbc444f57a734f8cb4 Mon Sep 17 00:00:00 2001
From: George Koehler <kernigh at gmail.com>
Date: Sat, 18 Nov 2023 14:39:36 -0500
Subject: [PATCH] [PowerPC] Handle CALL_RM like CALL for 32-bit ELF
If a function call has the strictfp attribute, its opcode changes from
CALL to CALL_RM. If the call uses the secure PLT for 32-bit ELF, then
it must getGlobalBaseReg() to set r30.
---
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 6 +++---
.../CodeGen/PowerPC/ppc32-secure-plt-rm.ll | 21 +++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
create mode 100644 llvm/test/CodeGen/PowerPC/ppc32-secure-plt-rm.ll
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index b57d185bb638b8c..96115eb8eea523f 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -5475,7 +5475,8 @@ void PPCDAGToDAGISel::Select(SDNode *N) {
// generate secure plt code for TLS symbols.
getGlobalBaseReg();
} break;
- case PPCISD::CALL: {
+ case PPCISD::CALL:
+ case PPCISD::CALL_RM: {
if (PPCLowering->getPointerTy(CurDAG->getDataLayout()) != MVT::i32 ||
!TM.isPositionIndependent() || !Subtarget->isSecurePlt() ||
!Subtarget->isTargetELF())
@@ -5491,8 +5492,7 @@ void PPCDAGToDAGISel::Select(SDNode *N) {
if (ES->getTargetFlags() == PPCII::MO_PLT)
getGlobalBaseReg();
}
- }
- break;
+ } break;
case PPCISD::GlobalBaseReg:
ReplaceNode(N, getGlobalBaseReg());
diff --git a/llvm/test/CodeGen/PowerPC/ppc32-secure-plt-rm.ll b/llvm/test/CodeGen/PowerPC/ppc32-secure-plt-rm.ll
new file mode 100644
index 000000000000000..96008b712e0e98d
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/ppc32-secure-plt-rm.ll
@@ -0,0 +1,21 @@
+; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -mattr=+secure-plt -relocation-model=pic | FileCheck %s
+
+; This variant of ppc32-pic-large.ll checks that a strictfp call sets
+; r30 for the secure PLT.
+
+declare void @call_foo()
+
+define void @foo() {
+entry:
+ call void @call_foo() #0
+ ret void
+}
+
+attributes #0 = { strictfp }
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"PIC Level", i32 2}
+
+; CHECK: addis 30, 30, .LTOC-.L0$pb at ha
+; CHECK: addi 30, 30, .LTOC-.L0$pb at l
+; CHECK: bl call_foo at PLT+32768
More information about the llvm-commits
mailing list