Home

noinline

Noinline is a directive used in several programming languages to prevent the compiler from inlining a function or lambda. Inlining is the optimization that substitutes a function call with the body of the function, reducing call overhead and enabling further optimizations. When noinline is applied, the call remains a distinct call, preserving function boundaries, which can help with debugging, function pointers, and code layout, but may reduce certain performance benefits or increase code size.

In Kotlin, noinline is a modifier applied to a lambda parameter of an inline function to prevent

In Rust, inlining is controlled at the function level with attributes. The attribute #[inline(never)] applied to

In C and C++, compilers such as GCC and Clang provide the noinline attribute to prevent inlining.

Noinline behavior is not portable across languages; syntax and semantics vary by compiler and language. It

that
lambda
from
being
inlined.
This
is
necessary
when
the
lambda
is
stored,
passed
as
a
value,
or
used
in
a
way
that
must
preserve
its
identity.
Example
usage
is
inline
fun
perform(noinline
action:
()
->
Unit)
{
/*
...
*/
}.
a
function
disables
inlining
for
that
function.
Example:
#[inline(never)]
fn
compute(...)
{
...
}
This
can
be
useful
to
keep
a
stable
call
boundary
for
debugging
or
to
avoid
code
size
growth
from
aggressive
inlining.
It
can
be
applied
to
a
function
declaration
or
definition,
for
example:
void
process(...)
__attribute__((noinline));
or
__attribute__((noinline))
void
process(...);
This
helps
manage
performance
characteristics,
code
size,
and
interactions
with
linker
or
profiling
tools.
is
commonly
used
to
control
trade-offs
between
speed,
binary
size,
and
debugging
fidelity,
or
to
preserve
behavior
that
depends
on
distinct
function
boundaries.