[clang] 393a1c3 - [PS4][clang] Pass -flto-jobs argument to orbis-ld

Matthew Voss via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 10:33:31 PDT 2023


Author: Matthew Voss
Date: 2023-04-11T10:33:16-07:00
New Revision: 393a1c3b4fcded56a1078d2c01c69af2f2ec05cf

URL: https://github.com/llvm/llvm-project/commit/393a1c3b4fcded56a1078d2c01c69af2f2ec05cf
DIFF: https://github.com/llvm/llvm-project/commit/393a1c3b4fcded56a1078d2c01c69af2f2ec05cf.diff

LOG: [PS4][clang] Pass -flto-jobs argument to orbis-ld

Pass -flto-jobs to orbis-ld correctly.

Differential Revision: https://reviews.llvm.org/D147660

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/PS4CPU.cpp
    clang/test/Driver/lto-jobs.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 71c6b650e1f52..b280abb0d58b7 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -180,6 +180,14 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
       AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
 
+    StringRef Parallelism = getLTOParallelism(Args, D);
+    if (!Parallelism.empty()) {
+      if (IsPS4)
+        AddCodeGenFlag(Twine("-threads=") + Parallelism);
+      else
+        CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + Parallelism));
+    }
+
     if (IsPS4) {
       const char *Prefix = nullptr;
       if (D.getLTOMode() == LTOK_Thin)
@@ -193,12 +201,6 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     }
   }
 
-  if (IsPS5 && UseLTO) {
-    StringRef Parallelism = getLTOParallelism(Args, D);
-    if (!Parallelism.empty())
-      CmdArgs.push_back(Args.MakeArgString("-plugin-opt=jobs=" + Parallelism));
-  }
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
     TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 

diff  --git a/clang/test/Driver/lto-jobs.c b/clang/test/Driver/lto-jobs.c
index 443f8abced788..5402442ce6972 100644
--- a/clang/test/Driver/lto-jobs.c
+++ b/clang/test/Driver/lto-jobs.c
@@ -7,6 +7,11 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s
 //
 // CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5"
+//
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-PS4-LINK-THIN-JOBS-ACTION < %t %s
+//
+// CHECK-PS4-LINK-THIN-JOBS-ACTION: "-lto-thin-debug-options= -generate-arange-section -threads=5"
 
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s


        


More information about the cfe-commits mailing list