[PATCH] D144444: [PowerPC] Use member function to determine PowerPC Secure PLT

Brad Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 20 19:51:55 PST 2023


brad updated this revision to Diff 499018.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144444/new/

https://reviews.llvm.org/D144444

Files:
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp


Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -106,9 +106,7 @@
   if (IsPPC64 && has64BitSupport())
     Use64BitRegs = true;
 
-  if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
-      TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
-      TargetTriple.isMusl())
+  if (TargetTriple.isPPCSecurePlt())
     IsSecurePlt = true;
 
   if (HasSPE && IsPPC64)
Index: llvm/include/llvm/TargetParser/Triple.h
===================================================================
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -890,6 +890,15 @@
             getOS() == Triple::OpenBSD || isMusl()));
   }
 
+  /// Tests whether the target 32-bit PowerPC uses Secure PLT.
+  bool isPPCSecurePlt() const {
+    return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
+            ((getOS() == Triple::FreeBSD &&
+            (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
+            getOS() == Triple::NetBSD || getOS() == Triple::OpenBSD ||
+            isMusl()));
+  }
+
   /// Tests whether the target is 32-bit RISC-V.
   bool isRISCV32() const { return getArch() == Triple::riscv32; }
 
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -119,8 +119,7 @@
                                               const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
     return ppc::ReadGOTPtrMode::SecurePlt;
-  if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
-      Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+  if (Triple.isPPCSecurePlt())
     return ppc::ReadGOTPtrMode::SecurePlt;
   else
     return ppc::ReadGOTPtrMode::Bss;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144444.499018.patch
Type: text/x-patch
Size: 2006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230221/81d7fbd5/attachment.bin>


More information about the cfe-commits mailing list