[clang] Add -mno-unaligned-access and -mbig-endian to ARM and AArch64 multilib flags (PR #114782)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 07:27:40 PST 2024
https://github.com/simpal01 updated https://github.com/llvm/llvm-project/pull/114782
>From 4a06df9bec87882964e0892b50dd9a81d5e1e6ac Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Mon, 4 Nov 2024 12:02:29 +0000
Subject: [PATCH 1/2] Add -mno-unaligned-access and -mbig-endian to ARM and
AArch64 multilib flags.
---
clang/lib/Driver/ToolChain.cpp | 25 +++++++++++++++++++
.../test/Driver/print-multi-selection-flags.c | 8 ++++++
2 files changed, 33 insertions(+)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index bdf3da0c96adca..dec9af62ad79e4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -230,6 +230,18 @@ static void getAArch64MultilibFlags(const Driver &D,
Result.push_back(BranchProtectionArg->getAsString(Args));
}
+ const Arg *StrictAlignArg =
+ Args.getLastArgNoClaim(options::OPT_mstrict_align, options::OPT_mno_unaligned_access);
+ if (StrictAlignArg) {
+ Result.push_back(StrictAlignArg->getAsString(Args));
+ }
+
+ const Arg *BigEndian =
+ Args.getLastArgNoClaim(options::OPT_mbig_endian);
+ if (BigEndian) {
+ Result.push_back(BigEndian->getAsString(Args));
+ }
+
const Arg *ABIArg = Args.getLastArgNoClaim(options::OPT_mabi_EQ);
if (ABIArg) {
Result.push_back(ABIArg->getAsString(Args));
@@ -287,6 +299,19 @@ static void getARMMultilibFlags(const Driver &D,
if (BranchProtectionArg) {
Result.push_back(BranchProtectionArg->getAsString(Args));
}
+
+ const Arg *StrictAlignArg =
+ Args.getLastArgNoClaim(options::OPT_mstrict_align, options::
+OPT_mno_unaligned_access);
+ if (StrictAlignArg) {
+ Result.push_back(StrictAlignArg->getAsString(Args));
+ }
+
+ const Arg *BigEndian =
+ Args.getLastArgNoClaim(options::OPT_mbig_endian);
+ if (BigEndian) {
+ Result.push_back(BigEndian->getAsString(Args));
+ }
}
static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,
diff --git a/clang/test/Driver/print-multi-selection-flags.c b/clang/test/Driver/print-multi-selection-flags.c
index 4bb62665ad8981..5bf6dca5096a73 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -68,6 +68,14 @@
// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbranch-protection=standard | FileCheck --check-prefix=CHECK-BRANCH-PROTECTION %s
// CHECK-BRANCH-PROTECTION: -mbranch-protection=standard
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mno-unaligned-access | FileCheck --check-prefix=CHECK-NO-UNALIGNED-ACCESS %s
+// CHECK-NO-UNALIGNED-ACCESS: -mno-unaligned-access
+
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=arm-none-eabi -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s
+// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=aarch64-none-elf -mbig-endian | FileCheck --check-prefix=CHECK-BIG-ENDIAN %s
+// CHECK-BIG-ENDIAN: -mbig-endian
+
// RUN: %clang -multi-lib-config=%S/Inputs/multilib/empty.yaml -print-multi-flags-experimental --target=riscv32-none-elf -march=rv32g | FileCheck --check-prefix=CHECK-RV32 %s
// CHECK-RV32: --target=riscv32-unknown-none-elf
// CHECK-RV32: -mabi=ilp32d
>From 5a315d558bda884f1203b8bc5a0dd45c558f45e6 Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath at arm.com>
Date: Mon, 4 Nov 2024 15:20:28 +0000
Subject: [PATCH 2/2] fixup! Fix the clang code format issue
---
clang/lib/Driver/ToolChain.cpp | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index dec9af62ad79e4..652aa9686054c8 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -230,14 +230,13 @@ static void getAArch64MultilibFlags(const Driver &D,
Result.push_back(BranchProtectionArg->getAsString(Args));
}
- const Arg *StrictAlignArg =
- Args.getLastArgNoClaim(options::OPT_mstrict_align, options::OPT_mno_unaligned_access);
+ const Arg *StrictAlignArg = Args.getLastArgNoClaim(
+ options::OPT_mstrict_align, options::OPT_mno_unaligned_access);
if (StrictAlignArg) {
Result.push_back(StrictAlignArg->getAsString(Args));
}
- const Arg *BigEndian =
- Args.getLastArgNoClaim(options::OPT_mbig_endian);
+ const Arg *BigEndian = Args.getLastArgNoClaim(options::OPT_mbig_endian);
if (BigEndian) {
Result.push_back(BigEndian->getAsString(Args));
}
@@ -300,15 +299,13 @@ static void getARMMultilibFlags(const Driver &D,
Result.push_back(BranchProtectionArg->getAsString(Args));
}
- const Arg *StrictAlignArg =
- Args.getLastArgNoClaim(options::OPT_mstrict_align, options::
-OPT_mno_unaligned_access);
+ const Arg *StrictAlignArg = Args.getLastArgNoClaim(
+ options::OPT_mstrict_align, options::OPT_mno_unaligned_access);
if (StrictAlignArg) {
Result.push_back(StrictAlignArg->getAsString(Args));
}
- const Arg *BigEndian =
- Args.getLastArgNoClaim(options::OPT_mbig_endian);
+ const Arg *BigEndian = Args.getLastArgNoClaim(options::OPT_mbig_endian);
if (BigEndian) {
Result.push_back(BigEndian->getAsString(Args));
}
More information about the cfe-commits
mailing list