[clang] [clang][driver] Allow unaligned access on ARMv7 and higher by default (PR #82400)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 20 12:13:10 PST 2024


efriedma-quic wrote:

Unaligned accesses require that SCTLR.A is 0, SCTLR.U is 1, and that the memory in question is configured as "normal" memory.  Almost all operating systems do in fact configure their registers/memory this way, but on baremetal it's not really a safe assumption. Changing the default here is basically guaranteed to break someone's code.

We could make the value judgement that the performance gain outweighs breaking someone's code. Disabled unaligned access is a performance hit users have a hard time discovering; incorrectly enabled unaligned access will generate an obvious alignment fault on v7 and up.

On pre-v7 processors, you can get the old "rotate" behavior instead of a fault.  This is controlled by SCTLR.U on v6, but I don't think there's any reason to expect the bit is configured the "right" way on baremetal.  So changing the default for v6 is a bit more dubious.

The tradeoffs might be a bit different for M-class processors; I think unaligned access works by default there (except for v6m and v8m.baseline).

This change needs a release note.

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


More information about the cfe-commits mailing list