LLVM Pass Managers

Hello all,

I have 2 separate questions:

1, What are the differences between LegacyPassManager and PassManager? I see that opt uses the former most of the times while the latter is used via PassBuilder API when an user wants to build her own pipeline, but I have no idea why so. What to use and when to use it is not clear to me.

2, I’ve asked this question once but have had no answer, so I’m gonna revive it here: in opt, the verify-each mode is only activated when we provide a pass name or a pipeline (list of pass names). I guess this is intended, but I expect that verify-each to insert Verifier to the whole pipeline after each optimization pass, even when I pass -O1/2/3/s/z to opt. And I assume others do expect the same thing.

The 2nd question lead me to another idea: if we really want to make verify-each to work on any pipeline (not only user-provided ones), and we’ll soon have a debugify-each option, should we refactor the code to have a apply-after-each=pass-name option that automatically inserts pass-name to the pipeline after each optimization pass? We can even replace print-after-all option with apply-after-each=PrintModulePassWrapper for example?

Thank you all,

Hi Son,

I have an answer to your first question:

Hi Philip,

Thank you for your reply. So what would be the right way/API to write out-of-tree pass? I’ve been using PassManagerBuilder, which requires a callback refering to legacy::PassManagerBase, so I guess this will be no longer the good way to go?

Hi Son,

PassManagerBuilder is used to populate legacy PassManagers. That role is taken over by PassBuilder for new-PM passes.

Cheers,
Philip

  • Vedant: what do you think about the last point, since Debugify is also related?

Hi,

  • Chandler, who has a lot more experience with our pass managers.
  • Vedant: what do you think about the last point, since Debugify is also related?

Could you clarify the question? I’m not sure what it is you’d like me to chime in about.

2, I’ve asked this question once but have had no answer, so I’m gonna revive it here: in opt, the verify-each mode is only activated when we provide a pass name or a pipeline (list of pass names). I guess this is intended, but I expect that verify-each to insert Verifier to the whole pipeline after each optimization pass, even when I pass -O1/2/3/s/z to opt. And I assume others do expect the same thing.

I’d expect the same thing. I’m pretty sure it’s a missing feature that -verify-each doesn’t apply at opt -O1/etc.

The 2nd question lead me to another idea: if we really want to make verify-each to work on any pipeline (not only user-provided ones), and we’ll soon have a debugify-each option, should we refactor the code to have a apply-after-each=pass-name option that automatically inserts pass-name to the pipeline after each optimization pass? We can even replace print-after-all option with apply-after-each=PrintModulePassWrapper for example?

Speaking for myself, I’d rather type “opt -foo-each” over “opt -apply-after-each=foo”.

best,
vedant

Hi Vedant,

Thanks for your reply. More comments inline.

Hi Vedant,

Thanks for your reply. More comments inline.

I think there was a little confusion, as I thought the “last point” was something Philip had said. I suppose you just meant question #2 from your first email.

This doesn’t seem like a common scenario to me.

vedant

Hi Chandler,

Can you confirm that there’s a bug in verify-each mode at opt -O{0/1/2/3/s/z}?