Handmade Hero»Forums»Code
Henry Kloren
15 posts
Day 5: Pointer Aliasing Effects Inlining?
Edited by Henry Kloren on
Hi guys! On day 5 around 9:10 - 9:45 Casey explains inlining, and seems to be indicating that changing an argument from a pointer to a value may make this easier / possible for the compiler. I understand his explanation of pointer aliasing, that occurred just prior, and I understand that the compiler has a harder time optimizing around pointers, but I don't understand how any of this effects the compiler's ability to inline. Was Casey's mention of function inlining, perhaps, just a tangential topic, given the function was small, or is there actually some way having the argument passed in as a pointer instead of a value could deter compiler inlining.

Thanks All!
EDIT: Link to Video at 9:10
https://youtu.be/w7ay7QXmo_o?t=550
Simon Anciaux
1337 posts
Day 5: Pointer Aliasing Effects Inlining?
The compiler decides what to inline and what not to inline. And the main (only ?) reason for inlining is to improve performances. So if passing a struct by value allows better optimizing and thus better performance, the compiler may be more inclined to inline the function.

That said, the only way to know if a function has been inlined is to look at the disasembly (or use __forceinline but you need a really good reason for doing that). You can read Inline Functions on msdn for some information.