This is an archive of the discontinued LLVM Phabricator instance.

[mlir][DialectConversion] Cache type conversions and add a few useful helpers
ClosedPublic

Authored by rriddle on Jun 11 2020, 12:03 PM.

Details

Summary

It is quite common for the same type to be converted many types throughout the conversion process, and there isn't any good reason why we aren't caching that result. Especially given that we currently use identity conversion to signify legality. This revision also adds a few additional helpers to TypeConverter.

Diff Detail

Event Timeline

rriddle created this revision.Jun 11 2020, 12:03 PM
ftynse added inline comments.Jun 12 2020, 2:30 AM
mlir/lib/Transforms/DialectConversion.cpp
1745

I may be missing something, but doesn't DenseMap::lookup return a default-constructed ValueTy on failure? This will be a null Type in our case. Then: (a) we ignore cached conversion failures because we never enter this block; (b) the checks on cachedConversion not being null inside the block are spurious.

rriddle marked 2 inline comments as done.Jun 12 2020, 10:41 AM
rriddle added inline comments.
mlir/lib/Transforms/DialectConversion.cpp
1745

Oops, thanks for the catch. Forgot to update this after things changed.

ftynse accepted this revision.Jun 12 2020, 11:00 AM
This revision is now accepted and ready to land.Jun 12 2020, 11:00 AM
This revision was automatically updated to reflect the committed changes.
rriddle marked an inline comment as done.