[clang] [ARM] Introduce -mtp=auto and make it the default (PR #128901)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 22:48:18 PST 2025
https://github.com/Zhenhang1213 updated https://github.com/llvm/llvm-project/pull/128901
>From fb062da006042e7f0d6cab77f9d0d57a50d091f9 Mon Sep 17 00:00:00 2001
From: Austin <zhenhangwang at huawei.com>
Date: Thu, 27 Feb 2025 00:11:56 +0800
Subject: [PATCH] [ARM] Introduce -mtp=auto and make it the default
This adds a new value auto to the possible values of the existing -mtp= clang option which controls how the thread pointer is found. auto means the same as soft if the target architecture doesn't support a hardware thread pointer at all; otherwise it means the same as cp15.
This behavior is the default in gcc version 7.3.0 and later. The new auto option is therefore also the default in clang, so this change aligns clang with gcc.
---
clang/lib/Driver/ToolChains/Arch/ARM.cpp | 10 +++++-----
clang/test/Driver/arm-thread-pointer.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 3aee540d501be..c07b6afc08fd3 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -239,7 +239,7 @@ arm::ReadTPMode arm::getReadTPMode(const Driver &D, const ArgList &Args,
D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);
return ReadTPMode::Invalid;
}
- return ReadTPMode::Soft;
+ return (isHardTPSupported(Triple) ? ReadTPMode::TPIDRURO : ReadTPMode::Soft);
}
void arm::setArchNameInTriple(const Driver &D, const ArgList &Args,
@@ -574,12 +574,12 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
A->ignoreTargetSpecific();
}
- if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRURW)
+ arm::ReadTPMode TPMode = getReadTPMode(D, Args, Triple, ForAS);
+
+ if (TPMode == ReadTPMode::TPIDRURW)
Features.push_back("+read-tp-tpidrurw");
- if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRURO)
+ else if (TPMode == ReadTPMode::TPIDRURO)
Features.push_back("+read-tp-tpidruro");
- if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRPRW)
- Features.push_back("+read-tp-tpidrprw");
const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ);
const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
diff --git a/clang/test/Driver/arm-thread-pointer.c b/clang/test/Driver/arm-thread-pointer.c
index 5521e1865b276..e4bce724be74a 100644
--- a/clang/test/Driver/arm-thread-pointer.c
+++ b/clang/test/Driver/arm-thread-pointer.c
@@ -42,4 +42,4 @@
// RUN: %clang --target=armv7-linux -### -S %s 2>&1 | \
// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
-// ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-tpidruro"
+// ARMv7_THREAD_POINTER_NON: "-target-feature" "+read-tp-tpidruro"
More information about the cfe-commits
mailing list