Functions can certainly be built-in if certain conditions are met, but they are definitely not always integral. Most often, calling a function calls a genuine call without a function. A function call has some additional costs associated with it, such as
- Preparing parameters for a function in accordance with the function call convention
- Getting the return value of a function
- Functional prologue and epilogue code responsible for managing local memory, managing parameter memory and storing register values.
- The function can compress some processor registers, thereby violating their use in the calling code and thereby hinder optimization
- Less processor-friendly and caching non-linear code behavior
All this will lead to overhead, probably would not have happened if the body of the function were embedded inline in the calling code.
source share