diff options
author | Diego Novillo <dnovillo@google.com> | 2014-04-16 16:53:41 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2014-04-16 16:53:41 +0000 |
commit | df655013a997cc07dde62316bd4ba0b17fb3c25a (patch) | |
tree | 63c095676c99367a0848540c4b8f6a9be0885799 /llvm/lib/IR/LLVMContext.cpp | |
parent | 4e40d7b07402fdd82686a5eb37d32d3914d61b30 (diff) | |
download | bcm5719-llvm-df655013a997cc07dde62316bd4ba0b17fb3c25a.tar.gz bcm5719-llvm-df655013a997cc07dde62316bd4ba0b17fb3c25a.zip |
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
llvm-svn: 206400
Diffstat (limited to 'llvm/lib/IR/LLVMContext.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContext.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index bd87ef3ab69..588e1217bd4 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -130,6 +130,16 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) { 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 char *PassName, 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)); } //===----------------------------------------------------------------------===// |