Index: lib/IR/LLVMContext.cpp =================================================================== --- lib/IR/LLVMContext.cpp +++ lib/IR/LLVMContext.cpp @@ -160,7 +160,14 @@ const Function &Fn, const DebugLoc &DLoc, const Twine &Msg) { - if (pImpl->optimizationRemarksEnabledFor(PassName)) + // Optimization remark diagnostics can be enabled via -Rpass= from + // the front end or -pass-remarks= from opt. If there is a + // diagnostic handler installed, we defer to it to check whether a + // diagnostic should be generated for \p PassName. Otherwise, call + // LLVMContextImpl::optimizationRemarksEnabledFor to check the + // pattern passed in -pass-remarks. + if (pImpl->DiagnosticHandler || + pImpl->optimizationRemarksEnabledFor(PassName)) diagnose(DiagnosticInfoOptimizationRemark(PassName, Fn, DLoc, Msg)); }