This is an archive of the discontinued LLVM Phabricator instance.

[mlir:PDL] Rework errors for pdl.operations with non-inferrable results
ClosedPublic

Authored by rriddle on Apr 27 2022, 5:34 PM.

Details

Summary

We currently emit an error during verification if a pdl.operation with non-inferrable
results is used within a rewrite. This allows for catching some errors during compile
time, but is slightly broken. For one, the verification at the PDL level assumes that
all dialects have been loaded, which is true at run time, but may not be true when
the PDL is generated (such as via PDLL). This commit fixes this by not emitting the
error if the operation isn't registered, i.e. it uses the mightHave variant of trait/interface
methods.

Secondly, we currently don't verify when a pdl.operation has no explicit results, but the
operation being created is known to expect at least one. This commit adds a heuristic
error to detect these cases when possible and fail. We can't always capture when the user
made an error, but we can capture the most common case where the user expected an
operation to infer its result types (when it actually isn't possible).

Depends on D124582

Diff Detail

Event Timeline

rriddle created this revision.Apr 27 2022, 5:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 5:34 PM
rriddle requested review of this revision.Apr 27 2022, 5:34 PM
jpienaar accepted this revision.Apr 28 2022, 5:50 AM
jpienaar added inline comments.
mlir/lib/Dialect/PDL/IR/PDL.cpp
203

Assume here throws me a bit. This is the user wrote no results, we have nothing to contradict that, so accept they are telling the truth.

How about: don't attempt any verification for unknown op?

This revision is now accepted and ready to land.Apr 28 2022, 5:50 AM
This revision was landed with ongoing or failed builds.Apr 28 2022, 12:58 PM
This revision was automatically updated to reflect the committed changes.
rriddle marked an inline comment as done.