coder.inline
Control inlining of current function in generated code
Description
coder.inline("always")
inlines the
current function (the function in which coder.inline
appears) in the
generated code. Use the coder.inline("always")
optimization directive to
replace a function call with the body of the called function. Inlining eliminates the
overhead of a function call and can create opportunities for further optimization of the
generated C/C++ code. However, inlining can generate larger, more complex C/C++ code.
The coder.inline("always")
directive does not support the inlining
of:
Entry-point functions
Recursive functions
Functions that contain
parfor
-loopsFunctions called from
parfor
-loops
coder.inline("never")
prevents
inlining of the function in which it is used in the generated code. Use the
coder.inline("never")
optimization directive when you want to simplify
the mapping between the MATLAB® source code and the generated code.
The coder.inline("never")
directive does not prevent the inlining of:
Empty functions
Functions that return constant output
To prevent inlining even in these situations, use the coder.ignoreConst
(MATLAB Coder) function on an input at the function call site in your
MATLAB code. For more information, see Resolve Issue: coder.inline("never") and coder.nonInlineCall Do Not Prevent Function Inlining (MATLAB Coder).
coder.inline("default")
instructs the code generator to use
internal heuristics to determine whether to inline the current function. Usually, these
heuristics produce highly optimized code.
Examples
Tips
If you use the
codegen
(MATLAB Coder) or thefiaccel
(Fixed-Point Designer) command, you can disable inlining for all functions by using the-O disable:inline
option.You might have different speed and readability requirements for C/C++ code generated from functions that you write as compared to C/C++ code generated from MathWorks® functions. Additional global settings enable you to control inlining for these two parts of the generated code base. See Control Inlining to Fine-Tune Performance and Readability of Generated Code (MATLAB Coder).
Extended Capabilities
Version History
Introduced in R2011a