LLVM 22.0.0git
MisExpect.cpp File Reference
#include "llvm/Transforms/Utils/MisExpect.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormatVariadic.h"
#include <algorithm>
#include <cstdint>
#include <functional>
#include <numeric>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "misexpect"

Functions

static bool isMisExpectDiagEnabled (const LLVMContext &Ctx)
static uint32_t getMisExpectTolerance (const LLVMContext &Ctx)
static const InstructiongetInstCondition (const Instruction *I)
static void emitMisexpectDiagnostic (const Instruction *I, LLVMContext &Ctx, uint64_t ProfCount, uint64_t TotalCount)

Variables

static cl::opt< boolPGOWarnMisExpect ("pgo-warn-misexpect", cl::init(false), cl::Hidden, cl::desc("Use this option to turn on/off " "warnings about incorrect usage of llvm.expect intrinsics."))
static cl::opt< uint32_tMisExpectTolerance ("misexpect-tolerance", cl::init(0), cl::desc("Prevents emitting diagnostics when profile counts are " "within N% of the threshold.."))

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "misexpect"

Definition at line 46 of file MisExpect.cpp.

Function Documentation

◆ emitMisexpectDiagnostic()

void emitMisexpectDiagnostic ( const Instruction * I,
LLVMContext & Ctx,
uint64_t ProfCount,
uint64_t TotalCount )
static

◆ getInstCondition()

const Instruction * getInstCondition ( const Instruction * I)
static

Definition at line 73 of file MisExpect.cpp.

References assert(), B(), llvm::dyn_cast(), and I.

Referenced by emitMisexpectDiagnostic().

◆ getMisExpectTolerance()

uint32_t getMisExpectTolerance ( const LLVMContext & Ctx)
static

Definition at line 68 of file MisExpect.cpp.

References MisExpectTolerance.

Referenced by llvm::misexpect::verifyMisExpect().

◆ isMisExpectDiagEnabled()

bool isMisExpectDiagEnabled ( const LLVMContext & Ctx)
static

Definition at line 64 of file MisExpect.cpp.

References PGOWarnMisExpect.

Referenced by emitMisexpectDiagnostic().

Variable Documentation

◆ MisExpectTolerance

cl::opt< uint32_t > MisExpectTolerance("misexpect-tolerance", cl::init(0), cl::desc("Prevents emitting diagnostics when profile counts are " "within N% of the threshold..")) ( "misexpect-tolerance" ,
cl::init(0) ,
cl::desc("Prevents emitting diagnostics when profile counts are " "within N% of the threshold..")  )
static

Referenced by getMisExpectTolerance().

◆ PGOWarnMisExpect

cl::opt< bool > PGOWarnMisExpect("pgo-warn-misexpect", cl::init(false), cl::Hidden, cl::desc("Use this option to turn on/off " "warnings about incorrect usage of llvm.expect intrinsics.")) ( "pgo-warn-misexpect" ,
cl::init(false) ,
cl::Hidden ,
cl::desc("Use this option to turn on/off " "warnings about incorrect usage of llvm.expect intrinsics.")  )
static

Referenced by isMisExpectDiagEnabled().