<div dir="ltr">Hello. This is Byungchan An.<div>I have a question on meaning of parameters in RegisterPass.</div><div><br></div><div>In the LLVM Pass examples, I see the followings.</div><div><pre style="font-family:Consolas,'Deja Vu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:0.95em;line-height:15px;padding:0.5em;border:1px solid rgb(204,204,204);background-color:rgb(248,248,248);color:rgb(0,0,0)">
<span class="" style="color:rgb(0,112,32);font-weight:bold">static</span> <span class="">RegisterPass</span><span class="" style="color:rgb(102,102,102)"><</span><span class="">Hello</span><span class="" style="color:rgb(102,102,102)">></span> <span class="">X</span><span class="">(</span><span class="" style="color:rgb(64,112,160)">"hello"</span><span class="">,</span> <span class="" style="color:rgb(64,112,160)">"Hello World Pass"</span><span class="">,</span>
<span class="" style="color:rgb(0,112,32)">false</span> <span class="" style="color:rgb(96,160,176);font-style:italic">/* Only looks at CFG */</span><span class="">,</span>
<span class="" style="color:rgb(0,112,32)">false</span> <span class="" style="color:rgb(96,160,176);font-style:italic">/* Analysis Pass */</span><span class="">);</span></pre></div><div>Here I have one question, what means by only looking at CFG?</div>
<div>If I set it third parameters as "true" what limitations I have?</div><div><br></div><div>Second, the last parameter, Analysis Pass means it doesn't change IR given as input. Am I right? Then, why the following example I got from the llvm website set the last parameter as false?</div>
<div><br></div><div>Thanks.</div><div><pre style="font-family:Consolas,'Deja Vu Sans Mono','Bitstream Vera Sans Mono',monospace;font-size:0.95em;line-height:15px;padding:0.5em;border:1px solid rgb(204,204,204);background-color:rgb(248,248,248);color:rgb(0,0,0)">
<span class="" style="color:rgb(0,112,32)">#include "llvm/Pass.h"</span>
<span class="" style="color:rgb(0,112,32)">#include "llvm/IR/Function.h"</span>
<span class="" style="color:rgb(0,112,32)">#include "llvm/Support/raw_ostream.h"</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">using</span> <span class="" style="color:rgb(0,112,32);font-weight:bold">namespace</span> <span class="">llvm</span><span class="">;</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">namespace</span> <span class="">{</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">struct</span> <span class="">Hello</span> <span class="" style="color:rgb(102,102,102)">:</span> <span class="" style="color:rgb(0,112,32);font-weight:bold">public</span> <span class="">FunctionPass</span> <span class="">{</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">static</span> <span class="" style="color:rgb(144,32,0)">char</span> <span class="">ID</span><span class="">;</span>
<span class="">Hello</span><span class="">()</span> <span class="" style="color:rgb(102,102,102)">:</span> <span class="">FunctionPass</span><span class="">(</span><span class="">ID</span><span class="">)</span> <span class="">{}</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">virtual</span> <span class="" style="color:rgb(144,32,0)">bool</span> <span class="">runOnFunction</span><span class="">(</span><span class="">Function</span> <span class="" style="color:rgb(102,102,102)">&</span><span class="">F</span><span class="">)</span> <span class="">{</span>
<span class="">errs</span><span class="">()</span> <span class="" style="color:rgb(102,102,102)"><<</span> <span class="" style="color:rgb(64,112,160)">"Hello: "</span><span class="">;</span>
<span class="">errs</span><span class="">().</span><span class="">write_escaped</span><span class="">(</span><span class="">F</span><span class="">.</span><span class="">getName</span><span class="">())</span> <span class="" style="color:rgb(102,102,102)"><<</span> <span class="" style="color:rgb(64,112,160)">'\n'</span><span class="">;</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">return</span> <span class="" style="color:rgb(0,112,32)">false</span><span class="">;</span>
<span class="">}</span>
<span class="">};</span>
<span class="">}</span>
<span class="" style="color:rgb(144,32,0)">char</span> <span class="">Hello</span><span class="" style="color:rgb(102,102,102)">::</span><span class="">ID</span> <span class="" style="color:rgb(102,102,102)">=</span> <span class="" style="color:rgb(64,160,112)">0</span><span class="">;</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">static</span> <span class="">RegisterPass</span><span class="" style="color:rgb(102,102,102)"><</span><span class="">Hello</span><span class="" style="color:rgb(102,102,102)">></span> <span class="">X</span><span class="">(</span><span class="" style="color:rgb(64,112,160)">"hello"</span><span class="">,</span> <span class="" style="color:rgb(64,112,160)">"Hello World Pass"</span><span class="">,</span> <span class="" style="color:rgb(0,112,32)">false</span><span class="">,</span> <span class="" style="color:rgb(0,112,32)">false</span><span class="">);</span></pre>
</div></div>