Expand description
Public API for inline_pass.
Function inlining pass.
Replaces call instructions to small, non-recursive, non-variadic
functions with a copy of the callee body.
§Algorithm
For each eligible call site in a caller function:
- Split the caller block at the call instruction, producing a pre-block (instructions before the call) and a post-block (instructions after the call, plus the original terminator).
- Clone the callee’s blocks into the caller, mapping:
- Callee
Argument(ArgId(i))→ the i-th call argument. - Callee
InstrId(j)→InstrId(caller_instr_count + j). - Callee
BlockId(k)→BlockId(caller_block_count + k).
- Callee
- Wire the pre-block to the cloned callee entry with an unconditional branch.
- Replace each
ret %vin the clone withbr post-block, and collect return values into a phi at the head of the post-block (or directly if there is only one return site). - Remove the original call instruction.
§Eligibility
A call site is inlineable when:
- The callee is a definition (not a declaration).
- The callee is not variadic.
- The call is not recursive (callee ≠ caller by name).
- The callee body has at most
size_limitnon-terminator instructions.
Structs§
- Inliner
- Function inlining pass.