[LLVMdev] Instruction insertion By Module Pass
rasha.sala7 at gmail.com
Wed Jul 31 05:20:52 PDT 2013
Thank you for your help
Instruction* p=&( Bb->front());
Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext());
AllocaInst* newInst = new AllocaInst(Int32Type,"flag", p);
that works well
but I need to store the value of the variable too.
What's the method that could be used to store specific value??
On 30 July 2013 16:01, John Criswell <criswell at illinois.edu> wrote:
> 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*
> P* Please consider the environment before printing this email.*
> LLVM Developers mailing listLLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
* Rasha Salah Omar
Msc Student at E-JUST
Demonestrator at Faculty of Computers and Informatics
* e-mail: rasha.omar at ejust.edu.eg*
P* Please consider the environment before printing this email.*
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev