The LLVM IRBuilder function SetInsertPoint (Instruction *I) specifies that created instructions should be inserted before the specified instruction.
How can the insert point be set after a particular instruction? I can't find a function that can do it directly.
The insert point can't be set to be after a given instruction -- instead, you should set it to be before the next instruction.
To get a pointer to the next instruction, you can use the getNextNode()
method which is available on Instruction
:
Builder.SetInsertPoint(I->getNextNode());
or you could turn the instruction pointer into an iterator and advance it:
BasicBlock::iterator it(I);
it++;
Builder.SetInsertPoint(it);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With