<div dir="ltr">To follow on to Craig's note about it being a hint, note that the inline keyword is largely there to adjust the linkage type of the symbol so that it can be defined in a header without getting multiply defined symbol errors, and to allow it to be elided by the compiler when it isn't used in a translation unit that included that header. Without LTO, defining an inline function in a header can aid in inlining simply by making the definition available to all callers. But there is a cost (compile time, memory overhead) for defining a function in the header and therefore in all translation units that include it. With LTO (or ThinLTO), you can move these definitions to a source file (in which case the inline keyword *must* be removed), and it will still be available to inline as needed. LTO does this by merging all IR, which of course comes with a potentially big cost to memory and loss of incremental compiles. With ThinLTO (-flto=thin) the IR will be temporarily imported into other modules where it is thought to be profitable to inline.<div><div><div><br></div><div>To really force inlining, you would instead need to use the attribute "__attribute__((always_inline))". However, with or without LTO, it is typically better to let the compiler use its heuristics to determine whether inlining is profitable.<br></div></div></div><div><br></div><div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 18, 2019 at 10:52 PM Craig Topper via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">The inline keyword is a hint. The inliner calculates the cost of inlining a function using various heuristics. If the cost is too high it won't be inlined. The inline keyword increases the threshold that is considered too costly.<div><br><div><div><div dir="ltr" class="gmail-m_2953935106124885339gmail-m_-1652468208988819837gmail_signature">~Craig</div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 18, 2019 at 10:42 PM Peng Yu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
With LTO, it seems that compilers should have the information to<br>
decide whether to inline a function or not. In this case, is it<br>
unnecessary to specify functions as inline in C/C++ code?<br>
<br>
-- <br>
Regards,<br>
Peng<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_2953935106124885339gmail_signature"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div>