@@ -4204,8 +4204,8 @@ static void renderDwarfFormat(const Driver &D, const llvm::Triple &T,
4204
4204
4205
4205
static void
4206
4206
renderDebugOptions (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 ,
4209
4209
llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
4210
4210
DwarfFissionKind &DwarfFission) {
4211
4211
if (Args.hasFlag (options::OPT_fdebug_info_for_profiling,
@@ -4282,6 +4282,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
4282
4282
if (const Arg *A = getDwarfNArg (Args))
4283
4283
EmitDwarf = checkDebugInfoOption (A, Args, D, TC);
4284
4284
4285
+ bool EmitCodeView = false ;
4285
4286
if (const Arg *A = Args.getLastArg (options::OPT_gcodeview))
4286
4287
EmitCodeView = checkDebugInfoOption (A, Args, D, TC);
4287
4288
@@ -4518,6 +4519,33 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
4518
4519
4519
4520
renderDwarfFormat (D, T, Args, CmdArgs, EffectiveDWARFVersion);
4520
4521
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 ());
4521
4549
}
4522
4550
4523
4551
static void ProcessVSRuntimeLibrary (const ArgList &Args,
@@ -5697,33 +5725,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
5697
5725
5698
5726
RenderTargetOptions (Triple, Args, KernelOrKext, CmdArgs);
5699
5727
5700
- // These two are potentially updated by AddClangCLArgs.
5701
- llvm::codegenoptions::DebugInfoKind DebugInfoKind =
5702
- llvm::codegenoptions::NoDebugInfo;
5703
- bool EmitCodeView = false ;
5704
-
5705
5728
// Add clang-cl arguments.
5706
5729
types::ID InputType = Input.getType ();
5707
5730
if (D.IsCLMode ())
5708
- AddClangCLArgs (Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView );
5731
+ AddClangCLArgs (Args, InputType, CmdArgs);
5709
5732
5733
+ llvm::codegenoptions::DebugInfoKind DebugInfoKind =
5734
+ llvm::codegenoptions::NoDebugInfo;
5710
5735
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);
5727
5738
5728
5739
// Add the split debug info name to the command lines here so we
5729
5740
// can propagate it to the backend.
@@ -6076,12 +6087,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
6076
6087
if (!ShouldEnableAutolink (Args, TC, JA))
6077
6088
CmdArgs.push_back (" -fno-autolink" );
6078
6089
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
-
6085
6090
Args.AddLastArg (CmdArgs, options::OPT_ftemplate_depth_EQ);
6086
6091
Args.AddLastArg (CmdArgs, options::OPT_foperator_arrow_depth_EQ);
6087
6092
Args.AddLastArg (CmdArgs, options::OPT_fconstexpr_depth_EQ);
@@ -7518,11 +7523,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
7518
7523
CmdArgs.push_back (Args.MakeArgString (Str));
7519
7524
}
7520
7525
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
-
7526
7526
// Add the "-o out -x type src.c" flags last. This is done primarily to make
7527
7527
// the -cc1 command easier to edit when reproducing compiler crashes.
7528
7528
if (Output.getType () == types::TY_Dependencies) {
@@ -7808,9 +7808,7 @@ static EHFlags parseClangCLEHFlags(const Driver &D, const ArgList &Args) {
7808
7808
}
7809
7809
7810
7810
void Clang::AddClangCLArgs (const ArgList &Args, types::ID InputType,
7811
- ArgStringList &CmdArgs,
7812
- llvm::codegenoptions::DebugInfoKind *DebugInfoKind,
7813
- bool *EmitCodeView) const {
7811
+ ArgStringList &CmdArgs) const {
7814
7812
bool isNVPTX = getToolChain ().getTriple ().isNVPTX ();
7815
7813
7816
7814
ProcessVSRuntimeLibrary (Args, CmdArgs);
@@ -7836,31 +7834,8 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
7836
7834
CmdArgs.push_back (Args.MakeArgString (Twine (LangOptions::SSPStrong)));
7837
7835
}
7838
7836
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
-
7851
7837
const Driver &D = getToolChain ().getDriver ();
7852
7838
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
-
7864
7839
EHFlags EH = parseClangCLEHFlags (D, Args);
7865
7840
if (!isNVPTX && (EH.Synch || EH.Asynch )) {
7866
7841
if (types::isCXX (InputType))
0 commit comments