-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[AArch64] Disable cortex-a53-835769 when compiling for armv8.1-a or later #170649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Any code compiled with armv8.1-a or later cannot run on a cortex-a53, so does not need to enable the 835769 errata fix. This patch disables the +fix-cortex-a53-835769 feature when the architecture is later than armv8.0-a. The command line flag -mfix_cortex_a53_835769 will still enable it.
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-aarch64 Author: David Green (davemgreen) ChangesAny code compiled with armv8.1-a or later cannot run on a cortex-a53, so does not need to enable the 835769 errata fix. This patch disables the +fix-cortex-a53-835769 feature when the architecture is later than armv8.0-a. The command line flag -mfix_cortex_a53_835769 will still enable it. Full diff: https://github.com/llvm/llvm-project/pull/170649.diff 3 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index d6fb2a57539ed..087ae9201a1a0 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -453,13 +453,18 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
Features.push_back("+fix-cortex-a53-835769");
else
Features.push_back("-fix-cortex-a53-835769");
- } else if (Triple.isAndroid() || Triple.isOHOSFamily()) {
- // Enabled A53 errata (835769) workaround by default on android
- Features.push_back("+fix-cortex-a53-835769");
- } else if (Triple.isOSFuchsia()) {
- std::string CPU = getCPUName(D, Args, Triple);
- if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+ } else if (Extensions.BaseArch &&
+ Extensions.BaseArch->Version.getMajor() == 8 &&
+ Extensions.BaseArch->Version.getMinor() == 0) {
+ if (Triple.isAndroid() || Triple.isOHOSFamily()) {
+ // Enabled A53 errata (835769) workaround by default on android, providing
+ // that the architecture allows running on a cortex-a53.
Features.push_back("+fix-cortex-a53-835769");
+ } else if (Triple.isOSFuchsia()) {
+ std::string CPU = getCPUName(D, Args, Triple);
+ if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+ Features.push_back("+fix-cortex-a53-835769");
+ }
}
if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
diff --git a/clang/test/CodeGen/AArch64/fix-cortex-a53-835769.c b/clang/test/CodeGen/AArch64/fix-cortex-a53-835769.c
index baef74b4c18cc..d5a4d0d085f18 100644
--- a/clang/test/CodeGen/AArch64/fix-cortex-a53-835769.c
+++ b/clang/test/CodeGen/AArch64/fix-cortex-a53-835769.c
@@ -9,6 +9,14 @@
// RUN: | FileCheck --check-prefix=CHECK-YES --check-prefix=CHECK %s
// RUN: %clang -O3 -target aarch64-linux-ohos %s -S -o- \
// RUN: | FileCheck --check-prefix=CHECK-YES --check-prefix=CHECK %s
+// RUN: %clang -O3 --target=aarch64-linux-androideabi -march=armv8.1-a %s -S -o- \
+// RUN: | FileCheck --check-prefix=CHECK-NO --check-prefix=CHECK %s
+// RUN: %clang -O3 -target aarch64-linux-ohos -march=armv8.1-a %s -S -o- \
+// RUN: | FileCheck --check-prefix=CHECK-NO --check-prefix=CHECK %s
+// RUN: %clang -O3 --target=aarch64-linux-androideabi -mcpu=cortex-a55 %s -S -o- \
+// RUN: | FileCheck --check-prefix=CHECK-NO --check-prefix=CHECK %s
+// RUN: %clang -O3 -target aarch64-linux-ohos -mcpu=cortex-a55 %s -S -o- \
+// RUN: | FileCheck --check-prefix=CHECK-NO --check-prefix=CHECK %s
// RUN: %clang -O3 --target=aarch64-linux-androideabi -mfix-cortex-a53-835769 %s -S -o- \
// RUN: | FileCheck --check-prefix=CHECK-YES --check-prefix=CHECK %s
// RUN: %clang -O3 --target=aarch64-linux-androideabi -mno-fix-cortex-a53-835769 %s -S -o- \
diff --git a/clang/test/Driver/aarch64-fix-cortex-a53-835769.c b/clang/test/Driver/aarch64-fix-cortex-a53-835769.c
index 84d8c1dde7a78..757e945a856e0 100644
--- a/clang/test/Driver/aarch64-fix-cortex-a53-835769.c
+++ b/clang/test/Driver/aarch64-fix-cortex-a53-835769.c
@@ -7,9 +7,13 @@
// RUN: %clang --target=aarch64-linux-androideabi %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-YES %s
+// RUN: %clang --target=aarch64-linux-androideabi -march=armv8.1-a %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DEF %s
// RUN: %clang --target=aarch64-fuchsia %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-YES %s
+// RUN: %clang --target=aarch64-fuchsia -march=armv8.1-a %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DEF %s
// RUN: %clang --target=aarch64-fuchsia -mcpu=cortex-a73 %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-DEF %s
|
smithp35
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me. I've added my approval. I'll add some reviewers associated with Android to make sure they are aware.
Will be worth giving them some time to respond.
Any code compiled with armv8.1-a or later cannot run on a cortex-a53, so does not need to enable the 835769 errata fix. This patch disables the +fix-cortex-a53-835769 feature when the architecture is later than armv8.0-a. The command line flag -mfix_cortex_a53_835769 will still enable it.