This is an archive of the discontinued LLVM Phabricator instance.

[mlir][CAPI] Include anchor op in mlirParsePassPipeline
ClosedPublic

Authored by rkayaith on Oct 20 2022, 5:36 PM.

Details

Summary

The pipeline string must now include the pass manager's anchor op. This
makes the parse API properly roundtrip the printed form of a pass
manager. Since this is already an API break, I also added an extra
callback argument which is used for reporting errors.

The old functionality of appending to an existing pass manager is
available through mlirOpPassManagerAddPipeline.

Diff Detail

Event Timeline

rkayaith created this revision.Oct 20 2022, 5:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 5:36 PM
rkayaith updated this revision to Diff 469447.Oct 20 2022, 6:40 PM
rkayaith edited the summary of this revision. (Show Details)

description

rkayaith published this revision for review.Oct 20 2022, 6:49 PM
rkayaith added a reviewer: mehdi_amini.
rkayaith added inline comments.
mlir/include/mlir-c/Pass.h
129–132

Maybe this should return an MlirOpPassManager instead now? Though that would require adding something like

// create a PassManager from `pm` and delete it
MlirPassManager mlirPassManagerCreateFromOwnedOpPassManager(MlirContext ctx, MlirOpPassManager pm)

for constructing a PassManager from the result

mehdi_amini accepted this revision.Oct 24 2022, 5:55 PM
mehdi_amini added inline comments.
mlir/include/mlir-c/Pass.h
129–132

Maybe this should return an MlirOpPassManager instead

How would you handle the LogicalResult?

This revision is now accepted and ready to land.Oct 24 2022, 5:55 PM
rkayaith added inline comments.Oct 24 2022, 6:04 PM
mlir/include/mlir-c/Pass.h
129–132

it could return a null object on error, and we would need to add mlirOpPassManagerIsNull, similar to mlirPassManagerIsNull.

or we could use an output argument instead, i.e.

// passManager is an output argument
MlirLogicalResult mlirParsePassPipeline(MlirOpPassManager *passManager, MlirStringRef pipeline,  MlirStringCallback callback, void *userData)

Can we somehow test that the error messages are indeed redirected?

rkayaith updated this revision to Diff 470911.Oct 26 2022, 1:09 PM

add test for error capture

ftynse accepted this revision.Oct 27 2022, 1:45 AM
This revision was automatically updated to reflect the committed changes.
rkayaith marked an inline comment as not done.