<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 7/30/13 7:44 AM, Rasha Omar wrote:<br>
</div>
<blockquote
cite="mid:CACKsOi_3ro2ORBK4geSCGXx-dX0KF0+amX74cLhbwwV7vdON6w@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<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>
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
cite="mid:CACKsOi_3ro2ORBK4geSCGXx-dX0KF0+amX74cLhbwwV7vdON6w@mail.gmail.com"
type="cite">
<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 moz-do-not-send="true"
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 class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>