title: LLVM cannot see static function
body: <p>I am trying to instrument the linux kernel code to insert a function call in every function right after a <code>BitCast</code> instruction.</p>
  <p>So I modify the C code to <code>#include &lt;linux/my_header.h&gt;</code> where I have my printer function.</p>
  <p>The header looks something like this.</p>
  <pre><code>#ifndef __header_ID
  #define __header_ID
  
  static inline void print_typecast(...){
      printk(...);
  }
  #endif
  </code></pre>
  <p>Then I use Xclang to load my FunctionPass, which looks something like this.</p>
  <pre><code>// M is of type llvm::Module*
  Function* f = M-&gt;getFunction(&quot;print_typecast&quot;);
  if (f == nullptr) {
      errs() &lt;&lt; &quot;Function not found in the module\n&quot;;
  }
  else {
      // insert function in the code
  }
  </code></pre>
  <p>However, my pass never finds the function in the module. When I remove the <code>static</code> it will find the function but then the linker in the final compilation step will complain of duplicate definition.</p>
  <p>Anyone knows how to make LLVM &quot;see&quot; static imported/included functions?</p>
  <p>Edit: I have also gone to the extreme where I have the same function directly written in every c file of the kernel code (the ones that <code>#include &lt;linux/kernel.h&gt;</code>)</p>