-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Driver,AArch64] Remove AArch32-specific -m[no-]unaligned-access #85441
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
[Driver,AArch64] Remove AArch32-specific -m[no-]unaligned-access #85441
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Fangrui Song (MaskRay) ChangesFollow-up to #85350: GCC only supports -m[no-]strict-align for AArch64 Since the behavior has been longtime for ARM, keep ARM unchanged but Full diff: https://github.com/llvm/llvm-project/pull/85441.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e1743368b157e0..a9e3be617d0e74 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -191,7 +191,7 @@ Removed Compiler Flags
-------------------------
- The ``-freroll-loops`` flag has been removed. It had no effect since Clang 13.
-- ``-m[no-]unaligned-access`` is removed for RISC-V and LoongArch.
+- ``-m[no-]unaligned-access`` is removed for AArch64, RISC-V, and LoongArch.
``-m[no-]strict-align``, also supported by GCC, should be used instead.
(`#85350 <https://github.com/llvm/llvm-project/pull/85350>`_.)
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 3e6e29584df3ac..cac5ab5f369e57 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -321,13 +321,8 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
}
}
- if (Arg *A = Args.getLastArg(
- options::OPT_mstrict_align, options::OPT_mno_strict_align,
- options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
- if (A->getOption().matches(options::OPT_mstrict_align) ||
- A->getOption().matches(options::OPT_mno_unaligned_access))
- Features.push_back("+strict-align");
- } else if (Triple.isOSOpenBSD())
+ if (Args.hasFlag(options::OPT_mstrict_align, options::OPT_mno_strict_align,
+ Triple.isOSOpenBSD()))
Features.push_back("+strict-align");
if (Args.hasArg(options::OPT_ffixed_x1))
diff --git a/clang/test/Driver/arm-alignment.c b/clang/test/Driver/arm-alignment.c
index 8c915477af9aff..f7db966f9818ab 100644
--- a/clang/test/Driver/arm-alignment.c
+++ b/clang/test/Driver/arm-alignment.c
@@ -37,19 +37,13 @@
// RUN: %clang -target thumbv8m.base-none-gnueabi -### %s 2> %t
// RUN: FileCheck --check-prefix CHECK-ALIGNED-ARM <%t %s
-// RUN: %clang --target=aarch64 -munaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -mstrict-align -munaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -mno-unaligned-access -munaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
+// RUN: not %clang --target=aarch64 -munaligned-access -mno-unaligned-access -### %s 2>&1 | FileCheck %s --check-prefix=ERR
+// ERR: error: unsupported option '-munaligned-access' for target 'aarch64'
+// ERR: error: unsupported option '-mno-unaligned-access' for target 'aarch64'
// CHECK-UNALIGNED-ARM-NOT: "-target-feature" "+strict-align"
// CHECK-UNALIGNED-AARCH64-NOT: "-target-feature" "+strict-align"
-
// RUN: %clang -target arm-none-gnueabi -mno-unaligned-access -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
@@ -83,21 +77,9 @@
// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
-// RUN: %clang --target=aarch64 -mno-unaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
// RUN: %clang --target=aarch64 -mstrict-align -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-// RUN: %clang --target=aarch64 -munaligned-access -mno-unaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -munaligned-access -mstrict-align -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -mkernel -mno-unaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
// RUN: %clang -target aarch64-unknown-openbsd -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
|
@llvm/pr-subscribers-backend-aarch64 Author: Fangrui Song (MaskRay) ChangesFollow-up to #85350: GCC only supports -m[no-]strict-align for AArch64 Since the behavior has been longtime for ARM, keep ARM unchanged but Full diff: https://github.com/llvm/llvm-project/pull/85441.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e1743368b157e0..a9e3be617d0e74 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -191,7 +191,7 @@ Removed Compiler Flags
-------------------------
- The ``-freroll-loops`` flag has been removed. It had no effect since Clang 13.
-- ``-m[no-]unaligned-access`` is removed for RISC-V and LoongArch.
+- ``-m[no-]unaligned-access`` is removed for AArch64, RISC-V, and LoongArch.
``-m[no-]strict-align``, also supported by GCC, should be used instead.
(`#85350 <https://github.com/llvm/llvm-project/pull/85350>`_.)
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 3e6e29584df3ac..cac5ab5f369e57 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -321,13 +321,8 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
}
}
- if (Arg *A = Args.getLastArg(
- options::OPT_mstrict_align, options::OPT_mno_strict_align,
- options::OPT_mno_unaligned_access, options::OPT_munaligned_access)) {
- if (A->getOption().matches(options::OPT_mstrict_align) ||
- A->getOption().matches(options::OPT_mno_unaligned_access))
- Features.push_back("+strict-align");
- } else if (Triple.isOSOpenBSD())
+ if (Args.hasFlag(options::OPT_mstrict_align, options::OPT_mno_strict_align,
+ Triple.isOSOpenBSD()))
Features.push_back("+strict-align");
if (Args.hasArg(options::OPT_ffixed_x1))
diff --git a/clang/test/Driver/arm-alignment.c b/clang/test/Driver/arm-alignment.c
index 8c915477af9aff..f7db966f9818ab 100644
--- a/clang/test/Driver/arm-alignment.c
+++ b/clang/test/Driver/arm-alignment.c
@@ -37,19 +37,13 @@
// RUN: %clang -target thumbv8m.base-none-gnueabi -### %s 2> %t
// RUN: FileCheck --check-prefix CHECK-ALIGNED-ARM <%t %s
-// RUN: %clang --target=aarch64 -munaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -mstrict-align -munaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -mno-unaligned-access -munaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s
+// RUN: not %clang --target=aarch64 -munaligned-access -mno-unaligned-access -### %s 2>&1 | FileCheck %s --check-prefix=ERR
+// ERR: error: unsupported option '-munaligned-access' for target 'aarch64'
+// ERR: error: unsupported option '-mno-unaligned-access' for target 'aarch64'
// CHECK-UNALIGNED-ARM-NOT: "-target-feature" "+strict-align"
// CHECK-UNALIGNED-AARCH64-NOT: "-target-feature" "+strict-align"
-
// RUN: %clang -target arm-none-gnueabi -mno-unaligned-access -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
@@ -83,21 +77,9 @@
// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
-// RUN: %clang --target=aarch64 -mno-unaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
// RUN: %clang --target=aarch64 -mstrict-align -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-// RUN: %clang --target=aarch64 -munaligned-access -mno-unaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -munaligned-access -mstrict-align -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
-// RUN: %clang --target=aarch64 -mkernel -mno-unaligned-access -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
-
// RUN: %clang -target aarch64-unknown-openbsd -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
|
If Apple platforms need this option, I can keep it recognized but only for Apple. For ELF platforms, we should remove the GCC-unsupported-and-rejected aliases, so that software written for one compiler will not unnecessarily have portability problems for the other. |
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.
If possible I would prefer to keep -m[no-]unaligned-access for AArch64.
The history of this option name derives from Arm's proprietary compiler https://developer.arm.com/documentation/dui0472/m/Compiler-Command-line-Options/--unaligned-access----no-unaligned-access which has been carried forward for the LLVM based Arm Compiler https://developer.arm.com/documentation/101754/0621/armclang-Reference/armclang-Command-line-Options/-munaligned-access---mno-unaligned-access?lang=en
Yes the proprietary compiler can always put this back as a downstream change. However we are trying to introduce more use of upstream clang and it would help migration of these projects if they didn't need to change.
I don't see any projects that use |
Thanks for the comments. The first link gives Part of the motivation behind the change and #85350 is to discourage future ports (including existing RISC-V/LoongArch) to create aliases for architectures that don't need the aliases. |
Yes the first link is just showing the history of the name. The --unaligned_access became -munaligned-access in clang/gcc for Arm.
It means both.
I would just like to keep the Tracing the history back it looks like AArch64 -mno-unaligned-access support was added in 2014 with
Checking our own issue tracker I've found our own internal ticket. Which doesn't add much information, it does have:
|
Thanks for the comment. I'll abandon this. |
Follow-up to #85350: GCC only supports -m[no-]strict-align for AArch64
and rejects adding -m[no-]unaligned-access aliases. We inapropriated
supported -m[no-]unaligned-access as aliases for non-AArch64 due to an
early design issue (a146a48).
Since the behavior has been longtime for ARM, keep ARM unchanged but
tighten up the behavior for AArch64.