UP | HOME

Control-Flow Analysis
COP-5621, Spring 2024

Table of Contents

Review

Questions about the last class?

Questions about project setup

Homework discussion

What is a Control-Flow Graph (CFG)?

Why Would We Need a CFG?

Elements of a CFG

Examples

Conditional statements

Loops

Diagrams

An algorithm for CFG construction

  1. Create entry and exit nodes (used for optimization later)
  2. Collect the leaders of the basic blocks, i.e., each line that starts a basic block, and creating a new node for each
  3. create edges between basic blocks, looking at each basic block's ending goto/ifgoto and create an edge to the target leader

How do we know when something is a leader, i.e., the first line of a basic block?

  1. First line of the program
  2. Target of a goto/ifgoto
  3. Line after a goto/ifgoto

Structural analysis

Implementing control-flow analysis

Author: Paul Gazzillo

Created: 2024-02-08 Thu 10:51