Basic Blocks and Control-Flow Graphs
Build a control-flow graph from jump boundaries and state which exceptional exits are part of the program model.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A block has one entry at its first instruction
Begin a block at the function entry, every possible jump target, and each instruction immediately after a control transfer that has a following instruction. A block ends with a transfer or just before the next leader. Add an edge to each possible successor, including implicit fallthrough where permitted. Reaching an ordinary instruction in the middle then means executing from the block’s first instruction under the intended instruction model.
The edges determine what later analyses can see
A conditional jump has two successors even if a later optimization can prove one infeasible. A call that can throw may need an exceptional edge to a handler. Leaving it out would make subsequent analyses unsound for the chosen observable behavior. Dominator analysis reasons about all entry paths in this graph. Liveness analysis computes where a value may be read along those paths.[1][2]