Index: clang/lib/Driver/ToolChains/PS4CPU.cpp =================================================================== --- clang/lib/Driver/ToolChains/PS4CPU.cpp +++ clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -160,18 +160,12 @@ const bool IsPS5 = TC.getTriple().isPS5(); assert(IsPS4 || IsPS5); + const char *PS4LTOArgs = ""; auto AddCodeGenFlag = [&](Twine Flag) { - const char *Prefix = nullptr; - if (IsPS4 && D.getLTOMode() == LTOK_Thin) - Prefix = "-lto-thin-debug-options="; - else if (IsPS4 && D.getLTOMode() == LTOK_Full) - Prefix = "-lto-debug-options="; + if (IsPS4) + PS4LTOArgs = Args.MakeArgString(Twine(PS4LTOArgs) + " " + Flag); else if (IsPS5) - Prefix = "-plugin-opt="; - else - llvm_unreachable("new LTO mode?"); - - CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag)); + CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + Flag)); }; if (UseLTO) { @@ -185,6 +179,18 @@ if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir)) AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue()); + + if (IsPS4) { + const char *Prefix = nullptr; + if (D.getLTOMode() == LTOK_Thin) + Prefix = "-lto-thin-debug-options="; + else if (D.getLTOMode() == LTOK_Full) + Prefix = "-lto-debug-options="; + else + llvm_unreachable("new LTO mode?"); + + CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + PS4LTOArgs)); + } } if (IsPS5 && UseLTO) { Index: clang/test/Driver/ps4-ps5-linker.c =================================================================== --- clang/test/Driver/ps4-ps5-linker.c +++ clang/test/Driver/ps4-ps5-linker.c @@ -7,8 +7,8 @@ // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s // CHECK-PS4-NOT: -enable-jmc-instrument -// CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument -// CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument +// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section -enable-jmc-instrument" +// CHECK-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section -enable-jmc-instrument" // CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument // CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument @@ -23,7 +23,7 @@ // RUN: %clang --target=x86_64-scei-ps5 -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5 %s // RUN: %clang --target=x86_64-scei-ps5 -flto -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5-LTO %s -// CHECK-DIAG-PS4-THIN-LTO: -lto-thin-debug-options=-crash-diagnostics-dir=mydumps -// CHECK-DIAG-PS4-FULL-LTO: -lto-debug-options=-crash-diagnostics-dir=mydumps +// CHECK-DIAG-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section -crash-diagnostics-dir=mydumps" +// CHECK-DIAG-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section -crash-diagnostics-dir=mydumps" // CHECK-DIAG-PS5-NOT: -plugin-opt=-crash-diagnostics-dir=mydumps // CHECK-DIAG-PS5-LTO: -plugin-opt=-crash-diagnostics-dir=mydumps