This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVM] Add support for arrays in `SplitStores` pattern
ClosedPublic

Authored by zero9178 on Jul 10 2023, 6:15 AM.

Details

Summary

The pattern so far has only supported splitting stores into struct types, marking arrays as explicitly unsupported. This would lead to stores into arrays not being made type-consistent like structs and therefore also not being properly split by SROA and mem2reg.

This patch adds support for array types by creating a common abstraction for both structs and arrays, making an array of size n essentially be treated like a struct with n fields of the arrays element type.
This gives us immediate feature parity without special casing for either of the types.

Diff Detail

Event Timeline

zero9178 created this revision.Jul 10 2023, 6:15 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
zero9178 requested review of this revision.Jul 10 2023, 6:15 AM
gysit accepted this revision.Jul 10 2023, 6:45 AM

Very nice!

LGTM modulo some comment comments.

mlir/lib/Dialect/LLVMIR/Transforms/TypeConsistency.cpp
407

nit: it may now partially write to the last element if it is a nested aggregate.

503

nit: writtenToFields

This revision is now accepted and ready to land.Jul 10 2023, 6:45 AM
zero9178 marked 2 inline comments as done.Jul 10 2023, 6:57 AM