title: LLVM Insert function call defined from another file
body: <p>I want to insert a function all before a certain instruction but the function call is defined in another file. I tried</p>
  <pre><code>IRBuilder&lt;&gt; Builder(pi);
  CallInst *callOne = Builder.CreateCall(func_ins, &quot;foo&quot;);
  </code></pre>
  <p>where <code>func_ins</code> is <code>Function*</code>(or <code>Value*</code> to be more general) and <code>foo</code> is the variable name prefix of calling function got assigned.
  Since this function is defined in another file I've no idea where the pointer <code>func_ins</code> should point to so I just set it to <strong>NULL</strong> but it didn't work.</p>
  <p>Can anyone give me some hints on how to resolve this problem?</p>
  <p>One more issue is can I use <code>WriteBitcodeToFile</code> to dump the instrumented code which has external function call to file because I‘m wondering it may report <code>Referencing function in another module</code> or <code>Broken Module</code> while performing module checking?</p>