This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Pass] Check supported op types before running a pass
ClosedPublic

Authored by springerm on Jun 16 2023, 8:15 AM.

Details

Summary

Add extra error checking to prevent passes from being run on unsupported ops through the pass manager infrastructure.

Depends On: D153143

Diff Detail

Event Timeline

springerm created this revision.Jun 16 2023, 8:15 AM
Herald added a project: Restricted Project. · View Herald Transcript
springerm requested review of this revision.Jun 16 2023, 8:15 AM

Can this be tested without using the transform dialect?

springerm updated this revision to Diff 532611.Jun 19 2023, 5:01 AM

add unit test

Can this be tested without using the transform dialect?

I added a unit test. This issue can only be triggered from C++. (I cannot be triggered from test/Pass/pipeline-invalid.mlir.)

Can this be tested without using the transform dialect?

I added a unit test. This issue can only be triggered from C++. (I cannot be triggered from test/Pass/pipeline-invalid.mlir.)

Something like this should work:

// RUN: mlir-opt %s --pass-pipeline='any(test-function-pass)'
module {}
mlir/lib/Pass/Pass.cpp
441–443
springerm marked an inline comment as done.Jun 20 2023, 12:15 AM

Something like this should work:

// RUN: mlir-opt %s --pass-pipeline='any(test-function-pass)'
module {}

I tried this but it does not trigger the error. I spent some time looking into this yesterday and I think I found the reason why but I can't remember now of the top of my head...

mlir/lib/Pass/Pass.cpp
441–443

These checks are all slightly different. E.g., the error is reported at a different time (adding pass vs. running pipeline) or a different error handler is used. It may be possible to simply this, but there is probably some benefit in keeping some redundant checks, so that we can get error messages earlier (when adding a pass and not when running the pipeline later).

Another thing that I tried was putting the entire "op type check" logic into canScheduleOn. This was not possible because there is no MLIRContext available in various parts of the pass infrastructure. (A StringRef is not enough because it cannot be queried for implemented interfaces, which is needed for InterfacePass.)

springerm marked an inline comment as done.Jun 20 2023, 12:17 AM

Something like this should work:

// RUN: mlir-opt %s --pass-pipeline='any(test-function-pass)'
module {}

I tried this but it does not trigger the error. I spent some time looking into this yesterday and I think I found the reason why but I can't remember now of the top of my head...

Actually, this is slightly different can *does* trigger the error! Thx!

add pipeline-invalid.mlir test

mehdi_amini accepted this revision.Jun 20 2023, 3:18 AM
This revision is now accepted and ready to land.Jun 20 2023, 3:18 AM