<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>Dear John,</div><div><br></div><div>Thank you for your answer.</div><div>The bad news is that I need to apply several optimizations between the store and read. So the CFG will be modified.</div><div>Anyway, I will find another way out.</div><div><br></div><div>Thank you very much!</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>Vendredi 29 Août 2014 15:24:52<br><b>Objet: </b>Re: [LLVMdev] The problem of densemap and loop<br><div><br></div><div class="moz-cite-prefix">On 8/29/14, 8:52 AM, Hanbing Li wrote:<br></div><blockquote cite="mid:1861729590.21277591.1409316721930.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>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></div></div></blockquote><br> I think that the loop objects retrieved by two different ModulePasses would be different. The reason is that the PassManager tells the LoopInfo pass (a FunctionPass) to reinitialize itself every time it is run from a ModulePass. You therefore cannot call getAnalysis<LoopInfo>(F), grab a pointer to a Loop returned from the FunctionPass, and save it; the Loop object will be deleted (and its memory potentially reused) on the next call to getAnalysis.<br> <br> What you should do in your ModulePass is something like the following:<br> <br> for (every function F in the Module) {<br> container box;<br> for (every Loop L in the Function F) {<br> Add L to box<br> }<br> <br> for (every Loop L in box) {<br> Do with loop whatever you are going to do with it<br> }<br> }<br> <br> If you really need to track all loops in all functions in a single data structure (and assuming that I'm correct that LoopInfo gets reinitialized), then I think there is something else you can do: instead of recording a pointer to the Loop object, record the basic block of the loop's header and the loop's nesting level. When you then need the Loop object, you run the LoopInfo pass on the function to which the basic block belongs and find the loop with the matching header basic block. As long as the CFG isn't modified in between the time you record the basic blocks and the time you look up the LoopInfo, this should work.<br> <br> Hope this helps,<br> <br> John Criswell<br> <br></blockquote><div><br></div></div></body></html>