[llvm] r206400 - Allow diagnostic handlers to check for optimization remarks.
Diego Novillo
dnovillo at google.com
Wed Apr 16 09:53:41 PDT 2014
Author: dnovillo
Date: Wed Apr 16 11:53:41 2014
New Revision: 206400
URL: http://llvm.org/viewvc/llvm-project?rev=206400&view=rev
Log:
Allow diagnostic handlers to check for optimization remarks.
Summary:
When optimization remarks are enabled via the driver flag -Rpass, we
should allow the FE diagnostic handler to check if the given pass name
needs a diagnostic.
We were unconditionally checking the pattern defined in opt's
-pass-remarks flag. This was causing the FE to not emit any diagnostics.
Reviewers: qcolombet
CC: llvm-commits
Differential Revision: http://reviews.llvm.org/D3362
Modified:
llvm/trunk/lib/IR/LLVMContext.cpp
Modified: llvm/trunk/lib/IR/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=206400&r1=206399&r2=206400&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContext.cpp Wed Apr 16 11:53:41 2014
@@ -130,6 +130,16 @@ void LLVMContext::diagnose(const Diagnos
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 @@ void LLVMContext::emitOptimizationRemark
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));
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list