C++ inline functions using GCC - why the CALL?

后端 未结 7 706
感动是毒
感动是毒 2020-12-28 17:55

I have been testing inline function calls in C++.

Thread model: win32
gcc version 4.3.3 (4.3.3-tdm-1 mingw32)

Stroustrup in The C++ Program

7条回答
  •  醉话见心
    2020-12-28 18:09

    Are you looking at a debug build (optimizations disabled)? Compilers usually disable inlining in "debug" builds because they make debugging harder.

    In any case, the inline specified is indeed a hint. The compiler is not required to inline the function. There are a number of reasons why any compiler might decide to ignore an inline hint:

    • A compiler might be simple, and not support inlining
    • A compiler might use an internal algorithm to decide on what to inline and ignore the hints.
      (sometimes, the compiler can do a better job than you can possibly do at choosing what to inline, especially in complex architectures like IA64)
    • A compiler might use its own heuristics to decide that despite the hint, inlining will not improve performance

提交回复
热议问题