llvm::IRBuilderBase::CreateSwitch

Create a switch instruction with the specified value, default dest, and with a hint for the number of cases that will be added (for efficient allocation).

Synopsis

Declared in <llvm/IR/IRBuilder.h>

SwitchInst*
CreateSwitch(
    Value* V,
    BasicBlock* Dest,
    unsigned int NumCases = 10,
    MDNode* BranchWeights = nullptr,
    MDNode* Unpredictable = nullptr);

Return Value

The created switch instruction.

Parameters

NameDescription
VInput value.
DestDestination basic block.
NumCasesHint for how many switch cases will be added.
BranchWeightsOptional branch-weight profile metadata.
UnpredictableOptional unpredictable-branch metadata.