Compilers

In a control-flow graph, what do the nodes and edges represent?

  1. ANodes are variables, and edges are the order in which values were assigned
  2. BNodes are basic blocks, and edges are branches or transitions between blocks
  3. CNodes are functions, and edges are include relationships between files
Show answer and explanation

Answer: B. Nodes are basic blocks, and edges are branches or transitions between blocks

A control-flow graph has basic blocks as nodes and, as edges, the possible transitions from one block to the next: both targets of a conditional branch, or falling through to the following block. Back edges reveal loops, and the graph supports analyses of where variable values flow. Calls between functions are shown in a separate call graph, and file include relationships are unrelated.

  • A. It is not a graph of variables and assignment order.
  • B. Correct. It shows basic blocks and the transitions between them.
  • C. Function calls are represented in a separate call graph.
Practice this topic Back to topic

More Compilers questions

  1. Which is a characteristic of an IR in SSA form?
  2. Converting the code above to SSA form inserts an expression like "x3 = φ(x1, x2)" after the if statement. What does the φ function do?
  3. Which is an example of constant folding by a compiler?
  4. After repeatedly applying constant propagation and constant folding to the code above, what does it finally become?
  5. Which describes applying common subexpression elimination to the code above?