From 12da8ef0e318cf1e05c1380de7b98bc5cfa51f42 Mon Sep 17 00:00:00 2001 From: Victor Kingi Date: Wed, 30 Aug 2023 12:45:23 +0000 Subject: [Flang][Driver] Add location and remark option printing to R_Group Diagnostics For each R_Group diagnostic produced, this patch gives more information about it by printing the absolute file path, the line and column number the pass was applied to and finally the remark option that was used. Clang does the same with the exception of printing the relative path rather than absolute path. Depends on D159260. That patch adds support for backend passes while this patch adds remark options to the backend test cases. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D159258 --- flang/lib/Frontend/CompilerInvocation.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 56218cb..81bf89b 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -267,6 +267,21 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, diags, args, clang::driver::options::OPT_Rpass_analysis_EQ, /*remarkOptName=*/"pass-analysis"); + if (opts.getDebugInfo() == llvm::codegenoptions::NoDebugInfo) { + // If the user requested a flag that requires source locations available in + // the backend, make sure that the backend tracks source location + // information. + bool needLocTracking = !opts.OptRecordFile.empty() || + !opts.OptRecordPasses.empty() || + !opts.OptRecordFormat.empty() || + opts.OptimizationRemark.hasValidPattern() || + opts.OptimizationRemarkMissed.hasValidPattern() || + opts.OptimizationRemarkAnalysis.hasValidPattern(); + + if (needLocTracking) + opts.setDebugInfo(llvm::codegenoptions::LocTrackingOnly); + } + if (auto *a = args.getLastArg(clang::driver::options::OPT_save_temps_EQ)) opts.SaveTempsDir = a->getValue(); -- cgit v1.1