This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add support for diagnostics in C API.
ClosedPublic

Authored by ftynse on Oct 2 2020, 6:27 AM.

Details

Summary

Add basic support for registering diagnostic handlers with the context
(actually, the diagnostic engine contained in the context) and processing
diagnostic messages from the C API.

Diff Detail

Event Timeline

ftynse created this revision.Oct 2 2020, 6:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2020, 6:27 AM
ftynse requested review of this revision.Oct 2 2020, 6:27 AM
ftynse updated this revision to Diff 295815.Oct 2 2020, 6:31 AM

Reorganize comments

stellaraccident accepted this revision.Oct 2 2020, 7:40 AM

Thanks - this will be very helpful.

Nits and one question about API stability.

mlir/include/mlir-c/Support.h
61

How likely do you think it will be that this will change? At an API boundary like this with inline functions, even though insulated behind a function call, it would be quite a chaotic thing to change it (ie. Existing binaries interpreting true values as false). If this is a serious possibility to flip semantics, better to take the optimization hit and make the accessors opaque.

On the other hand, this seems like a totally fine thing for the C API to specify completely and disallow future change: if the underlying implementation changes semantics, the C API layer would translate to the compatible semantics.

74

Did you mean to lowercase the leasing "m"?

mlir/test/CAPI/ir.c
1017

Typo in "CHEKC"

This revision is now accepted and ready to land.Oct 2 2020, 7:40 AM
ftynse updated this revision to Diff 296129.Oct 5 2020, 2:52 AM
ftynse marked 2 inline comments as done.

Review

ftynse added inline comments.Oct 5 2020, 2:53 AM
mlir/include/mlir-c/Support.h
61

I don't expect this to change, but also don't want users to inspect things directly. But it's C, so direct inspection is probably unavoidable, so we may just use an enum instead. WDYT?

stellaraccident added inline comments.Oct 5 2020, 8:19 AM
mlir/include/mlir-c/Support.h
61

It's C - the best you can do is provide a speed bump. I'm fine with how you have it, but I think you should remove the part of the comment about this changing: in fact we need a string guarantee that it doesn't change, and it is put together this way for legibility.

ftynse updated this revision to Diff 296649.Oct 7 2020, 5:38 AM

Clarify comments

ftynse added inline comments.Oct 7 2020, 5:41 AM
mlir/include/mlir-c/Support.h
61

I removed that part of the comment. Just for completeness, here how the enum solution would look like - https://reviews.llvm.org/D88960. It would allow for if (someOperation())-style checks, which is what LogicalResult was expected to solve.

This revision was landed with ongoing or failed builds.Oct 7 2020, 5:42 AM
This revision was automatically updated to reflect the committed changes.