Questions: Use-Definition Chains

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Variable x is assigned on line 5 (x = 10) and on line 8 (x = y + 2). An if-statement between lines 5 and 12 can route control through line 8 or bypass it. At line 12, the use of x is analyzed. What does its U-D chain contain?

AOnly line 8, since it is the most recent possible definition
BOnly line 5, since it is the first definition and line 8 does not always execute
CBoth line 5 and line 8, because both can reach line 12 along different control flow paths
DNothing, because U-D chains only apply to variables with a single unambiguous definition
Question 2 Multiple Choice

A compiler wants to apply constant propagation to replace a use of variable x with a literal. Using U-D chains, what condition must hold?

AThe variable x must not be redefined anywhere in the entire function
BThe U-D chain for that specific use must contain exactly one definition, and that definition must assign a constant value
CAll definitions of x in the program must assign the same constant value
DThe use must appear in the same basic block as the definition with no control flow in between
Question 3 True / False

U-D chains allow a compiler to answer data-dependence queries with targeted lookups rather than re-solving reaching-definitions equations for every optimization pass.

TTrue
FFalse
Question 4 True / False

A use of a variable generally has exactly one definition in its U-D chain, because programs is expected to assign a variable before using it.

TTrue
FFalse
Question 5 Short Answer

Why are U-D chains described as enabling 'sparse' analysis, and how do they improve on using reaching-definitions sets directly for each optimization query?

Think about your answer, then reveal below.