<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>Hi,<br> <br> I tried to solve the problem by myself. And when I even got the densemap with 6 items, I still got 0 in another ModulePass by using the loopinfo derived in the new ModulePass. So if this means that when I use a loop in LoopInfo in a Function/ModulePass, I can't get the same loop object in another ModulePass. In other words, the loop objects in two ModulePasses are always different?<br> Does anyone know something about it?<br> <br> Thank you<br> <br> Sincerely,<br> <br> Hanbing</div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>De: </b>"Hanbing Li" <hanbing.li@inria.fr><br><b>À: </b>"John Criswell" <jtcriswel@gmail.com><br><b>Cc: </b>llvmdev@cs.uiuc.edu<br><b>Envoyé: </b>Vendredi 29 Août 2014 10:47:07<br><b>Objet: </b>Re: [LLVMdev] The problem of densemap and loop<br><div><br></div><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000" data-mce-style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000;"><div>Dear John,</div><div><br></div><div>First thing, the 3 loops in  Densemap are all "<span style="font-family: Menlo; font-size: 11px;" data-mce-style="font-family: Menlo; font-size: 11px;">Loop at depth 1 containing: %1<header><exiting>,%3,%5<latch></span>" in the 3 functions.</div><div><br></div><div>The dense map is in a ImmutablePass. I got it in FunctionPass and tried insert the information in this FunctionPass. So to turn the FunctionPass to ModulePass may be a better idea?</div><div><br></div><div>Another interesting thing: if just before the insertion, I used "L -> print(errs());" to print the Loop, there were 6 items in ls. BUT when I tried to read it in a ModulePass, I can't get the correct result.</div><div>"<p style="margin: 0px;" data-mce-style="margin: 0px;">for (Module::iterator FI = M.begin(), E = M.end(); FI != E; ) {<br>     F = FI++;</p><p style="margin: 0px;" data-mce-style="margin: 0px;">    if (!F->hasName() && !F->isDeclaration()){}<br>     else{</p><p style="margin: 0px;" data-mce-style="margin: 0px;">        LoopInfo *LI = &getAnalysis<LoopInfo>(*F);<br>         WCETInfo *WI = &getAnalysis<WCETInfo>(); //WI is the ImmutablePass which contains the dense map</p><p style="margin: 0px;" data-mce-style="margin: 0px;">        for(LoopInfo::iterator i=LI->begin(); i!=LI->end(); ++i) {<br>             Loop *L = *i;</p><p style="margin: 0px;" data-mce-style="margin: 0px;">            int lb=0;<br>             lb=WI->outls(L); // the method: return ls.find(L)->second;</p><p style="margin: 0px;" data-mce-style="margin: 0px;">        }</p><p style="margin: 0px;" data-mce-style="margin: 0px;">    }</p><p style="margin: 0px;" data-mce-style="margin: 0px;">}</p>"</div><div><br></div><div>Thank you</div><div><br></div><div>Sincerely,</div><div><br></div><div>Hanbing</div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>De: </b>"John Criswell" <jtcriswel@gmail.com><br><b>À: </b>"Hanbing Li" <hanbing.li@inria.fr>, llvmdev@cs.uiuc.edu<br><b>Envoyé: </b>Jeudi 28 Août 2014 18:59:52<br><b>Objet: </b>Re: [LLVMdev] The problem of densemap and loop<br><div><br></div><div class="moz-cite-prefix">Dear Hanbing,<br> <br> You haven't provided enough information to help diagnose the problem.  It would help if you specified which 3 loops actually end up in the DenseMap.<br> <br> One thing to check for is if your code is in a FunctionPass.  A FunctionPass computes its results anew each time it is run on a function, and so it's possible that this is the cause of the problem.  Similarly, the Loop objects for each function might be deleted and re-allocated for new Loop objects every time you run the LoopAnalysis on a new function.  That would make it look like you only have three elements when, in fact, you've added six elements but three were deallocated.<br> <br> Alternatively, you might have some something silly like making ls a local variable, so it gets destroyed each time you enter the function/method in which it appears.<br> <br> However, these are just guesses.  I'm not certain it can be diagnosed even if you do provide more information.<br> <br> Regards,<br> <br> John Criswell<br> <br> <br> On 8/28/14, 12:49 PM, Hanbing Li wrote:<br></div><blockquote cite="mid:1071199000.21079311.1409244598377.JavaMail.zimbra@inria.fr"><div style="font-family: times new roman, new york, times, serif;
        font-size: 12pt; color: #000000" data-mce-style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000;"><div>Hello, everyone,</div><div><br></div><div>I created a dense map like this: DenseMap<Loop *, int> ls;</div><div>And I have a module which contains 3 functions:</div><div>function F and it has a loop which is "<span style="font-family: Menlo; font-size: 11px;" data-mce-style="font-family: Menlo; font-size: 11px;">Loop at depth 1 containing: %1<header><exiting>,%3,%5<latch></span><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">"</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">function G and it has two loops which are "</span></span><p style="margin: 0px; font-size: 11px; font-family: Menlo;" data-mce-style="margin: 0px; font-size: 11px; font-family: Menlo;">Loop at depth 1 containing: %8<header><exiting>,%10,%14<latch></p><p style="margin: 0px; font-size: 11px; font-family: Menlo;" data-mce-style="margin: 0px; font-size: 11px; font-family: Menlo;">Loop at depth 1 containing: %1<header><exiting>,%3,%5<latch></p><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">"</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">function main and it has 3 loops which are "</span></span><p style="margin: 0px; font-size: 11px; font-family: Menlo;" data-mce-style="margin: 0px; font-size: 11px; font-family: Menlo;">Loop at depth 1 containing: %17<header><exiting>,%19,%23<latch></p><p style="margin: 0px; font-size: 11px; font-family: Menlo;" data-mce-style="margin: 0px; font-size: 11px; font-family: Menlo;">Loop at depth 1 containing: %8<header><exiting>,%10,%14<latch</p><p style="margin: 0px; font-size: 11px; font-family: Menlo;" data-mce-style="margin: 0px; font-size: 11px; font-family: Menlo;">Loop at depth 1 containing: %1<header><exiting>,%3,%5<latch></p><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">"</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">Then I tried to insert these loops into ls and the expected result is that there are 6 items in ls after the insertion. </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">But I got only 3.</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><br> </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">So my question is why this happened? </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">The dense map uses the name of the loop to check if the element is in it?</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">Is there anything wrong during my code?</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><br> </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">Looking forward to your answer.</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><br> </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">Thank you</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><br> </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">Sincerely,</span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;"><br> </span></div><div><span style="font-size: 12pt;" data-mce-style="font-size: 12pt;">Hanbing</span></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" target="_blank" data-mce-href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu" target="_blank" data-mce-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" target="_blank" data-mce-href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre></blockquote><br></blockquote><div><br></div></div><br>_______________________________________________<br>LLVM Developers mailing list<br>LLVMdev@cs.uiuc.edu         http://llvm.cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev<br></blockquote><div><br></div></div></body></html>