<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<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"
type="cite">
<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>
</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>
</body>
</html>