diff options
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/DiagnosticInfo.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/IR/LLVMContext.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.h | 5 |
3 files changed, 29 insertions, 1 deletions
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index f46f0fd..50fe682 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -393,6 +393,17 @@ std::string DiagnosticInfoOptimizationBase::getMsg() const { return OS.str(); } +DiagnosticInfoMisExpect::DiagnosticInfoMisExpect(const Instruction *Inst, + Twine &Msg) + : DiagnosticInfoWithLocationBase(DK_MisExpect, DS_Warning, + *Inst->getParent()->getParent(), + Inst->getDebugLoc()), + Msg(Msg) {} + +void DiagnosticInfoMisExpect::print(DiagnosticPrinter &DP) const { + DP << getLocationStr() << ": " << getMsg(); +} + void OptimizationRemarkAnalysisFPCommute::anchor() {} void OptimizationRemarkAnalysisAliasing::anchor() {} diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index f4e917c..df4a007 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -138,10 +138,22 @@ bool LLVMContext::getDiagnosticsHotnessRequested() const { void LLVMContext::setDiagnosticsHotnessThreshold(Optional<uint64_t> Threshold) { pImpl->DiagnosticsHotnessThreshold = Threshold; } - +void LLVMContext::setMisExpectWarningRequested(bool Requested) { + pImpl->MisExpectWarningRequested = Requested; +} +bool LLVMContext::getMisExpectWarningRequested() const { + return pImpl->MisExpectWarningRequested; +} uint64_t LLVMContext::getDiagnosticsHotnessThreshold() const { return pImpl->DiagnosticsHotnessThreshold.getValueOr(UINT64_MAX); } +void LLVMContext::setDiagnosticsMisExpectTolerance( + Optional<uint64_t> Tolerance) { + pImpl->DiagnosticsMisExpectTolerance = Tolerance; +} +uint64_t LLVMContext::getDiagnosticsMisExpectTolerance() const { + return pImpl->DiagnosticsMisExpectTolerance.getValueOr(0); +} bool LLVMContext::isDiagnosticsHotnessThresholdSetFromPSI() const { return !pImpl->DiagnosticsHotnessThreshold.hasValue(); diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index b87d285..0b39029 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -1380,6 +1380,11 @@ public: /// If threshold option is not specified, it is disabled (0) by default. Optional<uint64_t> DiagnosticsHotnessThreshold = 0; + /// The percentage of difference between profiling branch weights and + // llvm.expect branch weights to tolerate when emiting MisExpect diagnostics + Optional<uint64_t> DiagnosticsMisExpectTolerance = 0; + bool MisExpectWarningRequested = false; + /// The specialized remark streamer used by LLVM's OptimizationRemarkEmitter. std::unique_ptr<LLVMRemarkStreamer> LLVMRS; |