LLVM 20.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
llvm::MustBeExecutedContextExplorer Struct Reference

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.
 
iteratorbegin (const Instruction *PP)
 Return an iterator to explore the context around PP.
 
const_iteratorbegin (const Instruction *PP) const
 Return an iterator to explore the cached context around PP.
 
iteratorend ()
 Return an universal end iterator.
 
iteratorend (const Instruction *)
 
const_iteratorend () const
 
const_iteratorend (const Instruction *) const
 
llvm::iterator_range< iteratorrange (const Instruction *PP)
 }
 
llvm::iterator_range< const_iteratorrange (const Instruction *PP) const
 Return an iterator range to explore the cached context around PP.
 
bool checkForAllContext (const Instruction *PP, function_ref< bool(const Instruction *)> Pred)
 }
 
bool findInContextOf (const Instruction *I, const Instruction *PP)
 Helper to look for I in the context of PP.
 
bool findInContextOf (const Instruction *I, iterator &EIt, iterator &EEnd)
 Helper to look for I in the context defined by EIt and EEnd.
 
const InstructiongetMustBeExecutedNextInstruction (MustBeExecutedIterator &It, const Instruction *PP)
 Return the next instruction that is guaranteed to be executed after PP.
 
const InstructiongetMustBeExecutedPrevInstruction (MustBeExecutedIterator &It, const Instruction *PP)
 Return the previous instr.
 
const BasicBlockfindForwardJoinPoint (const BasicBlock *InitBB)
 Find the next join point from InitBB in forward direction.
 
const BasicBlockfindBackwardJoinPoint (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
 

Detailed Description

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 385 of file MustExecute.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 416 of file MustExecute.h.

◆ iterator

Iterator-based interface.

See also
MustBeExecutedIterator. {

Definition at line 415 of file MustExecute.h.

Constructor & Destructor Documentation

◆ MustBeExecutedContextExplorer()

llvm::MustBeExecutedContextExplorer::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; } 
)
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.

Parameters
ExploreInterBlockFlag to indicate if instructions in blocks other than the parent of PP should be explored.
ExploreCFGForwardFlag to indicate if instructions located after PP in the CFG, e.g., post-dominating PP, should be explored.
ExploreCFGBackwardFlag to indicate if instructions located before PP in the CFG, e.g., dominating PP, should be explored.

Definition at line 400 of file MustExecute.h.

Member Function Documentation

◆ begin() [1/2]

iterator & llvm::MustBeExecutedContextExplorer::begin ( const Instruction PP)
inline

Return an iterator to explore the context around PP.

Definition at line 419 of file MustExecute.h.

Referenced by checkForAllContext(), findInContextOf(), llvm::Attributor::getAttrsFromAssumes(), and range().

◆ begin() [2/2]

const_iterator & llvm::MustBeExecutedContextExplorer::begin ( const Instruction PP) const
inline

Return an iterator to explore the cached context around PP.

Definition at line 427 of file MustExecute.h.

◆ checkForAllContext()

bool llvm::MustBeExecutedContextExplorer::checkForAllContext ( const Instruction PP,
function_ref< bool(const Instruction *)>  Pred 
)
inline

}

Check Pred on all instructions in the context.

This method will evaluate Pred and return true if Pred holds in every instruction.

Definition at line 455 of file MustExecute.h.

References begin(), and end().

◆ end() [1/4]

iterator & llvm::MustBeExecutedContextExplorer::end ( )
inline

Return an universal end iterator.

{

Definition at line 433 of file MustExecute.h.

Referenced by checkForAllContext(), findInContextOf(), llvm::Attributor::getAttrsFromAssumes(), and range().

◆ end() [2/4]

const_iterator & llvm::MustBeExecutedContextExplorer::end ( ) const
inline

Definition at line 436 of file MustExecute.h.

◆ end() [3/4]

iterator & llvm::MustBeExecutedContextExplorer::end ( const Instruction )
inline

Definition at line 434 of file MustExecute.h.

◆ end() [4/4]

const_iterator & llvm::MustBeExecutedContextExplorer::end ( const Instruction ) const
inline

Definition at line 437 of file MustExecute.h.

◆ findBackwardJoinPoint()

const BasicBlock * MustBeExecutedContextExplorer::findBackwardJoinPoint ( const BasicBlock InitBB)

◆ findForwardJoinPoint()

const BasicBlock * MustBeExecutedContextExplorer::findForwardJoinPoint ( const BasicBlock InitBB)

◆ findInContextOf() [1/2]

bool llvm::MustBeExecutedContextExplorer::findInContextOf ( const Instruction I,
const Instruction PP 
)
inline

Helper to look for I in the context of PP.

The context is expanded until I was found or no more expansion is possible.

Returns
True, iff I was found.

Definition at line 469 of file MustExecute.h.

References begin(), end(), findInContextOf(), and I.

Referenced by findInContextOf(), and llvm::Attributor::getAttrsFromAssumes().

◆ findInContextOf() [2/2]

bool llvm::MustBeExecutedContextExplorer::findInContextOf ( const Instruction I,
iterator EIt,
iterator EEnd 
)
inline

Helper to look for I in the context defined by EIt and EEnd.

The context is expanded until I was found or no more expansion is possible.

Returns
True, iff I was found.

Definition at line 480 of file MustExecute.h.

References llvm::MustBeExecutedIterator::count(), and I.

◆ getMustBeExecutedNextInstruction()

const Instruction * MustBeExecutedContextExplorer::getMustBeExecutedNextInstruction ( MustBeExecutedIterator It,
const Instruction PP 
)

Return the next instruction that is guaranteed to be executed after PP.

Parameters
ItThe iterator that is used to traverse the must be executed context.
PPThe program point for which the next instruction that is guaranteed to execute is determined.

Definition at line 613 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.

◆ getMustBeExecutedPrevInstruction()

const Instruction * MustBeExecutedContextExplorer::getMustBeExecutedPrevInstruction ( MustBeExecutedIterator It,
const Instruction PP 
)

Return the previous instr.

that is guaranteed to be executed before PP.

Parameters
ItThe iterator that is used to traverse the must be executed context.
PPThe program point for which the previous instr. that is guaranteed to execute is determined.

Definition at line 670 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.

◆ range() [1/2]

llvm::iterator_range< iterator > llvm::MustBeExecutedContextExplorer::range ( const Instruction PP)
inline

}

Return an iterator range to explore the context around PP.

Definition at line 441 of file MustExecute.h.

References begin(), end(), and llvm::make_range().

Referenced by llvm::MustBeExecutedContextPrinterPass::run().

◆ range() [2/2]

llvm::iterator_range< const_iterator > llvm::MustBeExecutedContextExplorer::range ( const Instruction PP) const
inline

Return an iterator range to explore the cached context around PP.

Definition at line 446 of file MustExecute.h.

References begin(), end(), and llvm::make_range().

Member Data Documentation

◆ ExploreCFGBackward

const bool llvm::MustBeExecutedContextExplorer::ExploreCFGBackward

Definition at line 517 of file MustExecute.h.

◆ ExploreCFGForward

const bool llvm::MustBeExecutedContextExplorer::ExploreCFGForward

Definition at line 516 of file MustExecute.h.

◆ ExploreInterBlock

const bool llvm::MustBeExecutedContextExplorer::ExploreInterBlock

Parameter that limit the performed exploration.

See the constructor for their meaning. {

Definition at line 515 of file MustExecute.h.

Referenced by getMustBeExecutedNextInstruction(), and getMustBeExecutedPrevInstruction().


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