Inline cost model
The heuristic that decides which calls get inlined, which makes it one of the most influential and least understood parts of a compiler.
For each call site LLVM estimates what the callee body costs in "instructions" and compares that against a threshold: 225 by default at -O2, 25 at -Oz. The cost isn't counted naively. The inliner simulates what happens when the actual arguments are plugged in, so branches that fold away because an argument is constant don't count, and the last call to a static function earns a big bonus, since the original can then be deleted. GCC works in two stages: an early per-function inliner and an interprocedural one once the call graph is built.
The model is a patchwork of constants tuned against benchmarks for decades. The always_inline and noinline attributes override it, and MLGO tries to replace parts of it with a trained model.