[PATCH] Add support for optimization reports.

Diego Novillo dnovillo at google.com
Tue Apr 15 12:10:25 PDT 2014



================
Comment at: include/clang/Basic/DiagnosticFrontendKinds.td:40-42
@@ +39,5 @@
+def note_fe_backend_optimization_remark : Note<"%0">, CatBackend;
+def note_fe_backend_optimization_remark_missing_loc : Note<"optimization "
+  "remarks cannot show source location information (use -gline-tables-only "
+  "-gcolumn-info to enable it)">;
+
----------------
Richard Smith wrote:
> Maybe better phrased as:
> 
>   "use -gline-tables-only -gcolumn-info to track source location information for this optimization remark"

Done.

================
Comment at: lib/CodeGen/CodeGenAction.cpp:433
@@ +432,3 @@
+      return;
+    ComputeDiagRemarkID(Severity, backend_optimization_remark, DiagID);
+    break;
----------------
Richard Smith wrote:
> It looks like we get here (and potentially use the error/warning forms of the remark diagnostic) if the diagnostic severity isn't `DS_Remark`. I don't think this is what we want -- maybe the severity check in `OptimizationRemarkHandler` should be an assert?

OK. This takes me back to my previous version, where I would not try to handle anything other than remarks. This means that the other codes I was forced to add can disappear.

================
Comment at: lib/Frontend/CompilerInvocation.cpp:526
@@ +525,3 @@
+    std::string RegexError;
+    Opts.OptimizationRemarkPattern = new llvm::Regex(Val);
+    if (!Opts.OptimizationRemarkPattern->isValid(RegexError)) {
----------------
Richard Smith wrote:
> Diego Novillo wrote:
> > Richard Smith wrote:
> > > It looks like this is leaked. Maybe use an `llvm::Optional<llvm::Regex>` instead?
> > I tried but llvm::Regex has an explicitly deleted constructor. I'm not sure how to deal with that, so I ended up using regular pointer semantics.
> `llvm::Optional` shouldn't call the `llvm::Regex` default constructor.

Sure, but it's trying to when instantiating CodeGenOptions:

llvm/include/llvm/ADT/Optional.h:39:28: error: call to deleted constructor of 'llvm::Regex'
      new (storage.buffer) T(*O);
                           ^ ~~
llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h:39:7: note: in instantiation of member function 'llvm::Optional<llvm::Regex>::Optional' requested here
class CodeGenOptions : public CodeGenOptionsBase {
      ^
llvm/include/llvm/Support/Regex.h:49:5: note: 'Regex' has been explicitly marked deleted here
    Regex(const Regex &) LLVM_DELETED_FUNCTION;
    ^
1 error generated.


I'm not quite sure how to deal with this.  All I'm doing is:

-  llvm::Regex *OptimizationRemarkPattern;
+  llvm::Optional<llvm::Regex> OptimizationRemarkPattern;

I feel like I'm missing something.


http://reviews.llvm.org/D3226






More information about the cfe-commits mailing list