[clang] [clang][AMDGPU] Enable module splitting by default (PR #128509)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 24 06:22:27 PST 2025
================
@@ -708,6 +712,34 @@ void amdgpu::getAMDGPUTargetFeatures(const Driver &D,
options::OPT_m_amdgpu_Features_Group);
}
+static unsigned GetFullLTOPartitions(const Driver &D, const ArgList &Args) {
+ const Arg *A = Args.getLastArg(options::OPT_flto_partitions_EQ);
+ // In the absence of an option, use the number of available threads with a cap
+ // at 16 partitions. More than 16 partitions rarely benefits code splitting
+ // and can lead to more empty/small modules each with their own overhead.
+ if (!A)
+ return std::max(16u, llvm::hardware_concurrency().compute_thread_count());
+ int Value;
+ if (StringRef(A->getValue()).getAsInteger(10, Value) || (Value < 1)) {
+ D.Diag(diag::err_drv_invalid_int_value)
+ << A->getAsString(Args) << A->getValue();
+ return 1;
+ }
+
+ return Value;
+}
+
+void amdgpu::addFullLTOPartitionOption(const Driver &D,
+ const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) {
+ // TODO: restrict to gpu-rdc only?
+
+ if (unsigned NumParts = GetFullLTOPartitions(D, Args); NumParts > 1) {
+ CmdArgs.push_back(
+ Args.MakeArgString("--lto-partitions=" + std::to_string(NumParts)));
----------------
arsenm wrote:
This uses Twine, you don't need the to_string
https://github.com/llvm/llvm-project/pull/128509
More information about the cfe-commits
mailing list