Is there a finalizer method in the new pass infrastructure?

Hi all,

It seems like the new pass manager mostly leverages passes written in PassInfoMixin. I think if I want to create a pass, I should start leveraging the new infrastructure, making me want to derive a pass out of PassInfoMixin.

However I don’t find any similar finalizer functionalities in the new pass infrastructure. Maybe I am missing something here? Or is it just that the new infrastructure decided not to implement such functionality?


eop Chen

So far there hasn’t been a reason to implement it, and adding support for it adds complexity. Do you have a use case that requires a finalizer method?

Yes. I am working on the GSoC project under the MLGO framework. When accumulating for training logs, I would like to extract loop informations within LoopUnrollPass. In my opinion I think it would be convenient if there is a finalizer method so I can dump the accumulated logs when all loops have been run by the LoopUnrollPass.

Other current cases of building a logger for MLGO, MLRegAllocEvictAdvisor, builds the logger as an ImmutablePass. IIUC, this is a class for the old pass infrastructure. So I am trying to find if there is a way to do this under the new pass infrastructure.

Thank you for replying.


eop Chen

@mtrofin on how ML data is extracted during training, especially with the inliner which I believe already works well.

IIUC, the pass queries for some analysis and calls various methods of it to give it info on successful/failed inlinings. It also calls some method on the analysis when the pass starts and ends. Not sure exactly how everything is dumped/cleaned up at the end.

We chatted on Slack, I think the current, dtor-based mechamism works fine.

1 Like