title: What are guiding principles of expansion of callee inside the caller (Inlining - Compiler Optimization)
body: <p>My understanding is that compilers follow certain semantics that decide whether or not a function should be expanded inline. for example, if the callee unconditionally (no if/élse-if to return) returns a value, it may be expanded in caller itself. Similarly, function call overhead can also guide this expansion.(I may be completely wrong)</p>
  
  <p>Similarly, the hardware parameters like cache-usage may also play a role in expansion.</p>
  
  <p>As a programmer, I want to understand these semantics and the algorithms which guide inline expansion. Ultimately, I should be able to write(or recognize) a code that surely will be inlined(not-inlined). I don't mean to override compiler or that I think I would be able to write a code better than compiler itself. The question is rather to understand internals of the compilers.</p>
  
  <p>EDIT: Since I use gcc/g++ in my work, we can limit the scope to these two alone. Though,  I was of opinion  that there will be several things common across compilers in this context. </p>