<DIV>Thanks a lot for replying...but I am not doing any deleting or removing node ...I am trying to insert a "new" entry node in an existing list.</DIV>
<DIV>In another reply I understood (also mentioned on the site) that no other block can branch to the entry block.</DIV>
<DIV> </DIV>
<DIV>How do I achieve this ? Is it feasible?Let me know if there is any example.</DIV>
<DIV> </DIV>
<DIV>Thanks again,</DIV>
<DIV>Tanu<BR><BR><B><I>Chris Lattner <sabre@nondot.org></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">On Thu, 17 Feb 2005, Tanu Sharma wrote:<BR>> I created a new block and inserted it into the present basic block list <BR>> , but I get this error:<BR>><BR>> opt: BasicBlock.cpp:83: virtual llvm::BasicBlock::~BasicBlock(): Assertion `getParent() == 0 && "BasicBlock still linked into the program!"' failed.<BR>><BR>> The program completes its task and i get this in the end. I am unable to <BR>> resolve this.<BR><BR>The problem there is that you're trying to delete some basic block that is <BR>still embedded into a function. There are several ways to accomplish <BR>this:<BR><BR>BasicBlock *BB = ...<BR><BR>// Approach number 1, the easy way:<BR>BB->eraseFromParent();<BR><BR>// Approach number 2, the more explicit way:<BR>BB->getParent()->getInstList().erase(BB); // Remove from list & delete<BR><BR>// Approach number 3, remove from the list!
 , then
 delete it explicitly:<BR>BB->getParent()->getInstList().remove(BB); // Just remove from list<BR>delete BB; // Delete block<BR><BR><BR>I strongly suggest using approach #1, but I listed all of them so you can <BR>see the relation between remove and erase.<BR><BR>-Chris<BR><BR><BR>> John Criswell <CRISWELL@CS.UIUC.EDU>wrote:<BR>> Tanu Sharma wrote:<BR>>> Hello,<BR>>><BR>>> In an attempt to randomise the basic blocks in a function, is it<BR>>> possible that I can randomise the entry block as well? And maybe insert<BR>>> some instructions in the pass to call entry block while running the<BR>>> program ?<BR>>><BR>>> Is it feasible?<BR>>><BR>>> What does entry block consist of ?<BR>><BR>> The entry block, by definition, is the first basic block (BB) to be<BR>> executed by a function. As I understand it, it has the additional<BR>> restriction that it cannot be dominated by other basic blocks (i.e.
 no<BR>> other BBs in the function can branch to it).<BR>><BR>> If your entry BB performs useful computations and you want to move it,<BR>> you could create a new entry BB that does nothing but branch to the old<BR>> entry BB. The old entry BB (now just a regular BB) can then be moved.<BR>><BR>> I'm assuming thus far that you're randomizing the basic block order at<BR>> the LLVM level (i.e. take LLVM function, randomize order of BBs, and<BR>> then codegen each BB in order). Another approach, as I see it, would be<BR>> to change the code generator so that it codegens the BBs in a random<BR>> order, instead of codegen'ing them in order.<BR>><BR>> The first approach, I think, is a lot easier.<BR>><BR>> Regards,<BR>><BR>> -- John T.<BR>><BR>>><BR>>> Thanks<BR>>><BR>>> Tanu<BR>>><BR>>><BR>>><BR>>> ------------------------------------------------------------------------<BR>>&gt!
 ; Do you
 Yahoo!?<BR>>> Yahoo! Search presents - Jib Jab's 'Second Term'<BR>>><BR>>><BR>>><BR>>><BR>>> ------------------------------------------------------------------------<BR>>><BR>>> _______________________________________________<BR>>> LLVM Developers mailing list<BR>>> LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu<BR>>> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev<BR>><BR>> _______________________________________________<BR>> LLVM Developers mailing list<BR>> LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu<BR>> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev<BR>><BR>> __________________________________________________<BR>> Do You Yahoo!?<BR>> Tired of spam? Yahoo! Mail has the best spam protection around<BR>> http://mail.yahoo.com<BR><BR>-Chris<BR><BR>-- <BR>http://nondot.org/sabre/<BR>http://llvm.cs.uiuc.edu/<BR><BR>_______________________________________________<BR>LLVM Developers !
 mailing
 list<BR>LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu<BR>http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev<BR></BLOCKQUOTE><p>__________________________________________________<br>Do You Yahoo!?<br>Tired of spam?  Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com