[LLVMdev] Instruction insertion By Module Pass

Rasha Omar rasha.sala7 at gmail.com
Tue Jul 30 05:44:27 PDT 2013

I need to insert new instruction into every basic block like x=1
or while loop
I tried this code, but it doesn't work

Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext());
 AllocaInst* newInst = new AllocaInst(Int32Type,"flag", Bb);

the error:
void llvm::SymbolTableListTraits<llvm::Instruction,
llvm::BasicBlock>::addNodeToList(ValueSubClass *) [ValueSubClass =
llvm::Instruction, ItemParentClass = llvm::BasicBlock]: Assertion
`V->getParent() == 0 && "Value already in a container!!"' failed.

 Is there a class I could use to insert while loop in Module Pass?

Thank you in advance

*     Rasha Salah Omar
     Msc Student at E-JUST
     Demonestrator  at Faculty of Computers and Informatics
     Benha University*

*     e-mail: rasha.omar at ejust.edu.eg*
 P* Please consider the environment before printing this email.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130730/c6effb93/attachment.html>

More information about the llvm-dev mailing list