LLVM  14.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"

Collaboration diagram for llvm::MustBeExecutedContextExplorer:
Collaboration graph
[legend]

Public Types

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

Public Attributes

const bool ExploreInterBlock
 Parameter that limit the performed exploration. More...
 
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 388 of file MustExecute.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 419 of file MustExecute.h.

◆ iterator

Iterator-based interface.

See also
MustBeExecutedIterator. {

Definition at line 418 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 403 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 422 of file MustExecute.h.

Referenced by checkForAllContext(), findInContextOf(), followUsesInContext(), 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 430 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 458 of file MustExecute.h.

References begin(), and end().

Referenced by followUsesInMBEC().

◆ end() [1/4]

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

Return an universal end iterator.

{

Definition at line 436 of file MustExecute.h.

Referenced by checkForAllContext(), findInContextOf(), followUsesInContext(), and range().

◆ end() [2/4]

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

Definition at line 439 of file MustExecute.h.

◆ end() [3/4]

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

Definition at line 437 of file MustExecute.h.

◆ end() [4/4]

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

Definition at line 440 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 472 of file MustExecute.h.

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

Referenced by followUsesInContext().

◆ 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 483 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 706 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::Instruction::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 763 of file MustExecute.cpp.

References llvm::dbgs(), ExploreInterBlock, findBackwardJoinPoint(), llvm::Instruction::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 444 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 449 of file MustExecute.h.

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

Member Data Documentation

◆ ExploreCFGBackward

const bool llvm::MustBeExecutedContextExplorer::ExploreCFGBackward

Definition at line 520 of file MustExecute.h.

◆ ExploreCFGForward

const bool llvm::MustBeExecutedContextExplorer::ExploreCFGForward

Definition at line 519 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 518 of file MustExecute.h.

Referenced by getMustBeExecutedNextInstruction(), and getMustBeExecutedPrevInstruction().


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