[clang] 5d585c9 - [PowerPC] Use member function to determine PowerPC Secure PLT
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 21 11:14:42 PST 2023
Author: Brad Smith
Date: 2023-02-21T14:08:25-05:00
New Revision: 5d585c9dd07d0df4d450e2b1ba61fb17a5153aac
URL: https://github.com/llvm/llvm-project/commit/5d585c9dd07d0df4d450e2b1ba61fb17a5153aac
DIFF: https://github.com/llvm/llvm-project/commit/5d585c9dd07d0df4d450e2b1ba61fb17a5153aac.diff
LOG: [PowerPC] Use member function to determine PowerPC Secure PLT
Add a member function isPPC32SecurePlt() to determine whether Secure
PLT is used by the target 32-bit PowerPC operating environment.
Reviewed By: dim, maskray
Differential Revision: https://reviews.llvm.org/D144444
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/PPC.cpp
llvm/include/llvm/TargetParser/Triple.h
llvm/lib/Target/PowerPC/PPCSubtarget.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
index b02e3b73aa5e1..e19bcc026b0f1 100644
--- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -119,8 +119,7 @@ ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const llvm::Tripl
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.isPPC32SecurePlt())
return ppc::ReadGOTPtrMode::SecurePlt;
else
return ppc::ReadGOTPtrMode::Bss;
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 59513fa2f2062..9910bb2a1f149 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -890,6 +890,15 @@ class Triple {
getOS() == Triple::OpenBSD || isMusl()));
}
+ /// Tests whether the target 32-bit PowerPC uses Secure PLT.
+ bool isPPC32SecurePlt() 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; }
diff --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
index e32a2ed9dee7c..49400eefe4a94 100644
--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -106,9 +106,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef TuneCPU,
if (IsPPC64 && has64BitSupport())
Use64BitRegs = true;
- if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
- TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
- TargetTriple.isMusl())
+ if (TargetTriple.isPPC32SecurePlt())
IsSecurePlt = true;
if (HasSPE && IsPPC64)
More information about the cfe-commits
mailing list