<div dir="ltr"><div dir="ltr"><div dir="ltr">I am programmatically building some functions in intermediate representation, and trying to verify them, but the verifier always reports that there is a problem, and I can't see why. Minimal test case:<div><br></div><div><div>#ifdef _MSC_VER</div><div>#pragma warning(disable : 4141)</div><div>#pragma warning(disable : 4530)</div><div>#pragma warning(disable : 4624)</div><div>#endif</div><div><br></div><div>#include <llvm/IR/IRBuilder.h></div><div>#include <llvm/IR/Verifier.h></div><div>using namespace llvm;</div><div><br></div><div>int main(int argc, char **argv) {</div><div>  LLVMContext context;</div><div>  IRBuilder<> builder(context);</div><div>  Module module("", context);</div><div><br></div><div>  // Function</div><div>  auto rty = Type::getInt32Ty(context);</div><div>  SmallVector<Type *, 1> pty;</div><div>  auto ty = FunctionType::get(rty, pty, false);</div><div>  auto f = Function::Create(ty, GlobalValue::CommonLinkage, "f", module);</div><div><br></div><div>  // Entry block</div><div>  auto entry = BasicBlock::Create(context, "entry", f);</div><div>  builder.SetInsertPoint(entry);</div><div><br></div><div>  // return 0</div><div>  auto val = ConstantInt::getSigned(rty, 0);</div><div>  builder.CreateRet(val);</div><div><br></div><div>  // Check</div><div>  f->dump();</div><div>  outs() << verifyFunction(*f) << '\n';</div><div>  return 0;</div><div>}</div></div><div><br></div><div>Output:</div><div><div><br></div><div>define common i32 @f() {</div><div>entry:</div><div>  ret i32 0</div><div>}</div><div><br></div></div><div>1</div><div><br></div><div>So the verifier says there is a problem, but I don't see anywhere the problem could be. What am I missing?</div></div></div></div>