Frontend: support dumping the JIT state

Add a debugging mechanism that enables the JIT to dump the LLVM IR and
object files to enable debugging the JIT.  This makes it easier to debug
the JIT mode failures.  The idea was from Lang Hames!
This commit is contained in:
Saleem Abdulrasool
2020-08-04 15:11:27 -07:00
parent e4f5cc296e
commit 8d21750ef3
5 changed files with 67 additions and 2 deletions

View File

@@ -1448,9 +1448,23 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_disable_concrete_type_metadata_mangled_name_accessors))
Opts.DisableConcreteTypeMetadataMangledNameAccessors = true;
if (Args.hasArg(OPT_use_jit))
if (Args.hasArg(OPT_use_jit)) {
Opts.UseJIT = true;
if (const Arg *A = Args.getLastArg(OPT_dump_jit)) {
llvm::Optional<swift::JITDebugArtifact> artifact =
llvm::StringSwitch<llvm::Optional<swift::JITDebugArtifact>>(A->getValue())
.Case("llvm-ir", JITDebugArtifact::LLVMIR)
.Case("object", JITDebugArtifact::Object)
.Default(None);
if (!artifact) {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
A->getOption().getName(), A->getValue());
return true;
}
Opts.DumpJIT = *artifact;
}
}
for (const Arg *A : Args.filtered(OPT_verify_type_layout)) {
Opts.VerifyTypeLayoutNames.push_back(A->getValue());
}