<p dir="ltr">There are lots of reasons a compiler will choose not to inline a function (inlining, while usually a win for performance is a time/space tradeoff, so often a compiler will try not to make a function 'too large' by inlining too many functions into it - it will simply so at some threshold)</p>

<p dir="ltr">In any case, if the correctness of your program depends on the function being inlined, you can use the always_inline attribute.</p>
<div class="gmail_quote">On Sep 4, 2014 5:46 AM, "David Sela" <<a href="mailto:sela.david@gmail.com">sela.david@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi Anton,<div>Thanks for the answer.<br></div><div><br></div><div>The link you provided doesn't answer the question. It lists the ways to overcome the linking error if the inline was not successful.</div>


<div>The only condition that is found there to make the compiler not inline is "<span style="font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19.5px">when compiling without optimization</span>".</div>


<div><br></div><div>I asked the question in the forum because I think that this info is not documented and most chances that the people that know the code inside-out will know the answer.</div><div><br></div><div>Thanks,</div>


<div>David</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 3:30 PM, Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info" target="_blank">anton@korobeynikov.info</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello<br>
<br>
First of all, such a question definitely belongs to cfe-dev, not llvmdev.<br>
<br>
Next, 'inline' is certainly a hint, and the full the answer is a first<br>
entry here: <a href="http://clang.llvm.org/compatibility.html#inline" target="_blank">http://clang.llvm.org/compatibility.html#inline</a><br>
<div><div><br>
On Thu, Sep 4, 2014 at 3:42 PM, David Sela <<a href="mailto:sela.david@gmail.com" target="_blank">sela.david@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I want to have some functions in my code inline so I use the inline keyword:<br>
><br>
> inline void foo() {}<br>
><br>
> On some functions the compiler inlines the function but it fails to do so on<br>
> other functions and thus I get a linkage error:<br>
><br>
> error: undefined reference to 'foo'<br>
><br>
> What are the conditions that make the compiler refuse inline?<br>
><br>
> Thanks,<br>
> David<br>
><br>
> p.s. I know that there are ways to pass compilation and let the compiler<br>
> decide if to inline like using __attribute__((always_inline)) but I must<br>
> have the function inline.<br>
><br>
</div></div>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
<span><font color="#888888"><br>
<br>
<br>
--<br>
With best regards, Anton Korobeynikov<br>
Faculty of Mathematics and Mechanics, Saint Petersburg State University<br>
</font></span></blockquote></div><br></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div>