My Legacy PM pass heavily uses doInitialization() and doFinalization(), aeubanks suggested that it could be done with lazy construction in NPM, however this doesn’t give access to doFinalization.
So the solution would be implement the pass as ModulePass?
However this raises another question w.r.t. to analysis passes,for example, in legacyPM, in order to get DominatorTree from DominatorTreeWrapperPass, I could:
getAnalysis<DominatorTreeWrapperPass>(Function& F) in a ModulePass
getAnalysis<DominatorTreeWrapperPass>() in a FunctionPass
Yeah that’s how you access function analyses from a module pass.
Thank you
Inserting intrinsic declarations from a function pass is considered okay, but inserting a non-intrinsic declaration is a bit less clear.
What exactly are you using doFinalization for? Everything you’ve mentioned happens before the pass runs.
I add for example printf() as my transform pass uses it to print messages on some branches, and remove it in doFinalization if the prototype is actually not being used