title: LLVM: Creating a CallInst with a null pointer operand
body: <p>I'm trying to use the LLVM C++ bindings to write a pass which generates the following IR</p>
  
  <pre><code>%1 = call i64 @time(i64* null) #3
  </code></pre>
  
  <p><code>@time</code> here is the C standard library <code>time()</code> function.</p>
  
  <p>Here's the code I've written</p>
  
  <pre><code>void Pass::Insert(BasicBlock *bb, Type *timety, Module *m) {
    Type *timetype[1];
    timetype[0] = timety;
    ArrayRef&lt;Type *&gt; timeTypeAref(timetype, 1);
    Value *args[1];
    args[0] = ConstantInt::get(timety, 0, false);
    ArrayRef&lt;Value *&gt; argsRef(args, 1);
    FunctionType *signature = FunctionType::get(timety, false);
    Function *timeFunc =
        Function::Create(signature, Function::ExternalLinkage, "time", m);
    IRBuilder&lt;&gt; Builder(&amp;*(bb-&gt;getFirstInsertionPt()));
    AllocaInst *a1 = Builder.CreateAlloca(timety, nullptr, Twine("a1"));
    CallInst *c1 = Builder.CreateCall(timeFunc, args, Twine("time"));
  }
  </code></pre>
  
  <p>This compiles, but results in the following error when run</p>
  
  <pre><code>Incorrect number of arguments passed to called function!
    %time = call i64 @time(i64 0)
  </code></pre>
  
  <p>As I understand this, I need to pass an int64 pointer which deferences to <code>nullptr</code>, but I'm unable to figure out how to do that.</p>