|
LLVM 24.0.0git
|
A "must be executed context" for a given program point PP is the set of instructions, potentially before and after PP, that are executed always when PP is reached. More...
#include "llvm/Analysis/MustExecute.h"
Public Types | |
| using | iterator = MustBeExecutedIterator |
| Iterator-based interface. | |
| using | const_iterator = const MustBeExecutedIterator |
Public Member Functions | |
| MustBeExecutedContextExplorer (bool ExploreInterBlock, bool ExploreCFGForward, bool ExploreCFGBackward, GetterTy< const LoopInfo > LIGetter=[](const Function &) { return nullptr;}, GetterTy< const DominatorTree > DTGetter=[](const Function &) { return nullptr;}, GetterTy< const PostDominatorTree > PDTGetter=[](const Function &) { return nullptr;}) | |
| In the description of the parameters we use PP to denote a program point for which the must be executed context is explored, or put differently, for which the MustBeExecutedIterator is created. | |
| iterator & | begin (const Instruction *PP) |
Return an iterator to explore the context around PP. | |
| const_iterator & | begin (const Instruction *PP) const |
Return an iterator to explore the cached context around PP. | |
| iterator & | end () |
| Return an universal end iterator. | |
| iterator & | end (const Instruction *) |
| const_iterator & | end () const |
| const_iterator & | end (const Instruction *) const |
| llvm::iterator_range< iterator > | range (const Instruction *PP) |
| } | |
| llvm::iterator_range< const_iterator > | range (const Instruction *PP) const |
Return an iterator range to explore the cached context around PP. | |
| LLVM_ABI bool | isInContextOf (const Instruction *I, const Instruction *PP) |
| } | |
| LLVM_ABI bool | checkForAllTerminatorsInContext (const Instruction *PP, function_ref< bool(const Instruction *)> Pred) |
Check Pred on all terminators in the context of PP and return true if it holds for all of them. | |
| LLVM_ABI const Instruction * | getMustBeExecutedNextInstruction (MustBeExecutedIterator &It, const Instruction *PP) |
Return the next instruction that is guaranteed to be executed after PP. | |
| LLVM_ABI const Instruction * | getMustBeExecutedPrevInstruction (MustBeExecutedIterator &It, const Instruction *PP) |
| Return the previous instr. | |
| LLVM_ABI const BasicBlock * | findForwardJoinPoint (const BasicBlock *InitBB) |
Find the next join point from InitBB in forward direction. | |
| LLVM_ABI const BasicBlock * | findBackwardJoinPoint (const BasicBlock *InitBB) |
Find the next join point from InitBB in backward direction. | |
Public Attributes | |
| const bool | ExploreInterBlock |
| Parameter that limit the performed exploration. | |
| const bool | ExploreCFGForward |
| const bool | ExploreCFGBackward |
A "must be executed context" for a given program point PP is the set of instructions, potentially before and after PP, that are executed always when PP is reached.
The MustBeExecutedContextExplorer an interface to explore "must be executed contexts" in a module through the use of MustBeExecutedIterator.
The explorer exposes "must be executed iterators" that traverse the must be executed context. There is little information sharing between iterators as the expected use case involves few iterators for "far apart" instructions. If that changes, we should consider caching more intermediate results.
Definition at line 383 of file MustExecute.h.
Definition at line 414 of file MustExecute.h.
Iterator-based interface.
Definition at line 413 of file MustExecute.h.
|
inline |
In the description of the parameters we use PP to denote a program point for which the must be executed context is explored, or put differently, for which the MustBeExecutedIterator is created.
| ExploreInterBlock | Flag to indicate if instructions in blocks other than the parent of PP should be explored. |
| ExploreCFGForward | Flag to indicate if instructions located after PP in the CFG, e.g., post-dominating PP, should be explored. |
| ExploreCFGBackward | Flag to indicate if instructions located before PP in the CFG, e.g., dominating PP, should be explored. |
Definition at line 398 of file MustExecute.h.
References ExploreCFGBackward, ExploreCFGForward, and ExploreInterBlock.
|
inline |
Return an iterator to explore the context around PP.
Definition at line 417 of file MustExecute.h.
|
inline |
Return an iterator to explore the cached context around PP.
Definition at line 425 of file MustExecute.h.
| bool MustBeExecutedContextExplorer::checkForAllTerminatorsInContext | ( | const Instruction * | PP, |
| function_ref< bool(const Instruction *)> | Pred ) |
Check Pred on all terminators in the context of PP and return true if it holds for all of them.
Definition at line 830 of file MustExecute.cpp.
References ExploreCFGBackward, ExploreCFGForward, ExploreInterBlock, llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::BasicBlock::getTerminator(), llvm::SmallPtrSetImpl< PtrType >::insert(), isInContextOf(), and Pred.
|
inline |
|
inline |
Definition at line 434 of file MustExecute.h.
|
inline |
Definition at line 432 of file MustExecute.h.
|
inline |
Definition at line 435 of file MustExecute.h.
| const BasicBlock * MustBeExecutedContextExplorer::findBackwardJoinPoint | ( | const BasicBlock * | InitBB | ) |
Find the next join point from InitBB in backward direction.
Definition at line 565 of file MustExecute.cpp.
References llvm::dbgs(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::Value::getName(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getUniquePredecessor(), LLVM_DEBUG, llvm::predecessors(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
Referenced by getMustBeExecutedPrevInstruction().
| const BasicBlock * MustBeExecutedContextExplorer::findForwardJoinPoint | ( | const BasicBlock * | InitBB | ) |
Find the next join point from InitBB in forward direction.
Definition at line 429 of file MustExecute.cpp.
References llvm::append_range(), llvm::dbgs(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), F, llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::Value::getName(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), getOrCreateCachedOptional(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getUniqueSuccessor(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isGuaranteedToTransferExecutionToSuccessor(), LLVM_DEBUG, maybeEndlessLoop(), llvm::mayContainIrreducibleControl(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and llvm::successors().
Referenced by getMustBeExecutedNextInstruction().
| const Instruction * MustBeExecutedContextExplorer::getMustBeExecutedNextInstruction | ( | MustBeExecutedIterator & | It, |
| const Instruction * | PP ) |
Return the next instruction that is guaranteed to be executed after PP.
| It | The iterator that is used to traverse the must be executed context. |
| PP | The program point for which the next instruction that is guaranteed to execute is determined. |
Definition at line 632 of file MustExecute.cpp.
References assert(), llvm::dbgs(), ExploreInterBlock, findForwardJoinPoint(), llvm::BasicBlock::front(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Instruction::getNumSuccessors(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::Instruction::getSuccessor(), llvm::isGuaranteedToTransferExecutionToSuccessor(), llvm::Instruction::isTerminator(), and LLVM_DEBUG.
| const Instruction * MustBeExecutedContextExplorer::getMustBeExecutedPrevInstruction | ( | MustBeExecutedIterator & | It, |
| const Instruction * | PP ) |
Return the previous instr.
that is guaranteed to be executed before PP.
| It | The iterator that is used to traverse the must be executed context. |
| PP | The program point for which the previous instr. that is guaranteed to execute is determined. |
Definition at line 689 of file MustExecute.cpp.
References llvm::dbgs(), ExploreInterBlock, findBackwardJoinPoint(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), and LLVM_DEBUG.
| bool MustBeExecutedContextExplorer::isInContextOf | ( | const Instruction * | I, |
| const Instruction * | PP ) |
}
Return true if I is in the context of PP.
That is the case if iterating over the context of PP visits I. This does not explore the context of every program point separately but uses summaries of the contexts of basic blocks that are shared by all program points.
Definition at line 795 of file MustExecute.cpp.
References llvm::Instruction::comesBefore(), contains(), ExploreCFGBackward, ExploreCFGForward, ExploreInterBlock, llvm::BasicBlock::getParent(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), and I.
Referenced by checkForAllTerminatorsInContext(), and llvm::Attributor::getAttrsFromAssumes().
|
inline |
}
Return an iterator range to explore the context around PP.
Definition at line 439 of file MustExecute.h.
References begin(), end(), and llvm::make_range().
Referenced by llvm::MustBeExecutedContextPrinterPass::run().
|
inline |
Return an iterator range to explore the cached context around PP.
Definition at line 444 of file MustExecute.h.
References begin(), end(), and llvm::make_range().
Definition at line 493 of file MustExecute.h.
Referenced by checkForAllTerminatorsInContext(), isInContextOf(), and MustBeExecutedContextExplorer().
Definition at line 492 of file MustExecute.h.
Referenced by checkForAllTerminatorsInContext(), isInContextOf(), and MustBeExecutedContextExplorer().
Parameter that limit the performed exploration.
See the constructor for their meaning. {
Definition at line 491 of file MustExecute.h.
Referenced by checkForAllTerminatorsInContext(), getMustBeExecutedNextInstruction(), getMustBeExecutedPrevInstruction(), isInContextOf(), and MustBeExecutedContextExplorer().