This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Pass] Handle spaces in pipeline strings
ClosedPublic

Authored by boschmitt on Jan 28 2023, 4:53 PM.

Details

Summary

An user might want to add extra spaces for better readability, e.g:

mypm = pm.PassManager.parse(f"""builtin.module(
    mypass1,
    func.func(mypass2,mypass3)
)""")

GitHub issue #59151

The parser was not taking into account the possibility of spaces after )or }

Diff Detail

Event Timeline

boschmitt created this revision.Jan 28 2023, 4:53 PM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
boschmitt requested review of this revision.Jan 28 2023, 4:53 PM
boschmitt edited the summary of this revision. (Show Details)Jan 28 2023, 4:56 PM
boschmitt updated this revision to Diff 493083.Jan 29 2023, 3:45 AM

Rebase. Fix typo in comments.

myhsu added a subscriber: myhsu.

Could you add a test (not a multi-line one, just a pipeline string with white spaces) in test/Pass/pipeline-parsing.mlir as well? It should be easy

Add another test and rebase

Could you add a test (not a multi-line one, just a pipeline string with white spaces) in test/Pass/pipeline-parsing.mlir as well? It should be easy

Thanks for the review. I'm fairly new to the codebase, so I didn't know where else this was being tested.

myhsu accepted this revision.Jan 29 2023, 11:44 AM

LGTM thanks :-)

This revision is now accepted and ready to land.Jan 29 2023, 11:44 AM

There's still some cases where whitespace causes the parsing to fail:

" builtin.module()" - error: can't run ' builtin.module' pass manager on 'builtin.module' op
"builtin.module ()" - error: can't run 'builtin.module ' pass manager on 'builtin.module' op
"builtin.module() " - error: expected pass pipeline to be wrapped with the anchor operation type, e.g. 'builtin.module(...)'
boschmitt updated this revision to Diff 493162.Jan 29 2023, 4:32 PM

Handlle more cases

boschmitt updated this revision to Diff 493163.Jan 29 2023, 4:39 PM

Small fix to avoid unecessary work

myhsu accepted this revision.Jan 30 2023, 9:13 AM

Let us know if you need helps pushing the patching

mlir/test/Pass/pipeline-parsing.mlir
6

super nit: could you move this one line up so that CHECK_ERROR_X tests are put together

boschmitt marked an inline comment as done.Jan 30 2023, 10:52 AM

Yes, I need help pushing the patch as I don't have commit access.

Yes, I need help pushing the patch as I don't have commit access.

Cool, please provide the email you want to use. btw I can help you to push D142818 as well

Cool, please provide the email you want to use. btw I can help you to push D142818 as well

Thank you for the help. The e-mail is bruno@oschmitt.com

This revision was landed with ongoing or failed builds.Jan 30 2023, 12:51 PM
This revision was automatically updated to reflect the committed changes.