<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Thanks a million. Now I managed to insert the block into the loop using the mentioned function. However I have another issue now. I've inserted a block (named foo) in the start of the loop. I want to make the predecessors of the the previous start block
 (for.cond) to jump to foo instead, and foo jumps to for.cond. Predecessors of for.cond are entry and for.inc. When I run my pass, only for.inc is changed, entry is not. Here is code:<br>
</p>
<p><br>
</p>
<div>          pred_iterator PI = pred_begin(loopCond), PE = pred_end(loopCond);</div>
<div>          while (PI != PE) {</div>
<div>            if((*PI)!=foo){   <br>
</div>
<div>              BasicBlock::iterator it = (*PI)->end();</div>
<div>              it--;</div>
<div>              BranchInst *bi = dyn_cast<BranchInst>(it);<br>
</div>
<div>              bi->setSuccessor(0, foo);<br>
</div>
<div>            }</div>
<div>            PI++;</div>
<div>          }<br>
</div>
<div><br>
</div>
<div>I guessed that the problem is that entry block is not part of the loop, and this is a loop pass. So, if this is this the problem, how can I overcome? And if not, what could be the problem?<br>
</div>
<p><br>
</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt">
<div class="PlainText">Regards,<br>
Marwa Yusuf<br>
Teaching Assistant - Computer Engineering Department<br>
Faculty of Engineering - Benha University<br>
E-JUST PhD Student<br>
Computer Science & Engineering Dept.</div>
</span></font></div>
</div>
</div>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Philip Reames <listmail@philipreames.com><br>
<b>Sent:</b> Friday, June 12, 2015 11:55 PM<br>
<b>To:</b> marwayusuf@feng.bu.edu.eg<br>
<b>Cc:</b> llvmdev@cs.uiuc.edu<br>
<b>Subject:</b> Re: [LLVMdev] How to insert basic block in a loop</font>
<div> </div>
</div>
<div>Given lack of context in your question, it's hard to figure out what you're asking, but as a guess, I'd suggest you look at addBasicBlockToLoop on LoopBase in LoopInfo.h<br>
<br>
Philip<br>
<br>
<div class="moz-cite-prefix">On 06/12/2015 01:53 PM, <a class="moz-txt-link-abbreviated" href="mailto:marwayusuf@feng.bu.edu.eg">
marwayusuf@feng.bu.edu.eg</a> wrote:<br>
</div>
<blockquote type="cite">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Dear All<br>
</p>
<p>I'm making a transformation pass that inserts a new basic block at the start of a loop. However when I try to change predecessor/successor relations, it does not consider the new block in the loop at all. So I got that just inserting a loop in a function
 before another loop is not enough. So how exactly to do this job?<br>
</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt">
<div class="PlainText">Regards,<br>
Marwa Yusuf<br>
Teaching Assistant - Computer Engineering Department<br>
Faculty of Engineering - Benha University<br>
E-JUST PhD Student<br>
Computer Science & Engineering Dept.</div>
</span></font></div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset> <br>
<pre>_______________________________________________
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>
</div>
</div>
</div>
</body>
</html>