[PATCH] Allow diagnostic handlers to check for optimization remarks.

Diego Novillo dnovillo at google.com
Tue Apr 15 15:41:40 PDT 2014


  I did something slightly different. Setting a new function pointer
  just for the optimization remarks seemed like overkill. I am doing
  something similar to what is done in the front end.

  The backend handler checks whether it's dealing with an optimization
  remark. If so, it further checks the regexp passed in -pass-remarks.
  This seemed less invasive than the additional function pointer.

Hi qcolombet,

http://reviews.llvm.org/D3362

CHANGE SINCE LAST DIFF
  http://reviews.llvm.org/D3362?vs=8490&id=8547#toc

Files:
  lib/IR/LLVMContext.cpp

Index: lib/IR/LLVMContext.cpp
===================================================================
--- lib/IR/LLVMContext.cpp
+++ lib/IR/LLVMContext.cpp
@@ -130,6 +130,16 @@
     pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext);
     return;
   }
+
+  // Optimization remarks are selective. They need to check whether
+  // the regexp pattern, passed via -pass-remarks, matches the name
+  // of the pass that is emitting the diagnostic. If there is no match,
+  // ignore the diagnostic and return.
+  if (DI.getKind() == llvm::DK_OptimizationRemark &&
+      !pImpl->optimizationRemarksEnabledFor(
+          cast<DiagnosticInfoOptimizationRemark>(DI).getPassName()))
+    return;
+
   // Otherwise, print the message with a prefix based on the severity.
   std::string MsgStorage;
   raw_string_ostream Stream(MsgStorage);
@@ -160,8 +170,7 @@
                                          const Function &Fn,
                                          const DebugLoc &DLoc,
                                          const Twine &Msg) {
-  if (pImpl->optimizationRemarksEnabledFor(PassName))
-    diagnose(DiagnosticInfoOptimizationRemark(PassName, Fn, DLoc, Msg));
+  diagnose(DiagnosticInfoOptimizationRemark(PassName, Fn, DLoc, Msg));
 }
 
 //===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3362.2.patch
Type: text/x-patch
Size: 1327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140415/da51eda9/attachment.bin>


More information about the llvm-commits mailing list