Machine-translated by Google. Questions are authored in English.
Top

Discussion

Register allocation is commonly modelled as

  • A.a shortest path problem over the flow graph
  • B.a sorting problem over the variables of the procedure
  • C.a parsing problem over the intermediate code
  • D.a graph colouring problem over an interference graph

Answer: D

Correct answer: a graph colouring problem over an interference graph

Each value is a node, and two nodes are joined if their live ranges overlap so that they cannot share a register. Assigning \( k \) registers is then colouring the graph with \( k \) colours. The problem is NP-complete in general, so compilers use Chaitin-style heuristics and spill to memory when the colouring fails.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.