LLVM  8.0.1
Public Member Functions | Protected Member Functions | List of all members
llvm::LoopSafetyInfo Class Referenceabstract

Captures loop safety information. More...

#include "llvm/Analysis/MustExecute.h"

Inheritance diagram for llvm::LoopSafetyInfo:
Inheritance graph
[legend]

Public Member Functions

const DenseMap< BasicBlock *, ColorVector > & getBlockColors () const
 Returns block colors map that is used to update funclet operand bundles. More...
 
void copyColors (BasicBlock *New, BasicBlock *Old)
 Copy colors of block Old into the block New. More...
 
virtual bool blockMayThrow (const BasicBlock *BB) const =0
 Returns true iff the block BB potentially may throw exception. More...
 
virtual bool anyBlockMayThrow () const =0
 Returns true iff any block of the loop for which this info is contains an instruction that may throw or otherwise exit abnormally. More...
 
bool allLoopPathsLeadToBlock (const Loop *CurLoop, const BasicBlock *BB, const DominatorTree *DT) const
 Return true if we must reach the block BB under assumption that the loop CurLoop is entered. More...
 
virtual void computeLoopSafetyInfo (const Loop *CurLoop)=0
 Computes safety information for a loop checks loop body & header for the possibility of may throw exception, it takes LoopSafetyInfo and loop as argument. More...
 
virtual bool isGuaranteedToExecute (const Instruction &Inst, const DominatorTree *DT, const Loop *CurLoop) const =0
 Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumption that the loop is entered). More...
 
 LoopSafetyInfo ()=default
 
virtual ~LoopSafetyInfo ()=default
 

Protected Member Functions

void computeBlockColors (const Loop *CurLoop)
 Computes block colors. More...
 

Detailed Description

Captures loop safety information.

It keep information for loop blocks may throw exception or otherwise exit abnormaly on any iteration of the loop which might actually execute at runtime. The primary way to consume this infromation is via isGuaranteedToExecute below, but some callers bailout or fallback to alternate reasoning if a loop contains any implicit control flow. NOTE: LoopSafetyInfo contains cached information regarding loops and their particular blocks. This information is only dropped on invocation of computeLoopSafetyInfo. If the loop or any of its block is deleted, or if any thrower instructions have been added or removed from them, or if the control flow has changed, or in case of other meaningful modifications, the LoopSafetyInfo needs to be recomputed. If a meaningful modifications to the loop were made and the info wasn't recomputed properly, the behavior of all methods except for computeLoopSafetyInfo is undefined.

Definition at line 48 of file MustExecute.h.

Constructor & Destructor Documentation

◆ LoopSafetyInfo()

llvm::LoopSafetyInfo::LoopSafetyInfo ( )
default

◆ ~LoopSafetyInfo()

virtual llvm::LoopSafetyInfo::~LoopSafetyInfo ( )
virtualdefault

Member Function Documentation

◆ allLoopPathsLeadToBlock()

bool LoopSafetyInfo::allLoopPathsLeadToBlock ( const Loop CurLoop,
const BasicBlock BB,
const DominatorTree DT 
) const

◆ anyBlockMayThrow()

virtual bool llvm::LoopSafetyInfo::anyBlockMayThrow ( ) const
pure virtual

Returns true iff any block of the loop for which this info is contains an instruction that may throw or otherwise exit abnormally.

Implemented in llvm::ICFLoopSafetyInfo, and llvm::SimpleLoopSafetyInfo.

Referenced by llvm::SimpleLoopSafetyInfo::blockMayThrow().

◆ blockMayThrow()

virtual bool llvm::LoopSafetyInfo::blockMayThrow ( const BasicBlock BB) const
pure virtual

Returns true iff the block BB potentially may throw exception.

It can be false-positive in cases when we want to avoid complex analysis.

Implemented in llvm::ICFLoopSafetyInfo, and llvm::SimpleLoopSafetyInfo.

Referenced by allLoopPathsLeadToBlock().

◆ computeBlockColors()

void LoopSafetyInfo::computeBlockColors ( const Loop CurLoop)
protected

◆ computeLoopSafetyInfo()

virtual void llvm::LoopSafetyInfo::computeLoopSafetyInfo ( const Loop CurLoop)
pure virtual

Computes safety information for a loop checks loop body & header for the possibility of may throw exception, it takes LoopSafetyInfo and loop as argument.

Updates safety information in LoopSafetyInfo argument. Note: This is defined to clear and reinitialize an already initialized LoopSafetyInfo. Some callers rely on this fact.

Implemented in llvm::ICFLoopSafetyInfo, and llvm::SimpleLoopSafetyInfo.

◆ copyColors()

void LoopSafetyInfo::copyColors ( BasicBlock New,
BasicBlock Old 
)

Copy colors of block Old into the block New.

Definition at line 30 of file MustExecute.cpp.

Referenced by splitPredecessorsOfLoopExit().

◆ getBlockColors()

const DenseMap< BasicBlock *, ColorVector > & LoopSafetyInfo::getBlockColors ( ) const

Returns block colors map that is used to update funclet operand bundles.

Definition at line 26 of file MustExecute.cpp.

Referenced by canSplitPredecessors(), CloneInstructionInExitBlock(), isNotUsedOrFreeInLoop(), and splitPredecessorsOfLoopExit().

◆ isGuaranteedToExecute()

virtual bool llvm::LoopSafetyInfo::isGuaranteedToExecute ( const Instruction Inst,
const DominatorTree DT,
const Loop CurLoop 
) const
pure virtual

Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumption that the loop is entered).

Implemented in llvm::ICFLoopSafetyInfo, and llvm::SimpleLoopSafetyInfo.

Referenced by isSafeToExecuteUnconditionally().


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