This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Prevent implicit downcasting to interfaces
ClosedPublic

Authored by rkayaith on Apr 16 2023, 9:39 PM.

Details

Summary

Currently conversions to interfaces may happen implicitly (e.g.
Attribute -> TypedAttr), failing a runtime assert if the interface
isn't actually implemented. This change marks the Interface(ValueT)
constructor as explicit so that a cast is required.

Where it was straightforward to I adjusted code to not require casts,
otherwise I just made them explicit.

Depends on D148491, D148492

Diff Detail

Event Timeline

rkayaith created this revision.Apr 16 2023, 9:39 PM
rkayaith added inline comments.Apr 16 2023, 10:30 PM
mlir/lib/Dialect/Arith/IR/ArithCanonicalization.td
325–327

Not sure if this is the best way to do this, I couldn't figure out how to get DRR to do the cast.

rkayaith published this revision for review.Apr 16 2023, 10:34 PM
rriddle accepted this revision.Apr 16 2023, 10:43 PM
This revision is now accepted and ready to land.Apr 16 2023, 10:43 PM
This revision was automatically updated to reflect the committed changes.