title: How to build a empty basicblock and insert a Instruction in the front?
body: <p>I write a function to create a empty basicblock:</p>
  
  <pre><code>BasicBlock* createEmptyBlock(){
      llvm::LLVMContext context;
      IRBuilder&lt;&gt; builder(context);
      Function *mainFunction;
      mainFunction-&gt;setDoesNotReturn();
      BasicBlock* mainblock = BasicBlock::Create(context, "entrypoint", mainFunction);
      return mainblock;
  }
  </code></pre>
  
  <p>but when insert my instruction in the front of this mainblock:</p>
  
  <pre><code> Instruction *newBInst_0 = setBranchInst(F, inst, 1);//product a inst
                              llvm::BasicBlock *bb;
                              bb=createEmptyBlock();                      
                              newBInst_0-&gt;insertBefore(bb-&gt;front());//there are some errors
                              bb-&gt;insertInto(&amp;F,&amp;block);
  </code></pre>
  
  <p>I found some errors when I insert
  What's wrong with this?</p>