为什么对于内联函数,编译器会尝试在每个调用点生成代码

why for inline function, the compiler will try to generate code at each point of call

我目前正在通过阅读 Bjarne Stroustrup Programming_ Principles and Practice Using C++ 来了解 c++ 的内联函数。

作者提到

(for inline function) the compiler will try to generate code for the function at each point of call rather than using function-call instructions to use common code.

我不确定 "generate code for the function at each point of call" 和 "using function-call instruction to use common code" 之间有什么区别。区分这两个概念的根本区别是什么?

对于非内联函数,函数代码的单个副本存在于内存中的某处,并且编译器会在每个调用站点生成一条 CALL 指令以跳转到该内存位置。当函数退出时,执行流程会跳回调用处。

对于内联函数,编译器会将函数代码的副本直接合并到每个调用点的代码中。该函数不会单独存在于内存中,并且不会生成 CALL 指令来跳入函数并返回。