Questions: Reaching Definitions Analysis

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Block B1 assigns `x = 5` and block B2 assigns `x = 10`. Both B1 and B2 are predecessors of block B3, which contains the expression `y = x + 1`. Can constant propagation replace `x` with a constant value in B3?

AYes — x = 5 should be used because B1 is likely executed first
BYes — x = 10 should be used because it is the more recent assignment
CNo — both definitions reach B3, so the compiler cannot determine a unique constant value for x
DNo — reaching definitions cannot track variables across multiple blocks
Question 2 Multiple Choice

Why does reaching definitions analysis use union (not intersection) to combine facts from predecessor blocks at a join point?

ABecause it is a must-analysis: a definition must reach via all paths to be considered live
BBecause it is a may-analysis: a definition reaches a point if it arrives via at least one path
CBecause the kill sets require union to correctly remove overwritten definitions
DBecause intersection would make the analysis unsound, producing too few reaching definitions
Question 3 True / False

If a variable x is assigned in every predecessor block of block B, then every one of those definitions appears in IN[B].

TTrue
FFalse
Question 4 True / False

A basic block's kill set contains definitions that occur after that block in the control flow graph and that assign to the same variable.

TTrue
FFalse
Question 5 Short Answer

Explain why reaching definitions is classified as a 'may-analysis' and what practical consequence this has for how compilers use its results.

Think about your answer, then reveal below.