Skip to content

Commit c2f52e2

Browse files
brad0zmodem
authored andcommitted
Create strict aligned code for OpenBSD/arm64.
(cherry picked from commit 44613bb)
1 parent d09901e commit c2f52e2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,11 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
370370
V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
371371

372372
if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
373-
options::OPT_munaligned_access))
373+
options::OPT_munaligned_access)) {
374374
if (A->getOption().matches(options::OPT_mno_unaligned_access))
375375
Features.push_back("+strict-align");
376+
} else if (Triple.isOSOpenBSD())
377+
Features.push_back("+strict-align");
376378

377379
if (Args.hasArg(options::OPT_ffixed_x1))
378380
Features.push_back("+reserve-x1");

clang/test/Driver/arm-alignment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
// RUN: %clang -target aarch64-none-gnueabi -mkernel -mno-unaligned-access -### %s 2> %t
8181
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
8282

83+
// RUN: %clang -target aarch64-unknown-openbsd -### %s 2> %t
84+
// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
85+
8386
// CHECK-ALIGNED-ARM: "-target-feature" "+strict-align"
8487
// CHECK-ALIGNED-AARCH64: "-target-feature" "+strict-align"
8588

0 commit comments

Comments
 (0)