Which ONE of the following techniques used in compiler code optimization uses live variable analysis?
View worked solution
Answer: B
Live Variable Analysis (LVA) is a backward data-flow analysis technique used to determine, at each point in a program, which variables may be read in the future before being redefined (i.e., which variables are "live").
Let's analyze the given options to see which technique utilizes this analysis:
- Register assignment to variables (Option B): To allocate a limited number of physical registers to program variables, the compiler must determine which variables are active simultaneously. If two variables are never live at the same time, they can share the same register. This is solved using register allocation via graph-coloring, where the interference graph is constructed directly from the live ranges of variables obtained via Live Variable Analysis. Thus, this is the correct option.
- Run-time function call management (Option A): This is a run-time mechanism managed by the activation stack (stack frames) for handling function calls, parameters, and local variables. It is not a static optimization technique that uses live variable analysis.
- Strength reduction (Option C): This optimization replaces computationally expensive operations with cheaper ones (e.g., replacing with , or optimizing induction variables in loops). It does not require live variable analysis.
- Constant folding (Option D): This is the compile-time evaluation of expressions with constant operands (e.g., replacing with ). It does not depend on live variable analysis.
Therefore, Register assignment to variables is the correct technique that uses live variable analysis.
Free practice · Your answers on this page are not saved.
