struct MustBeExecutedIterator

Declaration

struct MustBeExecutedIterator { /* full declaration omitted */ };

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. 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.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:272

Member Variables

private llvm::MustBeExecutedIterator::VisitedSetTy Visited
A set to track the visited instructions in order to deal with endless loops and recursion.
private llvm::MustBeExecutedIterator::ExplorerTy& Explorer
A reference to the explorer that created this iterator.
private const llvm::Instruction* CurInst
The instruction we are currently exposing to the user. There is always an instruction that we know is executed with the given program point, initially the program point itself.
private const llvm::Instruction* Head
Two positions that mark the program points where this iterator will look for the next instruction. Note that the current instruction is either the one pointed to by Head, Tail, or both.
private const llvm::Instruction* Tail
Two positions that mark the program points where this iterator will look for the next instruction. Note that the current instruction is either the one pointed to by Head, Tail, or both.

Method Overview

Methods

MustBeExecutedIterator(
    const llvm::MustBeExecutedIterator& Other)

Declared at: llvm/include/llvm/Analysis/MustExecute.h:284

Parameters

const llvm::MustBeExecutedIterator& Other

MustBeExecutedIterator(
    llvm::MustBeExecutedIterator&& Other)

Declared at: llvm/include/llvm/Analysis/MustExecute.h:286

Parameters

llvm::MustBeExecutedIterator&& Other

MustBeExecutedIterator(
    llvm::MustBeExecutedIterator::ExplorerTy&
        Explorer,
    const llvm::Instruction* I)

Description

Private constructors.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:342

Parameters

llvm::MustBeExecutedIterator::ExplorerTy& Explorer
const llvm::Instruction* I

const llvm::Instruction* advance()

Description

Try to advance one of the underlying positions (Head or Tail).

Declared at: llvm/include/llvm/Analysis/MustExecute.h:354

Returns

The next instruction in the must be executed context, or nullptr if none was found.

bool count(const llvm::Instruction* I) const

Description

Return true if \p I was encountered by this iterator already.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:332

Parameters

const llvm::Instruction* I

const llvm::Instruction* getCurrentInst() const

Declared at: llvm/include/llvm/Analysis/MustExecute.h:329

void reset(const llvm::Instruction* I)

Description

Reset the iterator to its initial state pointing at \p I.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:345

Parameters

const llvm::Instruction* I

void resetInstruction(const llvm::Instruction* I)

Description

Reset the iterator to point at \p I, keep cached state.

Declared at: llvm/include/llvm/Analysis/MustExecute.h:348

Parameters

const llvm::Instruction* I

~MustBeExecutedIterator()

Declared at: llvm/include/llvm/Analysis/MustExecute.h:300