LLVM
8.0.1
|
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. 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... | |
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.
|
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 183 of file MustExecute.cpp.
References assert(), blockMayThrow(), CanProveNotTakenFirstIteration(), collectTransitivePredecessors(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::SmallPtrSetImpl< PtrType >::insert(), 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::ICFLoopSafetyInfo, and llvm::SimpleLoopSafetyInfo.
Referenced by llvm::SimpleLoopSafetyInfo::blockMayThrow().
|
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().
Computes block colors.
Definition at line 97 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::ICFLoopSafetyInfo, and llvm::SimpleLoopSafetyInfo.
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().
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().
|
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().