I’m trying to add a new instruction after a given instruction in a basic block.
Until LLVM 3.7, I was using the following code:
[where both I and new_inst are Instruction*]
In LLVM 3.8 however, the SymbolTableList was created as a wrapper over iplist.
Could anyone please tell me how I can do the same type of insertion in LLVM 3.8?
Thank you and Regards,
auto InsertPt = I->getIterator();
In your example, isn't "insert" inserting "new_inst" *before* instruction
As I would like to insert the "new_inst" instruction after "I", shouldn't
BB->getInstList().insertAfter(InsertPt, new_inst); ?
With insert I currently get the following error:
Instruction does not dominate all uses!
%0 = getelementptr inbounds i8, i8* getelementptr inbounds ([8 x
i8], [8 x i8]* @1, i32 0, i32 0)
call void @myCall(i8* %0)
Try incrementing the iterator before using.
Why not just use Instruction::insertAfter()?
This would work too, assuming the instruction is not linked anywhere currently.
It’s just doing what i wrote, with insertAfter() instead of insert()
Yes, it worked with insertAfter(). Thank you all.