<div dir="ltr">Hi Soham,<div><br></div><div>Are you intending to use the inline keyword in order to control the inlining optimization?</div><div><br></div><div>The inline keyword is not doing this, it is changing the linkage type of the symbol and instruct the compiler to discard it if there is no call left, and also will instruct the linker to deduplicate. For instance if multiple file include a header that defines an inline function, this function could end up in multiple objects. Without the inline keyword you would get linker errors for duplicate symbols.</div><div><br></div><div>So, the question become: why do you want foo to be inline in bar? If it is for performance then you don't need the keyword and you should rely on the optimizer to "do the right thing": running `opt -O2` on the resulting .ll file you get after llvm-link and after running your pass that adds the call should be enough.</div><div><br></div><div>Best,</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div><div><br><br><div class="gmail_quote"><div dir="ltr">Le mar. 15 mai 2018 à 16:34, Soham Sinha via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>How can I inline a function mentioned in other file?</div><div><br></div><div>I have an inline function <i>foo</i> in C source file (a.c) which is not referenced in this file. I compile this file to a.ll (I notice that the compiled a.ll doesn't have <i>foo</i>'s definition, probably because it was inlined but not called anywhere)</div><div>I have another C source file b.c with function <i>bar</i>; I compile this to b.ll</div><div>I link these two files with llvm-link</div><div>I have written a pass which inserts <i>foo </i>function calls to the bar function at some points. I want foo function calls to be <i>inlined</i>. However, I get  compilation error because <i>foo </i>is not found (a.ll doesn't have foo)</div><div>If I remove the inline attribute of foo in a.c, I get the correctly compilation, with calls to foo inserted in bar from b.c</div><div>How do I achieve this kind of inline-ing?</div><div><br clear="all"><div><div class="m_8085992196891104691gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Regards,<div>Soham Sinha</div><div>PhD Student, Department of Computer Science</div><div>Boston University</div></div></div></div></div></div></div></div>
</div></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></div></div>