[clang] [WIP] clang driver: enable fast unaligned access for Android on RISCV64 (PR #85704)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 19 07:43:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
@llvm/pr-subscribers-clang
Author: AdityaK (hiraditya)
<details>
<summary>Changes</summary>
Android CTS test already requires fast unaligned access https://android-review.googlesource.com/c/platform/cts/+/2675633
Pending testcase
---
Full diff: https://github.com/llvm/llvm-project/pull/85704.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+4)
- (modified) clang/test/Driver/riscv-features.c (+1-1)
``````````diff
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..7db3adb117ae47 100644
--- a/clang/test/Driver/riscv-features.c
+++ b/clang/test/Driver/riscv-features.c
@@ -1,7 +1,7 @@
// 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 -mabi=lp64d --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT,FAST-UNALIGNED-ACCESS
// CHECK: fno-signed-char
``````````
</details>
https://github.com/llvm/llvm-project/pull/85704
More information about the cfe-commits
mailing list