<div dir="ltr">I think the documentation is wrong. Existing function passes frequently insert new intrinsic function declarations, and we expect that to work. The loop vectorizer also inserts calls to non-intrinsic library functions.<div><br></div><div>The intention is that function passes don't introduce new function definitions, because then an outer pass manager would need to discover them and add them to its worklist.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 23, 2017 at 5:19 PM, Evgenii Stepanov via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
how do I insert a call to an external function in a FunctionPass?<br>
My problem is with creation of the declaration for the external function.<br>
<br>
According to <a href="http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class" rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>WritingAnLLVMPass.html#the-<wbr>functionpass-class</a>,<br>
a FunctionPass is not supposed to add or remove functions. I assume<br>
it's also true for function declarations.<br>
<br>
A declaration inserted in doInitialization is cleaned up in<br>
GlobalOptLegacyPass::<wbr>runOnModule, which happens to run before my pass'<br>
runOnFunction().<br>
<br>
Do I need a ModulePass for this?<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>