title: How to pass arguments to an external function that I am calling using CallInst::Create(...) in my LLVM pass?
body: <p>So this is what I am trying to do:</p>
  
  <pre><code>     if(isa&lt;CallInst&gt;(&amp;(*BI)) )
                  {
          ArrayRef &lt;Value *&gt; arguments('c');
          StringRef fname = cast&lt;CallInst&gt;(&amp;(*BI))-&gt;getCalledFunction()-&gt;getName();
          errs()&lt;&lt;fname + " was called\n";
          //CallInst *CI = dyn_cast&lt;CallInst&gt;(BI);
          if(fname=="pthread_mutex_lock"){
              Instruction *newInst = CallInst::Create(hook, arguments, "");
              BB-&gt;getInstList().insert(BI, newInst);
          }
  </code></pre>
  
  <p>where "hook" is the function. The error I get is:</p>
  
  <blockquote>
    <p>no matching constructor for initialization of
          'ArrayRef'
                            ArrayRef  arguments('c');</p>
  </blockquote>
  
  <p>And when I change <code>ArrayRef &lt;Value *&gt; arguments('c')</code>to <code>ArrayRef &lt;char&gt; arguments('c')</code> the error becomes:</p>
  
  <blockquote>
    <p>no matching function for call to 'Create'
                                    Instruction *newInst = CallInst::Create(hook, argume...
                                                           ^~~~~~~~~~~~~~~~
    /.../llvm/IR/Instructions.h:1187:20:
    note: 
          candidate function not viable: no known conversion from 'ArrayRef' to
          'ArrayRef' for 2nd argument   static CallInst *Create(Value *Func,
                       ^ /.../llvm/llvm-3.4/include/llvm/IR/Instructions.h:1200:20:
    note: 
          candidate function not viable: no known conversion from 'ArrayRef' to
          'const llvm::Twine' for 2nd argument   static CallInst *Create(Value *F, const Twine &amp;NameStr = "",
                       ^ /.../llvm/llvm-3.4/include/llvm/IR/Instructions.h:1204:20:
    note: 
          candidate function not viable: no known conversion from 'ArrayRef' to
          'const llvm::Twine' for 2nd argument   static CallInst *Create(Value *F, const Twine &amp;NameStr,
                       ^ /.../llvm/llvm-3.4/include/llvm/IR/Instructions.h:1194:20:
    note: 
          candidate function not viable: requires 4 arguments, but 3 were provided   static CallInst *Create(Value *Func,
                       ^</p>
  </blockquote>
  
  <p>I lack the understanding to passing arguments to external functions I call in my LLVM pass as I am new to this stuff. Help will be appreciated!</p>