forked from OSchip/llvm-project
[Driver][PS4] pass -fcrash-diagnostics-dir to LTO
Also refactor the existing code a little bit. Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D134673
This commit is contained in:
parent
5839fb6d25
commit
55cd5bc509
|
@ -158,34 +158,32 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
const bool IsPS4 = TC.getTriple().isPS4();
|
||||
const bool IsPS5 = TC.getTriple().isPS5();
|
||||
assert(IsPS4 || IsPS5);
|
||||
(void)IsPS5;
|
||||
|
||||
ArgStringList DbgOpts;
|
||||
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=";
|
||||
else if (IsPS5)
|
||||
Prefix = "-plugin-opt=";
|
||||
else
|
||||
llvm_unreachable("new LTO mode?");
|
||||
|
||||
// This tells LTO to perform JustMyCode instrumentation.
|
||||
if (UseLTO && UseJMC)
|
||||
DbgOpts.push_back("-enable-jmc-instrument");
|
||||
|
||||
// We default to creating the arange section, but LTO does not. Enable it
|
||||
// here.
|
||||
if (UseLTO)
|
||||
DbgOpts.push_back("-generate-arange-section");
|
||||
CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag));
|
||||
};
|
||||
|
||||
if (UseLTO) {
|
||||
if (IsPS4) {
|
||||
StringRef F = (D.getLTOMode() == LTOK_Thin) ?
|
||||
"-lto-thin-debug-options=" : "-lto-debug-options=";
|
||||
F = makeArgString(Args, F.data(), DbgOpts.front(), "");
|
||||
DbgOpts.erase(DbgOpts.begin());
|
||||
for (auto X : DbgOpts)
|
||||
F = makeArgString(Args, F.data(), " ", X);
|
||||
CmdArgs.push_back(F.data());
|
||||
} else {
|
||||
for (auto D : DbgOpts) {
|
||||
CmdArgs.push_back("-mllvm");
|
||||
CmdArgs.push_back(D);
|
||||
}
|
||||
}
|
||||
// We default to creating the arange section, but LTO does not. Enable it
|
||||
// here.
|
||||
AddCodeGenFlag("-generate-arange-section");
|
||||
|
||||
// This tells LTO to perform JustMyCode instrumentation.
|
||||
if (UseJMC)
|
||||
AddCodeGenFlag("-enable-jmc-instrument");
|
||||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
|
||||
AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
|
||||
}
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
|
||||
|
|
|
@ -375,8 +375,8 @@
|
|||
//
|
||||
|
||||
// LDGARANGE: {{".*ld.*"}} {{.*}}
|
||||
// LDGARANGE-NOT: "-generate-arange-section"
|
||||
// LLDGARANGE: {{".*lld.*"}} {{.*}} "-generate-arange-section"
|
||||
// LDGARANGE-NOT: "-plugin-opt=-generate-arange-section"
|
||||
// LLDGARANGE: {{".*lld.*"}} {{.*}} "-plugin-opt=-generate-arange-section"
|
||||
// SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-thin-debug-options=-generate-arange-section"
|
||||
// SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-debug-options=-generate-arange-section"
|
||||
|
||||
|
|
|
@ -7,14 +7,23 @@
|
|||
// 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-PS5-NOT: "-enable-jmc-instrument"
|
||||
|
||||
// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
|
||||
// CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
|
||||
// CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
|
||||
|
||||
// Check the default library name.
|
||||
// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
|
||||
// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
|
||||
|
||||
// Test the driver's control over the -fcrash-diagnostics-dir behavior with linker flags.
|
||||
|
||||
// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS4-THIN-LTO %s
|
||||
// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS4-FULL-LTO %s
|
||||
// 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-PS5-NOT: -plugin-opt=-crash-diagnostics-dir=mydumps
|
||||
// CHECK-DIAG-PS5-LTO: -plugin-opt=-crash-diagnostics-dir=mydumps
|
Loading…
Reference in New Issue