LLVM 22.0.0git
|
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 Instruction * | value_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) | |
MustBeExecutedIterator & | operator= (MustBeExecutedIterator &&Other) |
~MustBeExecutedIterator ()=default | |
MustBeExecutedIterator & | operator++ () |
Pre- and post-increment operators. | |
MustBeExecutedIterator | operator++ (int) |
bool | operator== (const MustBeExecutedIterator &Other) const |
} | |
bool | operator!= (const MustBeExecutedIterator &Other) const |
const Instruction *& | operator* () |
} | |
const Instruction * | getCurrentInst () const |
bool | count (const Instruction *I) const |
Return true if I was encountered by this iterator already. |
Friends | |
struct | MustBeExecutedContextExplorer |
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.
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 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.
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.
typedef std::ptrdiff_t llvm::MustBeExecutedIterator::difference_type |
Definition at line 278 of file MustExecute.h.
}
Definition at line 284 of file MustExecute.h.
typedef std::input_iterator_tag llvm::MustBeExecutedIterator::iterator_category |
Definition at line 281 of file MustExecute.h.
Definition at line 279 of file MustExecute.h.
Definition at line 280 of file MustExecute.h.
Type declarations that make his class an input iterator.
{
Definition at line 277 of file MustExecute.h.
|
default |
References MustBeExecutedIterator(), and llvm::Other.
Referenced by MustBeExecutedIterator(), MustBeExecutedIterator(), operator!=(), operator++(), operator++(), operator=(), and operator==().
|
inline |
Definition at line 288 of file MustExecute.h.
References llvm::move(), MustBeExecutedIterator(), and llvm::Other.
|
default |
|
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().
|
inline |
Definition at line 331 of file MustExecute.h.
|
inline |
Definition at line 324 of file MustExecute.h.
References MustBeExecutedIterator(), and llvm::Other.
|
inline |
|
inline |
Pre- and post-increment operators.
{
Definition at line 306 of file MustExecute.h.
References MustBeExecutedIterator().
Referenced by operator++().
|
inline |
Definition at line 311 of file MustExecute.h.
References MustBeExecutedIterator(), and operator++().
|
inline |
Definition at line 292 of file MustExecute.h.
References MustBeExecutedIterator(), llvm::Other, and std::swap().
|
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.
|
friend |
Definition at line 375 of file MustExecute.h.
References MustBeExecutedContextExplorer.
Referenced by MustBeExecutedContextExplorer.