LLVM  13.0.0git
Public Types | Public Member Functions | Public Attributes | 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"

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

Public Types

typedef std::ptrdiff_t difference_type
 
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...
 

Public Attributes

const typedef Instructionvalue_type
 Type declarations that make his class an input iterator. More...
 
const typedef Instruction ** pointer
 
const typedef Instruction *& reference
 

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

Member Typedef Documentation

◆ difference_type

Definition at line 276 of file MustExecute.h.

◆ ExplorerTy

}

Definition at line 282 of file MustExecute.h.

◆ iterator_category

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

Definition at line 279 of file MustExecute.h.

Constructor & Destructor Documentation

◆ MustBeExecutedIterator() [1/2]

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

Definition at line 284 of file MustExecute.h.

References Other.

◆ MustBeExecutedIterator() [2/2]

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

Definition at line 288 of file MustExecute.h.

References Other.

◆ ~MustBeExecutedIterator()

llvm::MustBeExecutedIterator::~MustBeExecutedIterator ( )
inline

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

References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::FORWARD, and I.

Referenced by llvm::MustBeExecutedContextExplorer::findInContextOf().

◆ getCurrentInst()

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

Definition at line 331 of file MustExecute.h.

◆ operator!=()

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

Definition at line 324 of file MustExecute.h.

References Other.

◆ operator*()

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

}

Return the underlying instruction.

Definition at line 330 of file MustExecute.h.

◆ operator++() [1/2]

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

Pre- and post-increment operators.

{

Definition at line 306 of file MustExecute.h.

Referenced by operator++().

◆ operator++() [2/2]

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

Definition at line 311 of file MustExecute.h.

References operator++().

◆ operator=()

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

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

References Other.

Friends And Related Function Documentation

◆ MustBeExecutedContextExplorer

friend struct MustBeExecutedContextExplorer
friend

Definition at line 375 of file MustExecute.h.

Member Data Documentation

◆ pointer

const typedef Instruction** llvm::MustBeExecutedIterator::pointer

Definition at line 277 of file MustExecute.h.

◆ reference

const typedef Instruction*& llvm::MustBeExecutedIterator::reference

Definition at line 278 of file MustExecute.h.

◆ value_type

const typedef Instruction* llvm::MustBeExecutedIterator::value_type

Type declarations that make his class an input iterator.

{

Definition at line 275 of file MustExecute.h.


The documentation for this struct was generated from the following files:
F
#define F(x, y, z)
Definition: MD5.cpp:56
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::ARM_PROC::A
@ A
Definition: ARMBaseInfo.h:34
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")