LLVM 22.0.0git
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.
typedef std::ptrdiff_t difference_type
typedef const Instruction ** pointer
typedef const Instruction *& reference
typedef std::input_iterator_tag iterator_category
using ExplorerTy = MustBeExecutedContextExplorer
 }

Public Member Functions

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

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;
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34

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;
#define F(x, y, z)
Definition MD5.cpp:55
#define G(x, y, z)
Definition MD5.cpp:56

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

Member Typedef Documentation

◆ difference_type

Definition at line 278 of file MustExecute.h.

◆ ExplorerTy

◆ iterator_category

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

Definition at line 281 of file MustExecute.h.

◆ pointer

◆ reference

◆ value_type

Type declarations that make his class an input iterator.

{

Definition at line 277 of file MustExecute.h.

Constructor & Destructor Documentation

◆ MustBeExecutedIterator() [1/2]

llvm::MustBeExecutedIterator::MustBeExecutedIterator ( const MustBeExecutedIterator & Other)
default

◆ MustBeExecutedIterator() [2/2]

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

Definition at line 288 of file MustExecute.h.

References llvm::move(), MustBeExecutedIterator(), and llvm::Other.

◆ ~MustBeExecutedIterator()

llvm::MustBeExecutedIterator::~MustBeExecutedIterator ( )
default

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::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 MustBeExecutedIterator(), and llvm::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.

References MustBeExecutedIterator().

Referenced by operator++().

◆ operator++() [2/2]

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

Definition at line 311 of file MustExecute.h.

References MustBeExecutedIterator(), and operator++().

◆ operator=()

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

Definition at line 292 of file MustExecute.h.

References MustBeExecutedIterator(), llvm::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 MustBeExecutedIterator(), and llvm::Other.

◆ MustBeExecutedContextExplorer

friend struct MustBeExecutedContextExplorer
friend

Definition at line 375 of file MustExecute.h.

References MustBeExecutedContextExplorer.

Referenced by MustBeExecutedContextExplorer.


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