LLVM IRBuilder: set the insertion point after a specific command

The LLVM IRBuilder SetInsertPoint function (instruction * I) indicates that created instructions should be inserted before the specified instruction.

How to set the insertion point after a certain command? I cannot find a function that can do this directly.

+5
source share
1 answer

The insertion point cannot be set after the given command - instead, you must set it before the next instruction.

To get a pointer to the following statement, you can use the getNextNode() method, which is available on Instruction :

 Builder.SetInsertPoint(I->getNextNode()); 

or you can rotate the instruction pointer into an iterator and advance it:

 BasicBlock::iterator it(I); it++; Builder.SetInsertPoint(it); 
+6
source

Source: https://habr.com/ru/post/1234458/


All Articles