This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix DenseArrayAttr's ElementsAttr implementation
AbandonedPublic

Authored by Mogball on Aug 26 2022, 1:10 PM.

Details

Summary

Previously, the dispatch to subclasses was unchecked, resulting in
tryGetValues<int32_t> on a DenseF32ArrayAttr asserting instead of
resulting failure(). This changes the implementation of
getValuesImpl to do dynamic dispatch to the subclasses, failing where
appropriate.

Depends on D132758

Diff Detail

Event Timeline

Mogball created this revision.Aug 26 2022, 1:10 PM
Herald added a project: Restricted Project. · View Herald Transcript
Mogball requested review of this revision.Aug 26 2022, 1:10 PM
rriddle requested changes to this revision.Aug 26 2022, 1:14 PM

Users are not supposed to override this. The long standing TODO has been to change ElementsAttr to check for a failable version.

This revision now requires changes to proceed.Aug 26 2022, 1:14 PM

More specifically, what I've wanted to do (but haven't had time) is to change the value_begin_impl to return FailureOr instead of the iterator directly (and rename to try_value_begin_impl or something). That is described here: https://github.com/llvm/llvm-project/blob/3155e3070c49b31b8d189f5f6caf376fcb82fcfb/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td#L57

I can make the change. You just mean to change iterator value_begin_impl to FailureOr<iterator> try_value_begin_impl?

I can make the change. You just mean to change iterator value_begin_impl to FailureOr<iterator> try_value_begin_impl?

Essentially, yeah.

Mogball abandoned this revision.Aug 30 2022, 11:07 AM

This has been superseded by https://reviews.llvm.org/D132904