LLVM 20.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.
 
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.
 
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.
 
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.
 

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 attached to the instruction, which 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 179 of file MisExpect.cpp.

References llvm::extractBranchWeights(), llvm::hasBranchWeightOrigin(), 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 attached to the instruction, which 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
ExistingWeightsA vector of profile weights for each target block
IsFrontendA boolean describing if this is Frontend instrumentation

Definition at line 202 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 attached to the instruction, which 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 emitting diagnostics

Definition at line 194 of file MisExpect.cpp.

References llvm::extractBranchWeights(), I, and verifyMisExpect().

Referenced by checkExpectAnnotations(), and handleBrSelExpect().

◆ 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 122 of file MisExpect.cpp.

References assert(), llvm::ArrayRef< T >::begin(), llvm::ArrayRef< T >::end(), End, llvm::BranchProbability::getBranchProbability(), I, Idx, LikelyBranchWeight, llvm::ArrayRef< T >::size(), and UnlikelyBranchWeight.

Referenced by checkBackendInstrumentation(), and checkFrontendInstrumentation().