Add support for optimization reports.

Summary:
This patch adds a new flag -Rpass=. The flag indicates the name
of the optimization pass that should emit remarks stating when it
made a transformation to the code.

This implements the design I proposed in:

https://docs.google.com/document/d/1FYUatSjZZO-zmFBxjOiuOzAy9mhHA8hqdvklZv68WuQ/edit?usp=sharing

Other changes:
- Add DiagnosticIDs::isRemark(). Use it in printDiagnosticOptions to
  print "-R" instead of "-W" in the diagnostic message.

- In BackendConsumer::OptimizationRemarkHandler, get a SourceLocation
  object out of the file name, line and column number. Use that location
  in the call to Diags.Report().

- When -Rpass is used without debug info a note is emitted alerting
  the user that they need to use -gline-tables-only -gcolumn-info to
  get this information.

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3226

llvm-svn: 206401
This commit is contained in:
Diego Novillo
2014-04-16 16:54:24 +00:00
parent df655013a9
commit 829b170048
13 changed files with 114 additions and 2 deletions

View File

@@ -520,6 +520,17 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DependentLibraries = Args.getAllArgValues(OPT_dependent_lib);
if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) {
StringRef Val = A->getValue();
std::string RegexError;
Opts.OptimizationRemarkPattern = std::make_shared<llvm::Regex>(Val);
if (!Opts.OptimizationRemarkPattern->isValid(RegexError)) {
Diags.Report(diag::err_drv_optimization_remark_pattern)
<< RegexError << A->getAsString(Args);
Opts.OptimizationRemarkPattern.reset();
}
}
return Success;
}