Questions: Procedure Inlining Optimization

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A compiler inlines the call `square(5)`, replacing it with `5 * 5` in the caller. What optimization is most likely to follow immediately?

ADead code elimination removes the now-unreachable square function definition
BConstant folding reduces `5 * 5` to `25` at compile time
CRegister allocation improves because one fewer function call means fewer callee-saved registers
DLoop unrolling becomes possible because the inlined body reveals a hidden iteration
Question 2 Multiple Choice

A function called from 50 different sites is aggressively inlined everywhere. What is the primary risk that could make this slower than not inlining?

AThe program stack grows too large because inlined code has no stack frame discipline
BInlined code cannot be shared across call sites, leading to subtle behavioral differences
CCode size grows 50x, increasing instruction cache pressure and potentially causing more cache misses
DRegister allocation becomes impossible when the inlined function has more than 4 local variables
Question 3 True / False

The primary benefit of procedure inlining is often not the elimination of call overhead itself, but enabling subsequent optimizations like constant propagation and dead code elimination that become visible only after inlining.

TTrue
FFalse
Question 4 True / False

Recursive functions are ideal candidates for inlining because their repeated structure creates many opportunities for constant propagation and loop optimization.

TTrue
FFalse
Question 5 Short Answer

Why is procedure inlining typically performed early in the compiler's optimization pipeline rather than as one of the last passes?

Think about your answer, then reveal below.