[clang] 2809308 - Remove small data limit for riscv64.*android triples
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 23:17:38 PDT 2023
Author: AdityaK
Date: 2023-06-14T23:14:03-07:00
New Revision: 280930816fe0ddbf183a077296e32a87be1f8a8a
URL: https://github.com/llvm/llvm-project/commit/280930816fe0ddbf183a077296e32a87be1f8a8a
DIFF: https://github.com/llvm/llvm-project/commit/280930816fe0ddbf183a077296e32a87be1f8a8a.diff
LOG: Remove small data limit for riscv64.*android triples
On Android GP register has been repurposed for SCS so there is no need to have .sdata section.
Reviewers: enh, craig.topper, pirama, kito-cheng, jrtc27
Differential Revision: https://reviews.llvm.org/D151512
Added:
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c
clang/test/Driver/riscv-sdata-warning.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 317036fc62a60..7ee39da952b20 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2096,6 +2096,12 @@ static void SetRISCVSmallDataLimit(const ToolChain &TC, const ArgList &Args,
if (Args.hasArg(options::OPT_G)) {
D.Diag(diag::warn_drv_unsupported_sdata);
}
+ } else if (Triple.isAndroid()) {
+ // GP relaxation is not supported on Android.
+ SmallDataLimit = "0";
+ if (Args.hasArg(options::OPT_G)) {
+ D.Diag(diag::warn_drv_unsupported_sdata);
+ }
} else if (Arg *A = Args.getLastArg(options::OPT_G)) {
SmallDataLimit = A->getValue();
}
diff --git a/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c b/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c
index aa407c17ea05b..27d9af5dbd6fc 100644
--- a/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c
+++ b/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c
@@ -21,6 +21,10 @@
// RUN: | FileCheck %s -check-prefix=RV64-S2G4
// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -msmall-data-threshold=16 -o - \
// RUN: | FileCheck %s -check-prefix=RV64-T16
+// RUN: %clang -target riscv64-linux-android %s -S -emit-llvm -o - \
+// RUN: | FileCheck %s -check-prefix=RV64-ANDROID
+// RUN: %clang -target riscv64-linux-android %s -S -emit-llvm -msmall-data-limit=8 -o - \
+// RUN: | FileCheck %s -check-prefix=RV64-ANDROID
// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -fpic -o - \
// RUN: | FileCheck %s -check-prefix=RV64-PIC
// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -mcmodel=large -o - \
@@ -46,3 +50,6 @@ void test(void) {}
// The value will be passed by module flag instead of target feature.
// RV32-S0-NOT: +small-data-limit=
// RV64-S0-NOT: +small-data-limit=
+
+// RV64-ANDROID-NOT: small-data-limit
+// RV64-ANDROID: !{i32 8, !"SmallDataLimit", i32 0}
diff --git a/clang/test/Driver/riscv-sdata-warning.c b/clang/test/Driver/riscv-sdata-warning.c
index 387bd8b200a88..dbb5f5de9cd81 100644
--- a/clang/test/Driver/riscv-sdata-warning.c
+++ b/clang/test/Driver/riscv-sdata-warning.c
@@ -6,3 +6,7 @@
// RUN: %clang -S --target=riscv64-unknown-elf -mcmodel=large -msmall-data-limit=8 %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-RV64-LARGE-SDATA %s
// CHECK-RV64-LARGE-SDATA: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64
+
+// RUN: %clang -S --target=riscv64-linux-android -msmall-data-limit=8 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-RV64-LARGE-SDATA-ANDROID %s
+// CHECK-RV64-LARGE-SDATA-ANDROID: warning: ignoring '-msmall-data-limit=' with -mcmodel=large for -fpic or RV64
More information about the cfe-commits
mailing list