LLVM 24.0.0git
llvm::LoopSafetyInfo Class Referenceabstract

Captures loop safety information. More...

#include "llvm/Analysis/MustExecute.h"

Inheritance diagram for llvm::LoopSafetyInfo:
[legend]

Public Member Functions

LLVM_ABI const DenseMap< BasicBlock *, ColorVector > & getBlockColors () const
 Returns block colors map that is used to update funclet operand bundles.
LLVM_ABI void copyColors (BasicBlock *New, BasicBlock *Old)
 Copy colors of block Old into the block New.
virtual bool blockMayThrow (const BasicBlock *BB) const =0
 Returns true iff the block BB potentially may throw exception.
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.
LLVM_ABI bool allLoopPathsLeadToBlock (const BasicBlock *BB, const DominatorTree *DT) const
 Return true if we must reach the block BB under assumption that the loop is entered.
virtual bool isGuaranteedToExecute (const Instruction &Inst, const DominatorTree *DT) 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).
 LoopSafetyInfo (const Loop *CurLoop)
virtual ~LoopSafetyInfo ()=default

Protected Member Functions

LLVM_ABI void computeBlockColors ()
 Computes block colors.

Protected Attributes

const LoopCurLoop

Detailed Description

Captures loop safety information.

It keep information for loop blocks may throw exception or otherwise exit abnormally on any iteration of the loop which might actually execute at runtime. The primary way to consume this information 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. Cached information may not be valid after control flow changes.

Definition at line 55 of file MustExecute.h.

Constructor & Destructor Documentation

◆ LoopSafetyInfo()

llvm::LoopSafetyInfo::LoopSafetyInfo ( const Loop * CurLoop)
inline

◆ ~LoopSafetyInfo()

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

Member Function Documentation

◆ allLoopPathsLeadToBlock()

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

Return true if we must reach the block BB under assumption that the loop is entered.

Definition at line 198 of file MustExecute.cpp.

References assert(), and CurLoop.

Referenced by llvm::ICFLoopSafetyInfo::isGuaranteedToExecute(), and llvm::SimpleLoopSafetyInfo::isGuaranteedToExecute().

◆ 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.

References LLVM_ABI.

◆ 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.

◆ computeBlockColors()

void LoopSafetyInfo::computeBlockColors ( )
protected

◆ copyColors()

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

Copy colors of block Old into the block New.

Definition at line 34 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 30 of file MustExecute.cpp.

Referenced by canSplitPredecessors(), cloneInstructionInExitBlock(), isNotUsedOrFoldableInLoop(), and splitPredecessorsOfLoopExit().

◆ isGuaranteedToExecute()

virtual bool llvm::LoopSafetyInfo::isGuaranteedToExecute ( const Instruction & Inst,
const DominatorTree * DT ) 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().

Member Data Documentation

◆ CurLoop


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