[PATCH] D57497: [RISCV] Passing -G value to RISCV backend
Shiva Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 30 21:48:56 PST 2019
shiva0217 created this revision.
shiva0217 added reviewers: asb, apazos.
Herald added subscribers: jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
Passing -G value to RISCVELFTargetObjectFile by -riscv-ssection-threshold flag,
So the backend can set small data section threshold by the value.
Repository:
rC Clang
https://reviews.llvm.org/D57497
Files:
lib/Driver/ToolChains/Clang.cpp
test/Driver/riscv-features.c
Index: test/Driver/riscv-features.c
===================================================================
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -11,3 +11,9 @@
// NO-RELAX: "-target-feature" "-relax"
// DEFAULT-NOT: "-target-feature" "+relax"
// DEFAULT-NOT: "-target-feature" "-relax"
+
+/// -G
+// RUN: %clang -target riscv32 -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-RISCV-G %s
+// CHECK-RISCV-G: "-mllvm" "-riscv-ssection-threshold=16"
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1799,6 +1799,14 @@
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName);
+
+ // Passing small data section limitaion if has -G flag.
+ if (Arg *A = Args.getLastArg(options::OPT_G)) {
+ StringRef v = A->getValue();
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back(Args.MakeArgString("-riscv-ssection-threshold=" + v));
+ A->claim();
+ }
}
void Clang::AddSparcTargetArgs(const ArgList &Args,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57497.184449.patch
Type: text/x-patch
Size: 1122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190131/0e8dbe7e/attachment.bin>
More information about the cfe-commits
mailing list