[clang] 34ebfab - [llvm][ARM] Restore the default to -mstrict-align on Apple firmwares (#115546)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 13:54:24 PST 2024
Author: Jon Roelofs
Date: 2024-11-15T13:54:21-08:00
New Revision: 34ebfabc34476b73a3d65d3bd046c35ffab411c4
URL: https://github.com/llvm/llvm-project/commit/34ebfabc34476b73a3d65d3bd046c35ffab411c4
DIFF: https://github.com/llvm/llvm-project/commit/34ebfabc34476b73a3d65d3bd046c35ffab411c4.diff
LOG: [llvm][ARM] Restore the default to -mstrict-align on Apple firmwares (#115546)
This is a partial revert of e314622f204a01ffeda59cbe046dd403b01f8b74
rdar://139237593
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-alignment.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 0489911ecd9dee..e6ee2317a160cc 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -908,6 +908,10 @@ 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