This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Improve LLVM IR constant import.
ClosedPublic

Authored by gysit on May 10 2023, 7:57 AM.

Details

Summary

Improve the constant import to handle zeroinitializer as well as
additional float types such as quad floats. The logic got restructured
to avoid creating intermediate dense element attributes when
constructing multi-dimensional arrays. Additionally, we also leverage
the fact that we do not need to iterate all elements of splat constants.

Diff Detail

Event Timeline

gysit created this revision.May 10 2023, 7:57 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
gysit requested review of this revision.May 10 2023, 7:57 AM
Dinistro accepted this revision.May 11 2023, 1:01 AM

LGTM, modulo comments.

mlir/lib/Target/LLVMIR/ModuleImport.cpp
626

It seems that all users of this function essentially use it to check if something is a scalar type or not. Can we not just return a boolean and rename this to isScalarType?

678

It's a bit sad that this function internally copies the vector or does not use it at all. On the other hand, moving a SmallVector might also not be worth it.

735

NIT: Is the capturing really required?

This revision is now accepted and ready to land.May 11 2023, 1:01 AM
gysit updated this revision to Diff 521249.May 11 2023, 3:48 AM

Address comments.

gysit marked an inline comment as done.May 11 2023, 3:57 AM
gysit added inline comments.
mlir/lib/Target/LLVMIR/ModuleImport.cpp
678

I considered passing it by reference but decided it is not nice to mutate the vector inside the function. Also moving seems to be the same as copying in this case. I thus decided to stick to the current version.

735

I need it to capture the this pointer.

This revision was automatically updated to reflect the committed changes.