[clang] [Driver,AArch64] Remove AArch32-specific -m[no-]unaligned-access (PR #85441)

Peter Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 11:15:51 PDT 2024


smithp35 wrote:

> > 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 [developer.arm.com/documentation/dui0472/m/Compiler-Command-line-Options/--unaligned-access----no-unaligned-access](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 [developer.arm.com/documentation/101754/0621/armclang-Reference/armclang-Command-line-Options/-munaligned-access---mno-unaligned-access?lang=en](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.
> 
> Thanks for the comments. The first link gives `--unaligned_access, --no_unaligned_access`, which Clang doesn't support.

Yes the first link is just showing the history of the name. The --unaligned_access became -munaligned-access in clang/gcc for Arm.

> Does the second link mean AArch32 or AArch64? 

It means both.

> I thinks there may be strong motivation to keep both `-m[no-]strict-align` for AArch32 (`-mno-strict-align` was a recent introduction by LoongArch folks) but very little for AArch64 (since GCC has always been rejecting `-m[no-]unaligned-access`).
> 
> 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.

I would just like to keep the `-mno-unaligned-access` alias for AArch64 if at all possible, I've no problem with it not aliasing for all targets. I think existing code coming from GCC or needing to be compatible with GCC will use `-mstrict-align` and `-mno-strict-align` and will be unaffected, however looking at the history this option has been supported in clang for AArch64 for almost 10 years. In our proprietary toolchain we've consistently used `-mno-unaligned-access` for AArch64. As mentioned previously we can always downstream patch that, although it adds yet another item to the migration guide to move people to upstream clang. 

Tracing the history back it looks like AArch64 -mno-unaligned-access support was added in 2014 with
```
commit e5cee260ce07f96a8bc8f82905bc319cc33106fe
Author: Kevin Qin <Kevin.Qin at arm.com>
Date:   Tue May 6 09:51:32 2014 +0000

    [PATCH] [ARM64] Enable alignment control option in front-end for ARM64.

    This patch is to get "-mno-unaligned-access" and "-munaligned-access"
    work in front-end for ARM64 target.

    llvm-svn: 208075
```
Checking our own issue tracker I've found our own internal ticket. Which doesn't add much information, it does have:
```
ARM64 had one back-end option "arm64-strict-align" to enable strict align mode, but didn't support any command line option in front-end. This patch allows users use "-mno-unaligned-access" and "-munaligned-access" in front-end to directly control alignment settings.
```


https://github.com/llvm/llvm-project/pull/85441


More information about the cfe-commits mailing list