Compilers
Which optimization does link-time optimization (LTO) make possible?
- AInlining and similar optimizations across separate source files
- BUnrolling loops, but only within a single function
- CLinking becomes unnecessary, and object files can be run directly as they are
Show answer and explanation
Answer: A. Inlining and similar optimizations across separate source files
Normal compilation translates each source file to machine code separately, so the contents of functions in other files are invisible and cross-file inlining or constant propagation is impossible. With LTO, each file is kept as an intermediate representation and the whole program is optimized together at link time. This enables cross-file inlining and removing functions that are never called. Unrolling loops within a function is possible with normal compilation.
- A. Correct. Optimization across files becomes possible.
- B. Unrolling loops within a function works in normal compilation too.
- C. Linking is still required.