clang 8.0.0

Macros | Enumerations | Functions
CodeGenPGO.cpp File Reference
`#include "CodeGenPGO.h"`
`#include "CodeGenFunction.h"`
`#include "CoverageMappingGen.h"`
`#include "clang/AST/RecursiveASTVisitor.h"`
`#include "clang/AST/StmtVisitor.h"`
`#include "llvm/IR/Intrinsics.h"`
`#include "llvm/IR/MDBuilder.h"`
`#include "llvm/Support/Endian.h"`
`#include "llvm/Support/FileSystem.h"`
`#include "llvm/Support/MD5.h"`
Include dependency graph for CodeGenPGO.cpp:

Go to the source code of this file.

## Macros
#define | DEFINE_NESTABLE_TRAVERSAL(N)

## Enumerations
enum | PGOHashVersion : unsigned { PGO_HASH_V1, PGO_HASH_V2, PGO_HASH_LATEST = PGO_HASH_V2 }
| The version of the PGO hash algorithm. More...

## Functions
static llvm::cl::opt< bool > | EnableValueProfiling ("enable-value-profiling", llvm::cl::ZeroOrMore, llvm::cl::desc("Enable value profiling"), llvm::cl::Hidden, llvm::cl::init(false))
static uint64_t | calculateWeightScale (uint64_t MaxWeight)
| Calculate what to divide by to scale weights. More...
static uint32_t | scaleBranchWeight (uint64_t Weight, uint64_t Scale)
| Scale an individual branch weight (and add 1). More...

## Macro Definition Documentation

## ◆ DEFINE_NESTABLE_TRAVERSAL

#define DEFINE_NESTABLE_TRAVERSAL | ( |  | N | ) |

Value:
bool Traverse##N(N *S) { \
Base::Traverse##N(S); \
if (Hash.getHashVersion() != PGO_HASH_V1) \
Hash.combine(PGOHash::EndOfScope); \
return true; \
}
PGO_HASH_V1
Definition: CodeGenPGO.cpp:53

Definition at line 236 of file CodeGenPGO.cpp.

## Enumeration Type Documentation

## ◆ PGOHashVersion

enum PGOHashVersion : unsigned

The version of the PGO hash algorithm.

Enumerator
PGO_HASH_V1 |
PGO_HASH_V2 |
PGO_HASH_LATEST |

Definition at line 52 of file CodeGenPGO.cpp.

## Function Documentation

## ◆ calculateWeightScale()

static uint64_t calculateWeightScale | ( | uint64_t | MaxWeight | ) |
| static

Calculate what to divide by to scale weights.

Given the maximum weight, calculate a divisor that will scale all the weights to strictly less than UINT32_MAX.

Definition at line 992 of file CodeGenPGO.cpp.

Referenced by scaleBranchWeight().

## ◆ EnableValueProfiling()

static llvm::cl::opt<bool> EnableValueProfiling | ( | "enable-value-profiling" | ,
|  | llvm::cl::ZeroOrMore | ,
|  | llvm::cl::desc("Enable value profiling") | ,
|  | llvm::cl::Hidden | ,
|  | llvm::cl::init(false) |
| ) |  |
| static

## ◆ scaleBranchWeight()

static uint32_t scaleBranchWeight | ( | uint64_t | Weight,
|  | uint64_t | Scale
| ) |  |
| static

Scale an individual branch weight (and add 1).

Scale a 64-bit weight down to 32-bits using `Scale`.

According to Laplace's Rule of Succession, it is better to compute the weight based on the count plus 1, so universally add 1 to the value.

Precondition
  `Scale` was calculated by calculateWeightScale() with a weight no greater than `Weight`.

Definition at line 1005 of file CodeGenPGO.cpp.

References calculateWeightScale(), and max().