[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 18:12:47 PST 2024
================
@@ -886,28 +886,16 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
} else {
// Assume pre-ARMv6 doesn't support unaligned accesses.
//
- // ARMv6 may or may not support unaligned accesses depending on the
- // SCTLR.U bit, which is architecture-specific. We assume ARMv6
- // Darwin and NetBSD targets support unaligned accesses, and others don't.
+ // Assume ARMv6+ supports unaligned accesses, except Armv6-M, and Armv8-M
+ // without the Main Extension. This aligns with the default behavior of
+ // ARM's downstream versions of GCC and Clang
//
- // ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit
- // which raises an alignment fault on unaligned accesses. Linux
- // defaults this bit to 0 and handles it as a system-wide (not
- // per-process) setting. It is therefore safe to assume that ARMv7+
- // Linux targets support unaligned accesses. The same goes for NaCl
- // and Windows.
- //
- // The above behavior is consistent with GCC.
+ // Users can disable behavior via -mno-unaliged-access.
int VersionNum = getARMSubArchVersionNumber(Triple);
- if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
- if (VersionNum < 6 ||
- Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
- Features.push_back("+strict-align");
- } else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
- Triple.isOSWindows()) {
- if (VersionNum < 7)
- Features.push_back("+strict-align");
- } else
+ if (VersionNum < 6 ||
+ Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m ||
+ Triple.getSubArch() ==
+ llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
----------------
efriedma-quic wrote:
I don't have a strong opinion on how we treat v6a. I guess I'd lean towards being conservative, I guess, like what you wrote?
https://github.com/llvm/llvm-project/pull/82400
More information about the cfe-commits
mailing list