class LoopSafetyInfo

Declaration

class LoopSafetyInfo { /* full declaration omitted */ };

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

Declared at: llvm/include/llvm/Analysis/MustExecute.h:60

Member Variables

private DenseMap<llvm::BasicBlock*, llvm::ColorVector> BlockColors

Method Overview

Methods

LoopSafetyInfo()

Declared at: llvm/include/llvm/Analysis/MustExecute.h:101

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

Description

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

Declared at: llvm/include/llvm/Analysis/MustExecute.h:85

Parameters

const llvm::Loop* CurLoop
const llvm::BasicBlock* BB
const llvm::DominatorTree* DT

virtual bool anyBlockMayThrow() const

Description

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

Declared at: llvm/include/llvm/Analysis/MustExecute.h:81

virtual bool blockMayThrow(
    const llvm::BasicBlock* BB) const

Description

Returns true iff the block \p BB potentially may throw exception. It can be false-positive in cases when we want to avoid complex analysis.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:77

Parameters

const llvm::BasicBlock* BB

void computeBlockColors(const llvm::Loop* CurLoop)

Description

Computes block colors.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:66

Parameters

const llvm::Loop* CurLoop

virtual void computeLoopSafetyInfo(
    const llvm::Loop* CurLoop)

Description

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.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:93

Parameters

const llvm::Loop* CurLoop

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

Description

Copy colors of block \p Old into the block \p New.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:73

Parameters

llvm::BasicBlock* New
llvm::BasicBlock* Old

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

Description

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

Declared at: llvm/include/llvm/Analysis/MustExecute.h:70

virtual bool isGuaranteedToExecute(
    const llvm::Instruction& Inst,
    const llvm::DominatorTree* DT,
    const llvm::Loop* CurLoop) const

Description

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

Declared at: llvm/include/llvm/Analysis/MustExecute.h:97

Parameters

const llvm::Instruction& Inst
const llvm::DominatorTree* DT
const llvm::Loop* CurLoop

virtual ~LoopSafetyInfo()

Declared at: llvm/include/llvm/Analysis/MustExecute.h:103