LLVM  10.0.0svn
Public Types | Public Member Functions | Friends | List of all members
llvm::MustBeExecutedIterator Struct Reference

Must be executed iterators visit stretches of instructions that are guaranteed to be executed together, potentially with other instruction executed in-between. More...

#include "llvm/Analysis/MustExecute.h"

Public Types

typedef const Instructionvalue_type
 Type declarations that make his class an input iterator. More...
 
typedef std::ptrdiff_t difference_type
 
typedef const Instruction ** pointer
 
typedef const Instruction *& reference
 
typedef std::input_iterator_tag iterator_category
 
using ExplorerTy = MustBeExecutedContextExplorer
 } More...
 

Public Member Functions

 MustBeExecutedIterator (const MustBeExecutedIterator &Other)
 
 MustBeExecutedIterator (MustBeExecutedIterator &&Other)
 
MustBeExecutedIteratoroperator= (MustBeExecutedIterator &&Other)
 
 ~MustBeExecutedIterator ()
 
MustBeExecutedIteratoroperator++ ()
 Pre- and post-increment operators. More...
 
MustBeExecutedIterator operator++ (int)
 
bool operator== (const MustBeExecutedIterator &Other) const
 } More...
 
bool operator!= (const MustBeExecutedIterator &Other) const
 
const Instruction *& operator* ()
 } More...
 
const InstructiongetCurrentInst () const
 
bool count (const Instruction *I) const
 Return true if I was encountered by this iterator already. More...
 

Friends

struct MustBeExecutedContextExplorer
 

Detailed Description

Must be executed iterators visit stretches of instructions that are guaranteed to be executed together, potentially with other instruction executed in-between.

Given the following code, and assuming all statements are single instructions which transfer execution to the successor (see isGuaranteedToTransferExecutionToSuccessor), there are two possible outcomes. If we start the iterator at A, B, or E, we will visit only A, B, and E. If we start at C or D, we will visit all instructions A-E.

A;
B;
if (...) {
C;
D;
}
E;

Below is the example extneded with instructions F and G. Now we assume F might not transfer execution to it's successor G. As a result we get the following visit sets:

Start Instruction | Visit Set A | A, B, E, F B | A, B, E, F C | A, B, C, D, E, F D | A, B, C, D, E, F E | A, B, E, F F | A, B, E, F G | A, B, E, F, G

A;
B;
if (...) {
C;
D;
}
E;
F; // Might not transfer execution to its successor G.
G;

A more complex example involving conditionals, loops, break, and continue is shown below. We again assume all instructions will transmit control to the successor and we assume we can prove the inner loop to be finite. We omit non-trivial branch conditions as the exploration is oblivious to them. Constant branches are assumed to be unconditional in the CFG. The resulting visist sets are shown in the table below.

A;
while (true) {
B;
if (...)
C;
if (...)
continue;
D;
if (...)
break;
do {
if (...)
continue;
E;
} while (...);
F;
}
G;

Start Instruction | Visit Set A | A, B B | A, B C | A, B, C D | A, B, D E | A, B, D, E, F F | A, B, D, F G | A, B, D, G

Note that the examples show optimal visist sets but not necessarily the ones derived by the explorer depending on the available CFG analyses (see MustBeExecutedContextExplorer). Also note that we, depending on the options, the visit set can contain instructions from other functions.

Definition at line 266 of file MustExecute.h.

Member Typedef Documentation

◆ difference_type

Definition at line 270 of file MustExecute.h.

◆ ExplorerTy

}

Definition at line 276 of file MustExecute.h.

◆ iterator_category

typedef std::input_iterator_tag llvm::MustBeExecutedIterator::iterator_category

Definition at line 273 of file MustExecute.h.

◆ pointer

Definition at line 271 of file MustExecute.h.

◆ reference

Definition at line 272 of file MustExecute.h.

◆ value_type

Type declarations that make his class an input iterator.

{

Definition at line 269 of file MustExecute.h.

Constructor & Destructor Documentation

◆ MustBeExecutedIterator() [1/2]

llvm::MustBeExecutedIterator::MustBeExecutedIterator ( const MustBeExecutedIterator Other)
inline

◆ MustBeExecutedIterator() [2/2]

llvm::MustBeExecutedIterator::MustBeExecutedIterator ( MustBeExecutedIterator &&  Other)
inline

Definition at line 282 of file MustExecute.h.

References Other.

◆ ~MustBeExecutedIterator()

llvm::MustBeExecutedIterator::~MustBeExecutedIterator ( )
inline

Definition at line 294 of file MustExecute.h.

Member Function Documentation

◆ count()

bool llvm::MustBeExecutedIterator::count ( const Instruction I) const
inline

Return true if I was encountered by this iterator already.

Definition at line 326 of file MustExecute.h.

References I.

Referenced by llvm::IRPosition::getAttrs().

◆ getCurrentInst()

const Instruction* llvm::MustBeExecutedIterator::getCurrentInst ( ) const
inline

Definition at line 323 of file MustExecute.h.

◆ operator!=()

bool llvm::MustBeExecutedIterator::operator!= ( const MustBeExecutedIterator Other) const
inline

Definition at line 316 of file MustExecute.h.

◆ operator*()

const Instruction*& llvm::MustBeExecutedIterator::operator* ( )
inline

}

Return the underlying instruction.

Definition at line 322 of file MustExecute.h.

◆ operator++() [1/2]

MustBeExecutedIterator& llvm::MustBeExecutedIterator::operator++ ( )
inline

Pre- and post-increment operators.

{

Definition at line 298 of file MustExecute.h.

◆ operator++() [2/2]

MustBeExecutedIterator llvm::MustBeExecutedIterator::operator++ ( int  )
inline

Definition at line 303 of file MustExecute.h.

◆ operator=()

MustBeExecutedIterator& llvm::MustBeExecutedIterator::operator= ( MustBeExecutedIterator &&  Other)
inline

Definition at line 286 of file MustExecute.h.

References Other, and std::swap().

◆ operator==()

bool llvm::MustBeExecutedIterator::operator== ( const MustBeExecutedIterator Other) const
inline

}

Equality and inequality operators. Note that we ignore the history here. {

Definition at line 312 of file MustExecute.h.

Friends And Related Function Documentation

◆ MustBeExecutedContextExplorer

friend struct MustBeExecutedContextExplorer
friend

Definition at line 355 of file MustExecute.h.


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