[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 16:22:44 PST 2024
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/115546
>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 1/2] [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
>From fc6ed5c2eb64ccc44b28267ff4fcac6456da9614 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Fri, 8 Nov 2024 16:22:29 -0800
Subject: [PATCH 2/2] clang-format
---
clang/lib/Driver/ToolChains/Arch/ARM.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index f7e9cbfe885785..e6ee2317a160cc 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -908,7 +908,8 @@ 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()) {
+ } 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 ||
More information about the cfe-commits
mailing list