Master the fundamental concepts of compiler optimization techniques through this focused micro-challenge.
Placing cold error-handling functions in separate translation units or marking them __attribute__((cold)) keeps icache filled with the fast path. LLVM outlines cold blocks from hot functions during optimization.
hot encourages layout near callers; cold moves unlikely blocks away. -freorder-blocks-and-partition is a GCC knob for similar effect.
cLoading…
unlikely() on branches into cold helpersKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will mark functions hot/cold and inspect section placement or size changes. This exercise requires showing icache-friendly layout for the common case.
Demonstrate hot/cold function attributes with performance comparison.
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