aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/LLVMContext.cpp
diff options
context:
space:
mode:
authorPaul Kirth <paulkirth@google.com>2022-03-09 16:01:38 +0000
committerPaul Kirth <paulkirth@google.com>2022-03-17 23:46:23 +0000
commite7749d4713a5ec886011ceb0fc821c6723061724 (patch)
tree1294c0be71860eb829e4f5ad9d5a3bcbbbcf6edd /llvm/lib/IR/LLVMContext.cpp
parent2e94d8e67a91fc84f48cf6b44c8558c3d9712f87 (diff)
downloadllvm-e7749d4713a5ec886011ceb0fc821c6723061724.zip
llvm-e7749d4713a5ec886011ceb0fc821c6723061724.tar.gz
llvm-e7749d4713a5ec886011ceb0fc821c6723061724.tar.bz2
[misexpect] Re-implement MisExpect Diagnostics
Reimplements MisExpect diagnostics from D66324 to reconstruct its original checking methodology only using MD_prof branch_weights metadata. New checks rely on 2 invariants: 1) For frontend instrumentation, MD_prof branch_weights will always be populated before llvm.expect intrinsics are lowered. 2) for IR and sample profiling, llvm.expect intrinsics will always be lowered before branch_weights are populated from the IR profiles. These invariants allow the checking to assume how the existing branch weights are populated depending on the profiling method used, and emit the correct diagnostics. If these invariants are ever invalidated, the MisExpect related checks would need to be updated, potentially by re-introducing MD_misexpect metadata, and ensuring it always will be transformed the same way as branch_weights in other optimization passes. Frontend based profiling is now enabled without using LLVM Args, by introducing a new CodeGen option, and checking if the -Wmisexpect flag has been passed on the command line. Differential Revision: https://reviews.llvm.org/D115907
Diffstat (limited to 'llvm/lib/IR/LLVMContext.cpp')
-rw-r--r--llvm/lib/IR/LLVMContext.cpp14
1 files changed, 13 insertions, 1 deletions
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();