<div dir="ltr">I'm not super familiar with the contracts of the legacy PM so I can't speak to doInit/doFinalization. Not sure if there would be any caching issues with modifying IR in doFinalization.<div><br></div><div>And yes this isn't really a thing in the new PM. Some passes have a module pass version which does global things and then a function pass version that runs things on each function.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 11, 2021 at 6:54 AM Zhang <<a href="mailto:admin@mayuyu.io">admin@mayuyu.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hi Arthur:</div><div>Thanks for the hint about RNG. While we are at it, one more thing the documentation is a bit vague about is that:</div><div>Can I insert GVs into the Module in doFinalization()? I know you could do so in doInit(). The reason I'm asking this is that so I could implement my passes as FunctionPass if this holds.</div><div><br></div><div>And again, where does this sort of behavior fits into the new PM? I assume it's also not considered?</div><div><br></div><div>Zhang</div><div><u></u><div> </div><div> </div><div style="color:rgb(0,0,0)"><div style="font-size:12px;font-family:"Arial Narrow";padding:2px 0px">------------------ Original ------------------</div><div style="font-size:12px;background:rgb(239,239,239);padding:8px"><div id="gmail-m_-464934389752358954menu_sender"><b>From: </b> "Arthur Eubanks"<<a href="mailto:aeubanks@google.com" target="_blank">aeubanks@google.com</a>>;</div><div><b>Date: </b> Wed, Nov 10, 2021 02:10 AM</div><div><b>To: </b> "Zhang"<<a href="mailto:admin@mayuyu.io" target="_blank">admin@mayuyu.io</a>>; </div><div><b>Cc: </b> "llvm-dev"<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; </div><div><b>Subject: </b> Re: [llvm-dev] Where does doInitialization() fit into the new PassManager model?</div></div><div> </div><div><div id="gmail-m_-464934389752358954tmpcontent_res"></div><div dir="ltr">Yeah there's currently no equivalent of doInitialization() in the new pass manager. Creating a per-module RNG to work on functions seems a bit weird to me. Module::createRNG() attempts to be consistent based on the module name + a per-call site salt, but that makes so changes in one function affect functions visited after. It would make more sense to me to use a per-function RNG salted with the module name and function name. Or if you really want a per-module RNG you could just lazily initialize it in the run(Function &). (Also Module::createRNG() isn't used in tree AFAICT)</div><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 8, 2021 at 7:59 PM Zhang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><font>Hi:</font></div><div>In my legacy pass, I usually use doInitialization() to call Module::createRNG() to create a RandomNumberGenerator, which my FunctionPass later uses.</div><div>How does this model fit into the new PassManager interface? Creating my new pass as run(Function&F ....) and re-create my RNG each time doesn't preserve its internal state, but using run(Module& M) seems a bit overkill to me?</div><div><u></u><u></u></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>

</div></div><u></u></div></blockquote></div>