<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 4/7/14 11:08 AM, Hanbing Li wrote:<br>
</div>
<blockquote
cite="mid:1040063164.496863.1396886904656.JavaMail.zimbra@inria.fr"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div style="font-family: times new roman, new york, times, serif;
font-size: 12pt; color: #000000">
<div>Hi John,</div>
<div><br>
</div>
<div>Thank you for your answer. I tried <span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;">ImmutablePasses,
while the problem came again.</span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;">Because
the W need some information like loopinfo, so I
need LoopInfo *LI = &getAnalysis<LoopInfo>(F); in
this ImmutablePasses, and Function or Module are needed.</span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;">I
didn't find a way to get the Module or Function in
ImmutablePasses.</span></div>
</div>
</blockquote>
<br>
It sounds like your pass is not a simple container which other
passes use to store information. It sounds like your pass is doing
actual analysis work. If that is the case, then you should probably
use a ModulePass instead of an ImmutablePass. By making your pass a
ModulePass, the PassManager can invalidate and re-run your pass
whenever an optimization pass changes the IR in a way that
invalidates your analysis pass's results.<br>
<br>
<blockquote
cite="mid:1040063164.496863.1396886904656.JavaMail.zimbra@inria.fr"
type="cite">
<div style="font-family: times new roman, new york, times, serif;
font-size: 12pt; color: #000000">
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><br>
</span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;">So,
1, can I use <span style="font-family: Helvetica, Arial,
sans-serif;" data-mce-style="font-family: Helvetica,
Arial, sans-serif;">LoopInfo *LI =
&getAnalysis<LoopInfo>(F); in ImmutablePasses?</span></span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;">2, is there a method to get the Module in
ImmutablePasses?</span></span></div>
</div>
</blockquote>
<br>
You might be able to do that in an ImmutablePass, but I'd recommend
using a ModulePass.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<blockquote
cite="mid:1040063164.496863.1396886904656.JavaMail.zimbra@inria.fr"
type="cite">
<div style="font-family: times new roman, new york, times, serif;
font-size: 12pt; color: #000000">
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;"><br>
</span></span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;">Thank you!</span></span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;"><br>
</span></span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;">Sincerely,</span></span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;"><br>
</span></span></div>
<div><span style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial, sans-serif;"><span
style="font-family: Helvetica, Arial, sans-serif;"
data-mce-style="font-family: Helvetica, Arial,
sans-serif;">Hanbing</span></span></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" <a class="moz-txt-link-rfc2396E" href="mailto:criswell@illinois.edu"><criswell@illinois.edu></a><br>
<b>À: </b>"Hanbing Li" <a class="moz-txt-link-rfc2396E" href="mailto:hanbing.li@inria.fr"><hanbing.li@inria.fr></a>,
<a class="moz-txt-link-abbreviated" href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
<b>Envoyé: </b>Samedi 5 Avril 2014 00:27:13<br>
<b>Objet: </b>Re: [LLVMdev] Add a new information and
preserve it in LLVM<br>
<div><br>
</div>
<div class="moz-cite-prefix">On 4/4/14 3:02 PM, Hanbing Li
wrote:<br>
</div>
<blockquote
cite="mid:155431169.2722035.1396641779298.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>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica;" data-mce-style="margin: 0px; font-size:
12px; font-family: Helvetica;">Hello,</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica; min-height: 14px;" data-mce-style="margin:
0px; font-size: 12px; font-family: Helvetica;
min-height: 14px;"><br>
</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica;" data-mce-style="margin: 0px; font-size:
12px; font-family: Helvetica;"><span
class="Apple-tab-span" style="white-space: pre;"
data-mce-style="white-space: pre;"> </span>I am
trying to add some thing into LLVM, while I
encountered some problems.</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica; min-height: 14px;" data-mce-style="margin:
0px; font-size: 12px; font-family: Helvetica;
min-height: 14px;"><br>
</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica;" data-mce-style="margin: 0px; font-size:
12px; font-family: Helvetica;"><span
class="Apple-tab-span" style="white-space: pre;"
data-mce-style="white-space: pre;"> </span>So my
situation is that I have some information W, some
transform passes may change it, after these passes, I
need the new W. What I did is to create an analysis
pass similar to scalar-evolution or loopinfo, I can
get the information by using getAnalysis<W>();
and preserve this information W by using
AU.addPreserved<W>();. Then the problem came,
for the module pass, the information can’t be
preserved. (I found this: <span style="font-size:
13px; font-family: Courier;"
data-mce-style="font-size: 13px; font-family:
Courier;">To the best of my knowledge, the LLVM pass
manager never preserves a FunctionPass analysis that
is requested by a ModulePass; every time you call
getAnalysis for a function, the FunctionPass is
re-run. <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-March/048139.html"
target="_blank"
data-mce-href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-March/048139.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-March/048139.html</a></span>)
So this means that I can’t update W when some module
passes changed it?</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica; min-height: 14px;" data-mce-style="margin:
0px; font-size: 12px; font-family: Helvetica;
min-height: 14px;"><br>
</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica;" data-mce-style="margin: 0px; font-size:
12px; font-family: Helvetica;">My questions are:</p>
<p style="margin: 0px; font-size: 12px; font-family:
Helvetica;" data-mce-style="margin: 0px; font-size:
12px; font-family: Helvetica;">1, Module pass really
can’t preserve the W?</p>
</div>
</div>
</blockquote>
<br>
If W is a FunctionPass, then I believe you are correct: a
ModulePass will re-run the FunctionPass every time it uses the
FunctionPass.<br>
<br>
I get the impression that you're using the PassManager
infrastructure improperly, and that is probably why you're not
getting the results you want.<br>
<br>
First, the ability to preserve a pass's results with
addPreserved<W>() is an optimization. A FunctionPass or
ModulePass() that analyzes the LLVM IR should work whether it
is run one time or a hundred times. The
addPreserved<>() functionality is only there so that the
LLVM compiler can cache the results of analysis passes for
efficiency.<br>
<br>
Second, the way to fix your problem depends on what you want
to do. If you want pass W to analyze the LLVM IR of a program
and cache its results (because the analysis it does is
expensive), then make it a ModulePass. That way, other
ModulePass'es can update and preserve its results.<br>
<br>
If you are just using W as a container in which to record
information that transform passes are doing, then you might
want to make W an ImmutablePass. ImmutablePasses are only run
once and are never invalidated; other passes can use them to
record information about what they do. ImmutablePasses, I
think, were not really designed for this purpose, but they'll
get the job done.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
</blockquote>
<div><br>
</div>
</div>
</blockquote>
<br>
</body>
</html>