llvm::setBranchWeights

Create a new branch_weights metadata node and add or overwrite a prof metadata reference to instruction I.

Synopsis

Declared in <llvm/IR/ProfDataUtils.h>

void
setBranchWeights(
    Instruction& I,
    ArrayRef<uint32_t> Weights,
    bool IsExpected,
    bool ElideAllZero = false);

Parameters

NameDescription
Ithe Instruction to set branch weights on.
Weightsan array of weights to set on instruction I.
IsExpectedwere these weights added from an llvm.expect* intrinsic.
ElideAllZeroif true, drop profile metadata when all weights are zero.