6

I have created a function in LLVM IR. Now I want to create a return instruction return void.

I saw the function Create ReturnInst::(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd)

But I don't know what should retVal should be so that it returns return void

coder hacker
  • 4,819
  • 1
  • 25
  • 50

2 Answers2

8

If you pass in nullptr to retVal (which is its default value too) that will give you a 'ret void'.

ScottyP
  • 144
  • 4
1

Seems this code works: UndefValue::get(Type::getVoidTy(Context))

Fangqing Du
  • 91
  • 1
  • 4