LLVM  13.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
llvm::SwitchInstProfUpdateWrapper Class Reference

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

#include "llvm/IR/Instructions.h"

Public Types

using CaseWeightOpt = Optional< uint32_t >
 

Public Member Functions

SwitchInstoperator-> ()
 
SwitchInstoperator* ()
 
 operator SwitchInst * ()
 
 SwitchInstProfUpdateWrapper (SwitchInst &SI)
 
 ~SwitchInstProfUpdateWrapper ()
 
SwitchInst::CaseIt removeCase (SwitchInst::CaseIt I)
 Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight. More...
 
void addCase (ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
 Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the added case. More...
 
SymbolTableList< Instruction >::iterator eraseFromParent ()
 Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch the underlying SwitchInst in destructor. More...
 
void setSuccessorWeight (unsigned idx, CaseWeightOpt W)
 
CaseWeightOpt getSuccessorWeight (unsigned idx)
 

Static Public Member Functions

static CaseWeightOpt getSuccessorWeight (const SwitchInst &SI, unsigned idx)
 

Protected Member Functions

MDNodebuildProfBranchWeightsMD ()
 
void init ()
 

Static Protected Member Functions

static MDNodegetProfBranchWeightsMD (const SwitchInst &SI)
 

Detailed Description

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

Definition at line 3497 of file Instructions.h.

Member Typedef Documentation

◆ CaseWeightOpt

Definition at line 3510 of file Instructions.h.

Constructor & Destructor Documentation

◆ SwitchInstProfUpdateWrapper()

llvm::SwitchInstProfUpdateWrapper::SwitchInstProfUpdateWrapper ( SwitchInst SI)
inline

Definition at line 3515 of file Instructions.h.

References init(), and SI.

◆ ~SwitchInstProfUpdateWrapper()

llvm::SwitchInstProfUpdateWrapper::~SwitchInstProfUpdateWrapper ( )
inline

Definition at line 3517 of file Instructions.h.

References buildProfBranchWeightsMD(), and SI.

Member Function Documentation

◆ addCase()

void SwitchInstProfUpdateWrapper::addCase ( ConstantInt OnVal,
BasicBlock Dest,
SwitchInstProfUpdateWrapper::CaseWeightOpt  W 
)

Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the added case.

Definition at line 4159 of file Instructions.cpp.

References assert(), SI, and llvm::RISCVFenceField::W.

Referenced by unswitchTrivialSwitch().

◆ buildProfBranchWeightsMD()

MDNode * SwitchInstProfUpdateWrapper::buildProfBranchWeightsMD ( )
protected

◆ eraseFromParent()

SymbolTableList< Instruction >::iterator SwitchInstProfUpdateWrapper::eraseFromParent ( )

Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch the underlying SwitchInst in destructor.

Definition at line 4178 of file Instructions.cpp.

References SI.

Referenced by unswitchTrivialSwitch().

◆ getProfBranchWeightsMD()

MDNode * SwitchInstProfUpdateWrapper::getProfBranchWeightsMD ( const SwitchInst SI)
staticprotected

Definition at line 4099 of file Instructions.cpp.

References SI.

Referenced by getSuccessorWeight(), and init().

◆ getSuccessorWeight() [1/2]

SwitchInstProfUpdateWrapper::CaseWeightOpt SwitchInstProfUpdateWrapper::getSuccessorWeight ( const SwitchInst SI,
unsigned  idx 
)
static

Definition at line 4211 of file Instructions.cpp.

References getProfBranchWeightsMD(), llvm::None, and SI.

◆ getSuccessorWeight() [2/2]

SwitchInstProfUpdateWrapper::CaseWeightOpt SwitchInstProfUpdateWrapper::getSuccessorWeight ( unsigned  idx)

Definition at line 4187 of file Instructions.cpp.

References llvm::None.

Referenced by unswitchTrivialSwitch().

◆ init()

void SwitchInstProfUpdateWrapper::init ( )
protected

◆ operator SwitchInst *()

llvm::SwitchInstProfUpdateWrapper::operator SwitchInst * ( )
inline

Definition at line 3513 of file Instructions.h.

References SI.

◆ operator*()

SwitchInst& llvm::SwitchInstProfUpdateWrapper::operator* ( )
inline

Definition at line 3512 of file Instructions.h.

References SI.

◆ operator->()

SwitchInst* llvm::SwitchInstProfUpdateWrapper::operator-> ( )
inline

Definition at line 3511 of file Instructions.h.

References SI.

◆ removeCase()

SwitchInst::CaseIt SwitchInstProfUpdateWrapper::removeCase ( SwitchInst::CaseIt  I)

Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.

Definition at line 4145 of file Instructions.cpp.

References assert(), I, and SI.

Referenced by eliminateDeadSwitchCases(), and unswitchTrivialSwitch().

◆ setSuccessorWeight()

void SwitchInstProfUpdateWrapper::setSuccessorWeight ( unsigned  idx,
SwitchInstProfUpdateWrapper::CaseWeightOpt  W 
)

Definition at line 4193 of file Instructions.cpp.

References SI, and llvm::RISCVFenceField::W.

Referenced by unswitchTrivialSwitch().


The documentation for this class was generated from the following files: