LLVM 20.0.0git
|
Captures loop safety information. More...
#include "llvm/Analysis/MustExecute.h"
Public Member Functions | |
const DenseMap< BasicBlock *, ColorVector > & | getBlockColors () const |
Returns block colors map that is used to update funclet operand bundles. | |
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. | |
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. | |
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. | |
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). | |
LoopSafetyInfo ()=default | |
virtual | ~LoopSafetyInfo ()=default |
Protected Member Functions | |
void | computeBlockColors (const Loop *CurLoop) |
Computes block colors. | |
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.
Definition at line 59 of file MustExecute.h.
|
default |
|
virtualdefault |
bool LoopSafetyInfo::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.
Definition at line 198 of file MustExecute.cpp.
References assert(), blockMayThrow(), CanProveNotTakenFirstIteration(), collectTransitivePredecessors(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::DominatorTree::dominates(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::predecessors(), and llvm::successors().
Referenced by llvm::SimpleLoopSafetyInfo::isGuaranteedToExecute(), and llvm::ICFLoopSafetyInfo::isGuaranteedToExecute().
|
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::SimpleLoopSafetyInfo, and llvm::ICFLoopSafetyInfo.
|
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::SimpleLoopSafetyInfo, and llvm::ICFLoopSafetyInfo.
Referenced by allLoopPathsLeadToBlock().
Computes block colors.
Definition at line 102 of file MustExecute.cpp.
References llvm::classifyEHPersonality(), llvm::colorEHFunclets(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::BasicBlock::getParent(), llvm::Function::getPersonalityFn(), llvm::Function::hasPersonalityFn(), and llvm::isScopedEHPersonality().
Referenced by llvm::SimpleLoopSafetyInfo::computeLoopSafetyInfo(), and llvm::ICFLoopSafetyInfo::computeLoopSafetyInfo().
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::SimpleLoopSafetyInfo, and llvm::ICFLoopSafetyInfo.
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().
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().
|
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::SimpleLoopSafetyInfo, and llvm::ICFLoopSafetyInfo.
Referenced by isSafeToExecuteUnconditionally().