[−][src]Module c2rust_transpile::cfg::loops
This module contains stuff related to choosing better loops in Relooper. The problem is simple:
there is a point in the relooper algorithm where we commit to making a Loop
structure. At that
point, we partition blocks into those that go into the loop and those that go after the loop.
Relooper gives us a handful of blocks which must go in the loop, but we have some freedom to choose which other blocks we want to also push into the loop.
Our choice can be informed by one of two strategies:
-
Do what C does. We can try to match what C does by keeping track of which blocks in CFG formed loops in the initial C source. This information needs to be built up when initially building the CFG .
-
Try to avoid jump-table's. The more entries we push into the loop, the more we risk creating a massive loop that starts with a jump table. OTOH, the more entries we put after the loop, the more likely we are to have a jump table right after the loop.
Structs
LoopId | These IDs identify groups of basic blocks corresponding to loops in a CFG. |
LoopInfo | Stores information about loops in a CFG. |
Functions
heuristic_loop_body | Use heuristics to decide which blocks to move into the loop body. |
match_loop_body | Modifies the |