PSA: Pass pipeline anchor becoming explicit

I have some changes landing soon that will make the anchor op of a textual pass pipeline explicit in various APIs so that the text form can be round-tripped properly. For example instead of:

# old:
mlir-opt -pass-pipeline="func.func(my-pass)"

now you’ll have to use:

# new:
mlir-opt -pass-pipeline="builtin.module(func.func(my-pass))"

This affects the python and C APIs as well.

Changes:

Does the simple mlir-opt -canonicalize ... syntax still work?

Yep, though it can’t be mixed with -pass-pipeline anymore: ⚙ D135745 [mlir][Pass] Disallow mixing -pass-pipeline with other pass options

1 Like

Unfortunately yes :wink: https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/LLVMIR/canonicalize.mlir#L1

Why “unfortunately”? Having to instead type out mlir-opt -pass-pipeline="builtin.module(func.func(canonicalize))" is terribly more verbose and inconvenient.

Is mlir-opt -<unrestricted op/func op pass> equivalent to mlir-opt -pass-pipeline="builtin.module(func.func(<unrestricted op/func op pass>))"?

-canonicalize is not the same as -pass-pipeline="builtin.module(func.func(canonicalize)). Generic passes have no implicit nesting, so you would be running canonicalize at the builtin.module level.

Thanks - but I’m confused about how this is working: llvm-project/scalrep.mlir at 5945ab10c36a908e3cb540f80a7c97dcaf19ec5b · llvm/llvm-project · GitHub

Isn’t -pass-pipeline="builtin.module(func.func(affine-scalrep))" same as -affine-scalrep here?

affine-scalrep is a FuncOp pass, so it gets implicitly nested to func.func.

This was just a wink to Chris here, because I advocated (unsuccessfully) 3 years ago to only support the pipeline form (at the time it would have been -pass-pipeline="func(pass-name)" because func and module were builtin and module was implicit top-level).

But more seriously, because this:

The non textual pipeline is ambiguous and confusing. It embeds too much “magic” to know what’s happening from reading the command line, and it does not scale of compose so it only works for trivial cases: the drawback makes it so that this does not pull its weight IMO (but I was unsuccessful with this line 3 years ago, I don’t expect to be today!)

Time cures all things :slight_smile: