This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Pass] Make PassManager default to op-agnostic

Authored by rkayaith on Nov 9 2022, 12:36 PM.



Currently PassManager defaults to being anchored on builtin.module.
Switching the default makes PassManager consistent with
OpPassManager and avoids the implicit dependency on builtin.module.

Specifying the anchor op type isn't strictly necessary when using
explicit nesting (existing pipelines will continue to work), but I've
updated most call sites to specify the anchor since it allows for better
error-checking during pipeline construction.

Diff Detail

Event Timeline

rkayaith created this revision.Nov 9 2022, 12:36 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
rkayaith updated this revision to Diff 474374.Nov 9 2022, 2:40 PM

fix for doc change

rkayaith published this revision for review.Nov 9 2022, 2:41 PM
rkayaith added a reviewer: mehdi_amini.
rriddle added inline comments.Nov 9 2022, 2:49 PM

Can you add a utility template class that takes the operation type? It'd be nice to preserve the simplicity when the anchor type is known (common for real pipelines), e.g.:

template <typename OpType>
class PassManagerOn : public PassManager ...

That would remove the need for most of the "dialect.opname"/"Op::getOperationName()"/"getName" calls when building a known passmanager.

rkayaith updated this revision to Diff 474561.Nov 10 2022, 8:54 AM
rkayaith marked an inline comment as done.
rkayaith edited the summary of this revision. (Show Details)

add PassManagerOn class

rkayaith added inline comments.Nov 10 2022, 8:57 AM

I added this + ModulePassManager as an alias, though I think there's a potential footgun since it's possible to change the anchor after the pass manager is created, e.g.

rriddle accepted this revision.Nov 15 2022, 12:25 PM
rriddle added inline comments.

Good point there. We could have a run method in PassManagerOn that verifies that the anchor is actually correct. We could also just have a templated construction method that returns a pass manager? Just making sure we don't lose the niceties of the API when we don't want "any" anchor.


I'd just drop any special usings for ModuleOp, it helps keep the API free from builtin deps.

This revision is now accepted and ready to land.Nov 15 2022, 12:25 PM
rkayaith planned changes to this revision.Dec 29 2022, 12:33 PM

I plan to rebase this + switch to a constructor method (static PassManager::on<T>(MLIRContext*) -> PassManager)

rkayaith updated this revision to Diff 491206.Jan 22 2023, 2:25 PM
rkayaith edited the summary of this revision. (Show Details)

Switch from PassManagerOn<T> to constructor method

This revision is now accepted and ready to land.Jan 22 2023, 2:25 PM
This revision was automatically updated to reflect the committed changes.