How to insert a CallInst which calls to a function from a library



<br>*Hello* <br>*I want to write a pass which insert a new call to a library function* <br>*but I don't know how to create a* *CallInst that calls a* <br>*function like "pthread_create",*<br>*can anyone help* *me with this problem?*<br><br>

|

First you have to create a declaration for the library function. Use Module::getOrInsertFunction for that; you’ll get back a Value representing the library function. Once you’ve got that, pass that Value in as the callee of the call instruction.