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

116 views
Skip to first unread message

Zhang via llvm-dev

unread,
Nov 8, 2021, 10:59:29 PM11/8/21
to llvm-dev
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&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?

Arthur Eubanks via llvm-dev

unread,
Nov 9, 2021, 1:10:54 PM11/9/21
to Zhang, llvm-dev
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)

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Zhang via llvm-dev

unread,
Nov 11, 2021, 9:54:50 AM11/11/21
to Arthur Eubanks, llvm-dev
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
 
 
------------------ Original ------------------
From:  "Arthur Eubanks"<aeub...@google.com>;
Date:  Wed, Nov 10, 2021 02:10 AM
To:  "Zhang"<ad...@mayuyu.io>;
Cc:  "llvm-dev"<llvm...@lists.llvm.org>;
Subject:  Re: [llvm-dev] Where does doInitialization() fit into the new PassManager model?

Arthur Eubanks via llvm-dev

unread,
Nov 11, 2021, 1:09:09 PM11/11/21
to Zhang, llvm-dev
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.

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.
Reply all
Reply to author
Forward
0 new messages