This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Support SSA values in runtime op verification errors
Needs ReviewPublic

Authored by springerm on Nov 28 2022, 12:08 AM.



This change allows additional msgArgs SSA values in cf.assert. The assert message is now a simple format string. E.g.:

cf.assert %condition, "found {}, expected {}"(%0, %1) : index, index

The runtime op verifier of memref.cast is extended such that it generates more descriptive runtime errors with full memref types. E.g.:

memref.cast: invalid cast from memref<5xf32, strided<[1], offset: 0> to memref<10xf32>

This change also adds a printStr helper function to the runtime library. puts can no longer be used because it automatically adds a new-line character. fputs cannot be used either because it requires an additional output stream argument, which is hard to produce in LLVMIR. (fputs does not add a new-line character.)

Depends On D138671

Diff Detail

Event Timeline

springerm created this revision.Nov 28 2022, 12:08 AM
Herald added a project: Restricted Project. · View Herald Transcript
springerm requested review of this revision.Nov 28 2022, 12:08 AM
springerm planned changes to this revision.Nov 28 2022, 12:09 AM
springerm added inline comments.Dec 5 2022, 2:18 AM

I don't know how to do this without adding a new function here. puts cannot be used because it adds \n to the string. fputs cannot be used because I don't know how to pass stderr as an argument from LLVMIR.

springerm edited the summary of this revision. (Show Details)Dec 5 2022, 2:18 AM
springerm retitled this revision from [WIP][mlir] Support SSA values in runtime op verification errors to [mlir] Support SSA values in runtime op verification errors.
springerm added reviewers: rriddle, mehdi_amini.
springerm updated this revision to Diff 482757.Dec 14 2022, 1:28 AM

simplify code and rebase

rriddle added inline comments.Dec 20 2022, 10:42 PM

What are the formatting semantics for the provided arguments? Implementation defined?

Also, why not use an indexed placeholder approach?

springerm updated this revision to Diff 484529.Dec 21 2022, 4:26 AM

better error handling

springerm added inline comments.Dec 21 2022, 4:36 AM

Only I64, F32 and F64 is supported at the moment. For other types that may be added in the future, I would say implementation defined.

By "indexed placeholder", do you mean {0}, {1}, etc.? I thought about this but {}` seemed simpler. Index placeholder would be beneficial if the same value is used multiple times in the msg string, but this is usually not the case in error messages.

springerm updated this revision to Diff 484535.Dec 21 2022, 4:42 AM

update op documentation