sway_ir::optimize::inline

Function inline_some_function_calls

Source
pub fn inline_some_function_calls<F: Fn(&Context<'_>, &Function, &Value) -> bool>(
    context: &mut Context<'_>,
    function: &Function,
    predicate: F,
) -> Result<bool, IrError>
Expand description

Inline function calls based on a provided heuristic predicate.

There are many things to consider when deciding to inline a function. For example:

  • The size of the function, especially if smaller than the call overhead size.
  • The stack frame size of the function.
  • The number of calls made to the function or if the function is called inside a loop.
  • A particular call has constant arguments implying further constant folding.
  • An attribute request, e.g., #[always_inline], #[never_inline].