Skip to content

Commit b20360a

Browse files
authored
clang driver: enable fast unaligned access for Android on RISCV64 (llvm#85704)
Android CTS test already requires fast unaligned access https://android-review.googlesource.com/c/platform/cts/+/2675633
1 parent b754e6f commit b20360a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
167167
Features.push_back("-relax");
168168
}
169169

170+
// Android requires fast unaligned access on RISCV64.
171+
if (Triple.isAndroid())
172+
Features.push_back("+fast-unaligned-access");
173+
170174
// -mstrict-align is default, unless -mno-strict-align is specified.
171175
AddTargetFeature(Args, Features, options::OPT_mno_strict_align,
172176
options::OPT_mstrict_align, "fast-unaligned-access");

clang/test/Driver/riscv-features.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %clang --target=riscv32-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
22
// RUN: %clang --target=riscv64-unknown-elf -### %s -fsyntax-only 2>&1 | FileCheck %s
3-
// RUN: %clang --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT
4-
// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT
3+
// RUN: %clang --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT,FAST-UNALIGNED-ACCESS
4+
// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=ANDROID,DEFAULT,FAST-UNALIGNED-ACCESS
5+
// RUN: %clang -mabi=lp64d --target=riscv64-linux-android -mstrict-align -### %s -fsyntax-only 2>&1 | FileCheck %s -check-prefixes=NO-FAST-UNALIGNED-ACCESS
6+
57

68
// CHECK: fno-signed-char
79

0 commit comments

Comments
 (0)