@@ -4204,8 +4204,8 @@ static void renderDwarfFormat(const Driver &D, const llvm::Triple &T,
42044204
42054205static void
42064206renderDebugOptions (const ToolChain &TC, const Driver &D, const llvm::Triple &T,
4207- const ArgList &Args, bool EmitCodeView, bool IRInput ,
4208- ArgStringList &CmdArgs ,
4207+ const ArgList &Args, bool IRInput, ArgStringList &CmdArgs ,
4208+ const InputInfo &Output ,
42094209 llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
42104210 DwarfFissionKind &DwarfFission) {
42114211 if (Args.hasFlag (options::OPT_fdebug_info_for_profiling,
@@ -4282,6 +4282,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
42824282 if (const Arg *A = getDwarfNArg (Args))
42834283 EmitDwarf = checkDebugInfoOption (A, Args, D, TC);
42844284
4285+ bool EmitCodeView = false ;
42854286 if (const Arg *A = Args.getLastArg (options::OPT_gcodeview))
42864287 EmitCodeView = checkDebugInfoOption (A, Args, D, TC);
42874288
@@ -4518,6 +4519,33 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
45184519
45194520 renderDwarfFormat (D, T, Args, CmdArgs, EffectiveDWARFVersion);
45204521 RenderDebugInfoCompressionArgs (Args, CmdArgs, D, TC);
4522+
4523+ // This controls whether or not we perform JustMyCode instrumentation.
4524+ if (Args.hasFlag (options::OPT_fjmc, options::OPT_fno_jmc, false )) {
4525+ if (TC.getTriple ().isOSBinFormatELF () || D.IsCLMode ()) {
4526+ if (DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
4527+ CmdArgs.push_back (" -fjmc" );
4528+ else if (D.IsCLMode ())
4529+ D.Diag (clang::diag::warn_drv_jmc_requires_debuginfo) << " /JMC"
4530+ << " '/Zi', '/Z7'" ;
4531+ else
4532+ D.Diag (clang::diag::warn_drv_jmc_requires_debuginfo) << " -fjmc"
4533+ << " -g" ;
4534+ } else {
4535+ D.Diag (clang::diag::warn_drv_fjmc_for_elf_only);
4536+ }
4537+ }
4538+
4539+ // Add in -fdebug-compilation-dir if necessary.
4540+ const char *DebugCompilationDir =
4541+ addDebugCompDirArg (Args, CmdArgs, D.getVFS ());
4542+
4543+ addDebugPrefixMapArg (D, TC, Args, CmdArgs);
4544+
4545+ // Add the output path to the object file for CodeView debug infos.
4546+ if (EmitCodeView && Output.isFilename ())
4547+ addDebugObjectName (Args, CmdArgs, DebugCompilationDir,
4548+ Output.getFilename ());
45214549}
45224550
45234551static void ProcessVSRuntimeLibrary (const ArgList &Args,
@@ -5697,33 +5725,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
56975725
56985726 RenderTargetOptions (Triple, Args, KernelOrKext, CmdArgs);
56995727
5700- // These two are potentially updated by AddClangCLArgs.
5701- llvm::codegenoptions::DebugInfoKind DebugInfoKind =
5702- llvm::codegenoptions::NoDebugInfo;
5703- bool EmitCodeView = false ;
5704-
57055728 // Add clang-cl arguments.
57065729 types::ID InputType = Input.getType ();
57075730 if (D.IsCLMode ())
5708- AddClangCLArgs (Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView );
5731+ AddClangCLArgs (Args, InputType, CmdArgs);
57095732
5733+ llvm::codegenoptions::DebugInfoKind DebugInfoKind =
5734+ llvm::codegenoptions::NoDebugInfo;
57105735 DwarfFissionKind DwarfFission = DwarfFissionKind::None;
5711- renderDebugOptions (TC, D, RawTriple, Args, EmitCodeView,
5712- types::isLLVMIR (InputType), CmdArgs, DebugInfoKind,
5713- DwarfFission);
5714-
5715- // This controls whether or not we perform JustMyCode instrumentation.
5716- if (Args.hasFlag (options::OPT_fjmc, options::OPT_fno_jmc, false )) {
5717- if (TC.getTriple ().isOSBinFormatELF ()) {
5718- if (DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
5719- CmdArgs.push_back (" -fjmc" );
5720- else
5721- D.Diag (clang::diag::warn_drv_jmc_requires_debuginfo) << " -fjmc"
5722- << " -g" ;
5723- } else {
5724- D.Diag (clang::diag::warn_drv_fjmc_for_elf_only);
5725- }
5726- }
5736+ renderDebugOptions (TC, D, RawTriple, Args, types::isLLVMIR (InputType),
5737+ CmdArgs, Output, DebugInfoKind, DwarfFission);
57275738
57285739 // Add the split debug info name to the command lines here so we
57295740 // can propagate it to the backend.
@@ -6076,12 +6087,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
60766087 if (!ShouldEnableAutolink (Args, TC, JA))
60776088 CmdArgs.push_back (" -fno-autolink" );
60786089
6079- // Add in -fdebug-compilation-dir if necessary.
6080- const char *DebugCompilationDir =
6081- addDebugCompDirArg (Args, CmdArgs, D.getVFS ());
6082-
6083- addDebugPrefixMapArg (D, TC, Args, CmdArgs);
6084-
60856090 Args.AddLastArg (CmdArgs, options::OPT_ftemplate_depth_EQ);
60866091 Args.AddLastArg (CmdArgs, options::OPT_foperator_arrow_depth_EQ);
60876092 Args.AddLastArg (CmdArgs, options::OPT_fconstexpr_depth_EQ);
@@ -7518,11 +7523,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
75187523 CmdArgs.push_back (Args.MakeArgString (Str));
75197524 }
75207525
7521- // Add the output path to the object file for CodeView debug infos.
7522- if (EmitCodeView && Output.isFilename ())
7523- addDebugObjectName (Args, CmdArgs, DebugCompilationDir,
7524- Output.getFilename ());
7525-
75267526 // Add the "-o out -x type src.c" flags last. This is done primarily to make
75277527 // the -cc1 command easier to edit when reproducing compiler crashes.
75287528 if (Output.getType () == types::TY_Dependencies) {
@@ -7808,9 +7808,7 @@ static EHFlags parseClangCLEHFlags(const Driver &D, const ArgList &Args) {
78087808}
78097809
78107810void Clang::AddClangCLArgs (const ArgList &Args, types::ID InputType,
7811- ArgStringList &CmdArgs,
7812- llvm::codegenoptions::DebugInfoKind *DebugInfoKind,
7813- bool *EmitCodeView) const {
7811+ ArgStringList &CmdArgs) const {
78147812 bool isNVPTX = getToolChain ().getTriple ().isNVPTX ();
78157813
78167814 ProcessVSRuntimeLibrary (Args, CmdArgs);
@@ -7836,31 +7834,8 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
78367834 CmdArgs.push_back (Args.MakeArgString (Twine (LangOptions::SSPStrong)));
78377835 }
78387836
7839- // Emit CodeView if -Z7 or -gline-tables-only are present.
7840- if (Arg *DebugInfoArg = Args.getLastArg (options::OPT__SLASH_Z7,
7841- options::OPT_gline_tables_only)) {
7842- *EmitCodeView = true ;
7843- if (DebugInfoArg->getOption ().matches (options::OPT__SLASH_Z7))
7844- *DebugInfoKind = llvm::codegenoptions::DebugInfoConstructor;
7845- else
7846- *DebugInfoKind = llvm::codegenoptions::DebugLineTablesOnly;
7847- } else {
7848- *EmitCodeView = false ;
7849- }
7850-
78517837 const Driver &D = getToolChain ().getDriver ();
78527838
7853- // This controls whether or not we perform JustMyCode instrumentation.
7854- if (Args.hasFlag (options::OPT__SLASH_JMC, options::OPT__SLASH_JMC_,
7855- /* Default=*/ false )) {
7856- if (*EmitCodeView &&
7857- *DebugInfoKind >= llvm::codegenoptions::DebugInfoConstructor)
7858- CmdArgs.push_back (" -fjmc" );
7859- else
7860- D.Diag (clang::diag::warn_drv_jmc_requires_debuginfo) << " /JMC"
7861- << " '/Zi', '/Z7'" ;
7862- }
7863-
78647839 EHFlags EH = parseClangCLEHFlags (D, Args);
78657840 if (!isNVPTX && (EH.Synch || EH.Asynch )) {
78667841 if (types::isCXX (InputType))
0 commit comments