[LLVMdev] Instruction insertion By Module Pass
criswell at illinois.edu
Tue Jul 30 07:01:21 PDT 2013
On 7/30/13 7:44 AM, Rasha Omar wrote:
> 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 problem is that you've inserted the AllocaInst into the basic block
via the AllocaInst constructor (note the Bb at the end of the line with
new AllocaInst). You then attempt to insert the AllocaInst into the
BasicBlock Bb a second time with the last line. Note that the assertion
is telling you that you're inserting the alloca instruction twice.
Remove the last line, and it should fix your problem.
-- John T.
> 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 <mailto:rasha.omar at ejust.edu.eg>*
> P* Please consider the environment before printing this email.*
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev