[clang] d4e2c0b - [Driver] Add options to control workaround for Cortex-A53 Erratum 843419 (#143915)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 16 17:59:21 PDT 2025
Author: Bryan Chan
Date: 2025-06-16T20:59:18-04:00
New Revision: d4e2c0b359ea90236fd1b62791a04fb845f5d9f3
URL: https://github.com/llvm/llvm-project/commit/d4e2c0b359ea90236fd1b62791a04fb845f5d9f3
DIFF: https://github.com/llvm/llvm-project/commit/d4e2c0b359ea90236fd1b62791a04fb845f5d9f3.diff
LOG: [Driver] Add options to control workaround for Cortex-A53 Erratum 843419 (#143915)
Implement the -mfix-cortex-a53-843419 and -mno-fix-cortex-a53-843419 options,
which have been introduced to GCC to allow the user to control the workaround
for the erratum. If the option is enabled (which is the default, unchanged by
this patch), Clang passes --fix-cortex-a53-843419 to the linker when it cannot
ensure that the target is not a Cortex A53, otherwise it doesn't.
See https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mfix-cortex-a53-843419
for information on the GCC options.
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/android-link.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 72d564e1ba0be..8b7708e530b14 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5150,10 +5150,16 @@ def mno_fix_cortex_a72_aes_1655431 : Flag<["-"], "mno-fix-cortex-a72-aes-1655431
Alias<mno_fix_cortex_a57_aes_1742098>;
def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">,
Group<m_aarch64_Features_Group>,
- HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">;
+ HelpText<"Work around Cortex-A53 erratum 835769 (AArch64 only)">;
def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">,
Group<m_aarch64_Features_Group>,
- HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">;
+ HelpText<"Don't work around Cortex-A53 erratum 835769 (AArch64 only)">;
+def mfix_cortex_a53_843419 : Flag<["-"], "mfix-cortex-a53-843419">,
+ Group<m_aarch64_Features_Group>,
+ HelpText<"Work around Cortex-A53 erratum 843419 (AArch64 only)">;
+def mno_fix_cortex_a53_843419 : Flag<["-"], "mno-fix-cortex-a53-843419">,
+ Group<m_aarch64_Features_Group>,
+ HelpText<"Don't work around Cortex-A53 erratum 843419 (AArch64 only)">;
def mmark_bti_property : Flag<["-"], "mmark-bti-property">,
Group<m_aarch64_Features_Group>,
HelpText<"Add .note.gnu.property with BTI to assembly files (AArch64 only)">;
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 1c165bbfe84f5..146dc8bbd5313 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -91,7 +91,9 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--execute-only");
std::string CPU = getCPUName(D, Args, Triple);
- if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+ if (Args.hasFlag(options::OPT_mfix_cortex_a53_843419,
+ options::OPT_mno_fix_cortex_a53_843419, true) &&
+ (CPU.empty() || CPU == "generic" || CPU == "cortex-a53"))
CmdArgs.push_back("--fix-cortex-a53-843419");
}
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 9c68c5c6de2b2..9203bbc91b0bb 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -402,7 +402,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// Most Android ARM64 targets should enable the linker fix for erratum
// 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
- if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily)) {
+ if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily) &&
+ Args.hasFlag(options::OPT_mfix_cortex_a53_843419,
+ options::OPT_mno_fix_cortex_a53_843419, true)) {
std::string CPU = getCPUName(D, Args, Triple);
if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
CmdArgs.push_back("--fix-cortex-a53-843419");
diff --git a/clang/test/Driver/android-link.cpp b/clang/test/Driver/android-link.cpp
index ab7dae5405587..b103263cdd3f0 100644
--- a/clang/test/Driver/android-link.cpp
+++ b/clang/test/Driver/android-link.cpp
@@ -16,6 +16,16 @@
// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
// RUN: %clang --target=aarch64-none-linux-android \
+// RUN: -mno-fix-cortex-a53-843419 \
+// RUN: -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=OVERRIDDEN < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN: -mno-fix-cortex-a53-843419 -mfix-cortex-a53-843419 \
+// RUN: -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=OVERRIDDEN2 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE-16KB < %t %s
@@ -31,6 +41,8 @@
// GENERIC-ARM: --fix-cortex-a53-843419
// CORTEX-A53: --fix-cortex-a53-843419
// CORTEX-A57-NOT: --fix-cortex-a53-843419
+// OVERRIDDEN-NOT: --fix-cortex-a53-843419
+// OVERRIDDEN2: --fix-cortex-a53-843419
// MAX-PAGE-SIZE-4KB: "-z" "max-page-size=4096"
// MAX-PAGE-SIZE-16KB: "-z" "max-page-size=16384"
// NO-MAX-PAGE-SIZE-16KB-NOT: "-z" "max-page-size=16384"
More information about the cfe-commits
mailing list