[clang] clang driver: enable fast unaligned access for Android on RISCV64 (PR #85704)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 20 08:43:11 PDT 2024
https://github.com/hiraditya updated https://github.com/llvm/llvm-project/pull/85704
>From a930e01740cd574905922fab9de850974940f6b3 Mon Sep 17 00:00:00 2001
From: AdityaK <hiraditya at msn.com>
Date: Mon, 18 Mar 2024 14:09:13 -0700
Subject: [PATCH] clang driver: enable fast unaligned access for Android on
RISCV64
Android CTS test already requires fast unaligned access
https://android-review.googlesource.com/c/platform/cts/+/2675633
---
clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 4 ++++
clang/test/Driver/riscv-features.c | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 5165bccc6d7e30..b1dd7c4372d475 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -167,6 +167,10 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
Features.push_back("-relax");
}
+ // Android requires fast unaligned access on RISCV64.
+ if (Triple.isAndroid())
+ Features.push_back("+fast-unaligned-access");
+
// -mstrict-align is default, unless -mno-strict-align is specified.
AddTargetFeature(Args, Features, options::OPT_mno_strict_align,
options::OPT_mstrict_align, "fast-unaligned-access");
diff --git a/clang/test/Driver/riscv-features.c b/clang/test/Driver/riscv-features.c
index fe74ac773ef8ca..052956dfa2dcea 100644
--- a/clang/test/Driver/riscv-features.c
+++ b/clang/test/Driver/riscv-features.c
@@ -1,7 +1,9 @@
// RUN: %clang --target=riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
// RUN: %clang --target=riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT
-// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT
+// RUN: %clang --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT,FAST-UNALIGNED-ACCESS
+// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT,FAST-UNALIGNED-ACCESS
+// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -mstrict-align -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=NO-FAST-UNALIGNED-ACCESS
+
// CHECK: fno-signed-char
More information about the cfe-commits
mailing list