[clang] [llvm][ARM] Restore the default to -mstrict-align on Apple firmwares (PR #115546)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 13:49:09 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-arm

Author: Jon Roelofs (jroelofs)

<details>
<summary>Changes</summary>

This is a partial revert of e314622f204a01ffeda59cbe046dd403b01f8b74

rdar://139237593

---
Full diff: https://github.com/llvm/llvm-project/pull/115546.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Arch/ARM.cpp (+3) 
- (modified) clang/test/Driver/arm-alignment.c (+6) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 0489911ecd9dee..f7e9cbfe885785 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -908,6 +908,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
       if (VersionNum < 6 ||
           Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
         Features.push_back("+strict-align");
+    } else if (Triple.getVendor() == llvm::Triple::Apple && Triple.isOSBinFormatMachO()) {
+      // Firmwares on Apple platforms are strict-align by default.
+      Features.push_back("+strict-align");
     } else if (VersionNum < 7 ||
                Triple.getSubArch() ==
                    llvm::Triple::SubArchType::ARMSubArch_v6m ||
diff --git a/clang/test/Driver/arm-alignment.c b/clang/test/Driver/arm-alignment.c
index 8c915477af9aff..b714f80a07dc12 100644
--- a/clang/test/Driver/arm-alignment.c
+++ b/clang/test/Driver/arm-alignment.c
@@ -37,6 +37,12 @@
 // RUN: %clang -target thumbv8m.base-none-gnueabi -### %s 2> %t
 // RUN: FileCheck --check-prefix CHECK-ALIGNED-ARM <%t %s
 
+// RUN: %clang -target armv7em-apple-unknown-macho -mthumb -### %s 2> %t
+// RUN: FileCheck --check-prefix CHECK-ALIGNED-ARM <%t %s
+
+// RUN: %clang -target armv7em-apple-darwin -mthumb -### %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
 

``````````

</details>


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


More information about the cfe-commits mailing list