Master the fundamental concepts of optimizations through this focused micro-challenge.
Function inlining replaces a call site with the callee's body, enabling further optimization across the old boundary. LLVM's inliner uses cost heuristics; C++ inline and LTO push this aggressively. Too much inlining blows code size.
Small callees, hot call sites, and functions marked always_inline are candidates. Copy parameters to locals, rename to avoid clashes, insert return handling at the call site.
cLoading…
Production compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will implement function inline expansion on your IR. This exercise requires copying a callee's instructions to the call site, mapping arguments to parameters, and splicing the result back into the caller.
Implement function inline expansion optimization.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github