Keep SwitchInst branch‐weight metadata in sync when editing cases.

Synopsis

Declared in <llvm/IR/Instructions.h>

class SwitchInstProfUpdateWrapper;

Description

A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights metadata.

Type Aliases

Name

Description

CaseWeightOpt

Optional profile weight for one switch successor.

Member Functions

Name

Description

SwitchInstProfUpdateWrapper [constructor]

Construct a wrapper that keeps branch weights in sync for SI.

~SwitchInstProfUpdateWrapper [destructor]

Write updated branch weights back to the switch if needed.

addCase

Add case OnVal ‐> Dest with optional branch weight W.

eraseFromParent

Delegate eraseFromParent to the wrapped switch and skip destructor updates.

getSuccessorWeight

Return the profile weight of successor idx.

operator*

Return a reference to the wrapped switch instruction.

operator‐>

Return a pointer to the wrapped switch instruction.

removeCase

Remove case I and its branch weight from the wrapped switch.

replaceDefaultDest

Replace the default destination with the case referenced by I.

setSuccessorWeight

Set the profile weight of successor idx.

operator SwitchInst*

Convert to a pointer to the wrapped switch instruction.

Static Member Functions

Name

Description

getSuccessorWeight

Return the profile weight of successor idx in SI.

Protected Member Functions

Name

Description

init

Initialize branch‐weight metadata from the wrapped switch.

Created with MrDocs