Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSVC - Any way to check if function is actually inlined?

Tags:

c++

visual-c++

I have to check whether a function is being inlined by the compiler. Is there any way to do this without looking at assembly (which I don't read). I have no choice in figuring this out, so I would prefer if we could not discuss the wisdom of doing this. Thanks!

like image 861
Steve Avatar asked Dec 14 '09 19:12

Steve


People also ask

How do you check if a function is inlined or not?

The decision to inline or not a function is made by compiler. And since it is made by compiler, so YES, it can be made at compile time only. So, if you can see the assembly code by using -S option (with gcc -S produces assembly code), you can see whether your function has been inlined or not. Save this answer.

When can a function be inlined?

An inline function is one for which the compiler copies the code from the function definition directly into the code of the calling function rather than creating a separate set of instructions in memory. This eliminates call-linkage overhead and can expose significant optimization opportunities.

Which functions Cannot be inlined?

The only situation in which a function cannot be inlined is if there is no definition for the function in the compilation unit.

What are the conditions of inlining a function?

Inline function may increase efficiency if it is small. 2) If a function contains static variables. 3) If a function is recursive. 4) If a function return type is other than void, and the return statement doesn't exist in function body.


1 Answers

If you enable warnings C4714, C4710, and C4711, it should give you fairly detailed information about which functions are and aren't inlined.

like image 181
DrPizza Avatar answered Nov 09 '22 05:11

DrPizza