LLVM: llvm::MustBeExecutedIterator Struct Reference (original) (raw)

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

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.

if (...) {

}

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.

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.

while (true) {

if (...)

if (...)

continue;

if (...)

break;

do {

if (...)

continue;

} while (...);

}

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](structllvm%5F1%5F1MustBeExecutedContextExplorer.html "A "must be executed context" for a given program point PP is the set of instructions,...")). 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.