[llvm-dev] Where does doInitialization() fit into the new PassManager model?

Zhang via llvm-dev
Thu, 11 Nov 2021 14:54:34 -0000

Hi Arthur:
Thanks for the hint about RNG. While we are at it, one more thing the
documentation is a bit vague about is that:
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.


And again, where does this sort of behavior fits into the new PM? I assume
it's also not considered?


Zhang
&nbsp;
&nbsp;
------------------&nbsp;Original&nbsp;------------------
From: &nbsp;"Arthur Eubanks"<aeubanks at google.com&gt;;
Date: &nbsp;Wed, Nov 10, 2021 02:10 AM
To: &nbsp;"Zhang"<admin at mayuyu.io&gt;;
Cc: &nbsp;"llvm-dev"<llvm-dev at lists.llvm.org&gt;;
Subject: &nbsp;Re: [llvm-dev] Where does doInitialization() fit into the new
PassManager model?

&nbsp;

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&nbsp;+ 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
&amp;). (Also Module::createRNG() isn't used in tree AFAICT)


On Mon, Nov 8, 2021 at 7:59 PM Zhang via llvm-dev <llvm-dev at
lists.llvm.org&gt; wrote:

Hi:
In my legacy pass, I usually use doInitialization() to call Module::createRNG()
to create a RandomNumberGenerator, which my FunctionPass later uses.
How does this model fit into the new PassManager interface? Creating my new pass
as run(Function&amp;F ....) and re-create my RNG each time doesn't
preserve its internal state, but using run(Module&amp; M) seems a bit
overkill to me?

_______________________________________________
 LLVM Developers mailing list
 llvm-dev at lists.llvm.org
 https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20211111/9179d8c7/attachment.html>