<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>Thanks , your suggestion was welcome and CloneLoop works without passing the LPPassManager.
<br><br> However, I reached another problem. When the loop to be cloned 
has some subloops, the subloops are not properly cloned. Some clones of 
the clones are created and the CFG between the cloned basic blocks of 
the subloops is not correctly built. There are clones like 
for.body.clone,  for.body.clone1,  for.body.clone2, ... 
 for.body.clone26 without any predecessor and  for.body.clone27, 
 for.body.clone28 ..  which are included in the CFG.  
<br><br>To be sure I did not mess up the code of CloneLoop I checked 
also the original version of the function (which requires LPPassManager 
as parameter), but the output is the same. How can I use the CloneLoop 
function to clone a loop nest?
<br><br>Thank you.
<br>Alexandra
</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Eli Friedman <eli.friedman@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Jimborean Alexandra <xinfinity_a@yahoo.com><br><b><span style="font-weight: bold;">Cc:</span></b> llvmdev@cs.uiuc.edu<br><b><span style="font-weight: bold;">Sent:</span></b> Mon, May 9, 2011 4:48:29 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [LLVMdev] get LPPassManager to use it in llvm::CloneLoop<br></font><br>
On Mon, May 9, 2011 at 1:06 AM, Jimborean Alexandra<br><<a ymailto="mailto:xinfinity_a@yahoo.com" href="mailto:xinfinity_a@yahoo.com">xinfinity_a@yahoo.com</a>> wrote:<br>> Hi,<br>><br>> I try to write a FunctionPass that, among other tasks, has to clone some<br>> loops from the current function.<br>> How can I obtain the LPPassManager in order to use the CloneLoop function.<br>> In a LoopPass this is a parameter for the runOnLoop, but how can I obtain it<br>> in a FunctionPass?<br>> I tried simply by creating a new instance :<br>><br>>         ValueMap<const Value *, Value* > VMap;<br>>         LoopInfo *LI = &getAnalysis<LoopInfo>();<br>>         LPPassManager *LPM = new llvm::LPPassManager(1);<br>><br>>         Loop* nL = llvm::CloneLoop(L, LPM, LI, VMap, this);<br>><br>> but it segfaults in CloneLoop
 when trying LPM->insertLoop(..).<br><br>CloneLoop isn't fundamentally dependent on a LPPassManager, but it<br>looks like you have to pass one in at the moment; you might need to<br>mess with the implementation of llvm::CloneLoop (in CloneLoop.cpp) a<br>bit so that passing in null for the LPM argument works correctly.<br><br>> Does the CloneLoop function include both loops in the CFG and re-create the<br>> use map between the clones?<br>> Also does it update the phi nodes to use either the original or the cloned<br>> values?<br><br>CloneLoop essentially puts in a copy of the loop, and doesn't mess<br>with anything outside of the loop.  You have to fix up everything else<br>to fit together properly yourself.  Note that the "LCSSA" pass helps a<br>lot here, but I don't recall if requiring it from a FunctionPass works<br>properly.<br><br>-Eli<br></div></div>



</div></body></html>