LLVM  15.0.0git
Functions
llvm::misexpect Namespace Reference

Functions

void checkBackendInstrumentation (Instruction &I, const llvm::ArrayRef< uint32_t > RealWeights)
 checkBackendInstrumentation - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range. More...
 
void checkFrontendInstrumentation (Instruction &I, const ArrayRef< uint32_t > ExpectedWeights)
 checkFrontendInstrumentation - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range. More...
 
void verifyMisExpect (Instruction &I, ArrayRef< uint32_t > RealWeights, const ArrayRef< uint32_t > ExpectedWeights)
 veryifyMisExpect - compares RealWeights to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range. More...
 
void checkExpectAnnotations (Instruction &I, const ArrayRef< uint32_t > ExistingWeights, bool IsFrontend)
 checkExpectAnnotations - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range. More...
 
Optional< SmallVector< uint32_t, 4 > > extractWeights (Instruction *I, LLVMContext &Ctx)
 
uint32_t clamp (uint64_t value, uint32_t low, uint32_t hi)
 

Function Documentation

◆ checkBackendInstrumentation()

void llvm::misexpect::checkBackendInstrumentation ( Instruction I,
const llvm::ArrayRef< uint32_t RealWeights 
)

checkBackendInstrumentation - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range.

It extracts the expected weights from the MD_prof weights attatched to the instruction, which are are assumed to come from lowered llvm.expect intrinsics. The RealWeights parameter and the extracted expected weights are then passed to verifyMisexpect() for verification

Parameters
IThe Instruction being checked
RealWeightsA vector of profile weights for each target block

Definition at line 219 of file MisExpect.cpp.

References extractWeights(), I, and verifyMisExpect().

Referenced by checkExpectAnnotations().

◆ checkExpectAnnotations()

void llvm::misexpect::checkExpectAnnotations ( Instruction I,
const ArrayRef< uint32_t ExistingWeights,
bool  IsFrontend 
)

checkExpectAnnotations - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range.

It extracts the expected weights from the MD_prof weights attatched to the instruction, which are are assumed to come from lowered llvm.expect intrinsics. The RealWeights parameter and the extracted expected weights are then passed to verifyMisexpect() for verification. It is a thin wrapper around the checkFrontendInstrumentation and checkBackendInstrumentation APIs

Parameters
IThe Instruction being checked
RealWeightsA vector of profile weights for each target block
IsBackendA boolean describing if this is Frontend instrumentation

Definition at line 237 of file MisExpect.cpp.

References checkBackendInstrumentation(), checkFrontendInstrumentation(), and I.

Referenced by handleSwitchExpect(), and llvm::setProfMetadata().

◆ checkFrontendInstrumentation()

void llvm::misexpect::checkFrontendInstrumentation ( Instruction I,
const ArrayRef< uint32_t ExpectedWeights 
)

checkFrontendInstrumentation - compares PGO counters to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range.

It extracts the expected weights from the MD_prof weights attatched to the instruction, which are are assumed to come from profiling data attached by the frontend prior to llvm.expect intrinsic lowering. The ExpectedWeights parameter and the extracted real weights are then passed to verifyMisexpect() for verification

Parameters
IThe Instruction being checked
ExpectedWeightsA vector of the expected weights for each target block, this determines the threshold values used when emiting diagnostics

Definition at line 228 of file MisExpect.cpp.

References extractWeights(), I, and verifyMisExpect().

Referenced by checkExpectAnnotations().

◆ clamp()

uint32_t llvm::misexpect::clamp ( uint64_t  value,
uint32_t  low,
uint32_t  hi 
)

◆ extractWeights()

Optional<SmallVector<uint32_t, 4> > llvm::misexpect::extractWeights ( Instruction I,
LLVMContext Ctx 
)

◆ verifyMisExpect()

void llvm::misexpect::verifyMisExpect ( Instruction I,
ArrayRef< uint32_t RealWeights,
const ArrayRef< uint32_t ExpectedWeights 
)

veryifyMisExpect - compares RealWeights to the thresholds used for llvm.expect and warns if the PGO counters are outside of the expected range.

Parameters
IThe Instruction being checked
RealWeightsA vector of profile weights from the profile data
ExpectedWeightsA vector of the weights attatch by llvm.expect

Definition at line 158 of file MisExpect.cpp.

References LikelyBranchWeight, llvm::max(), and UnlikelyBranchWeight.

Referenced by checkBackendInstrumentation(), and checkFrontendInstrumentation().