================
@@ -895,20 +895,18 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
     // 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.
+    // and Windows. However, ARM's forks of GCC and Clang both allow
+    // unaligned accesses by default for all targets. We follow this
+    // behavior and enable unaligned accesses by default for ARMv7+ targets.
+    // Users can disable behavior via compiler options (-mno-unaliged-access).
+    // See https://github.com/llvm/llvm-project/issues/59560 for more info.
     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)
+    } else if (VersionNum < 7)
----------------
smithp35 wrote:

I don't think this is quite right. Armv6 (but not Armv6-M) can support 
unaligned accesses. V8-M.main (logical extension of Armv7-M) supports unaligned 
accesses but v8-M.base (logical extension of Armv6-M) does not. Yet both will 
get VersionNum of 8.

Although not quite at the same point Arm's downstream fork uses
```
if (VersionNum < 6 ||
          Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m ||
          Triple.getSubArch() == 
llvm::Triple::SubArchType::ARMSubArch_v8m_baseline) {
        Features.push_back("+strict-align");
```
I don't suppose many care about Arm v6 but we'll need to make sure that 
strict-align is added for v8-m.base.

Arm's fork of clang mentions this in the documentation for 
-mno-unaligned-access 
https://developer.arm.com/documentation/101754/0621/armclang-Reference/armclang-Command-line-Options/-munaligned-access---mno-unaligned-access
 



 

https://github.com/llvm/llvm-project/pull/82400
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to