<div dir="ltr"><div><div><div><div>Thank you for your help<br></div>I tried <br> Instruction* p=&( Bb->front());<br> Type * Int32Type = IntegerType::getInt32Ty(getGlobalContext()); <br> AllocaInst* newInst = new AllocaInst(Int32Type,"flag", p);<br>
</div>that works well<br></div>but I need to store the value of the variable too. <br></div>What's the method that could be used to store specific value??<br><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 30 July 2013 16:01, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu" target="_blank">criswell@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div class="im">
<div>On 7/30/13 7:44 AM, Rasha Omar wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>Hi,<br>
</div>
<div>I need to insert new instruction into every basic block
like x=1<br>
</div>
<div>or while loop<br>
</div>
<div>I tried this code, but it doesn't work<br>
<br>
Type * Int32Type =
IntegerType::getInt32Ty(getGlobalContext());<br>
AllocaInst* newInst = new AllocaInst(Int32Type,"flag", Bb);<br>
Bb->getInstList().push_back(newInst);<br>
</div>
</div>
</blockquote>
<br></div>
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.<br>
<br>
Remove the last line, and it should fix your problem.<br>
<br>
-- John T.<br>
<br>
<blockquote type="cite"><div class="im">
<div dir="ltr">
<div><br>
the error:<br>
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.<br>
<br>
</div>
<div> Is there a class I could use to insert while loop in
Module Pass?<br>
</div>
<div><br>
</div>
<div>Thank you in advance<br clear="all">
</div>
<div><br>
-- <br>
<div dir="ltr"><b style="color:rgb(32,18,77)"><span> </span>Rasha
Salah Omar<br>
<span> </span> Msc Student at E-JUST<br>
<span> </span> Demonestrator at Faculty of Computers
and Informatics<br>
<span> </span> Benha University</b>
<p style="color:rgb(32,18,77);font-size:13px;font-family:arial,helvetica,clean,sans-serif;background-color:transparent;font-style:normal"><b><span>
e-mail: <a href="mailto:rasha.omar@ejust.edu.eg" target="_blank">rasha.omar@ejust.edu.eg</a></span></b></p>
<font size="4"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(69,69,69)">
<div style="padding:0px;display:block;line-height:normal">
<span style="font-size:20pt;color:rgb(0,176,80);font-family:Webdings">P</span><b><span style="font-size:11pt;color:rgb(0,176,80);font-family:sans-serif"> Please
consider the environment before printing this
email.</span></b></div>
</span></font><br>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div><pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><b style="color:rgb(32,18,77)"><span> </span>Rasha Salah Omar<br><span> </span> Msc Student at E-JUST<br><span> </span> Demonestrator at Faculty of Computers and Informatics<br>
<span> </span> Benha University</b>
<p style="color:rgb(32,18,77);font-size:13px;font-family:arial,helvetica,clean,sans-serif;background-color:transparent;font-style:normal"><b><span> e-mail: <a href="mailto:rasha.omar@ejust.edu.eg" target="_blank">rasha.omar@ejust.edu.eg</a></span></b></p>
<font size="4"><span style="font-family:Arial,Helvetica,sans-serif;font-size:12px;border-collapse:collapse;color:rgb(69,69,69)"><div style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;display:block;line-height:normal">
<span style="font-size:20pt;color:rgb(0,176,80);font-family:Webdings">P</span><b><span style="font-size:11pt;color:rgb(0,176,80);font-family:sans-serif"> Please consider the environment before printing this email.</span></b></div>
</span></font><br></div>
</div>