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,
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,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits