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

Jon Roelofs via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 13:48:36 PST 2024


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

This is a partial revert of e314622f204a01ffeda59cbe046dd403b01f8b74

rdar://139237593

>From a54e1c1b7ff03fa0f29b0a64e290763d6b085df8 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Fri, 8 Nov 2024 13:46:33 -0800
Subject: [PATCH] [llvm][ARM] Restore the default to -mstrict-align on Apple
 firmwares

This is a partial revert of e314622f204a01ffeda59cbe046dd403b01f8b74

rdar://139237593
---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp | 3 +++
 clang/test/Driver/arm-alignment.c        | 6 ++++++
 2 files changed, 9 insertions(+)

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
 



More information about the cfe-commits mailing list