Page MenuHomePhabricator

[mlir][IR] Move the storage for results to before the Operation instead of after.
ClosedPublic

Authored by rriddle on Dec 4 2020, 1:59 PM.

Details

Summary

Trailing objects are really nice for storing additional data inline with the main class, and is something that we heavily take advantage of for Operation(and many other classes). To get the address of the inline data you need to compute the address by doing some pointer arithmetic taking into account any objects stored before the object you want to access. Most classes keep the count of the number of objects, so this is relatively cheap to compute. This is not the case for results though, which have two different types(inline and trailing) that are not necessarily as cheap to compute as the count for other objects. This revision moves the storage for results to before the operation and stores them in reverse order. This allows for getting results to still be very fast given that they are never iterated directly in order, and also greatly improves the speed when accessing the other trailing objects of an operation(operands/regions/blocks/etc).

This reduced compile time when compiling a decently sized mlir module by about ~400ms, or 2.17s -> 1.76s.

Diff Detail

Event Timeline

rriddle created this revision.Dec 4 2020, 1:59 PM
rriddle requested review of this revision.Dec 4 2020, 1:59 PM
mehdi_amini accepted this revision.Dec 4 2020, 3:26 PM
mehdi_amini added inline comments.
mlir/include/mlir/IR/Operation.h
678

is "Trailing" still accurate?

This revision is now accepted and ready to land.Dec 4 2020, 3:26 PM
rriddle marked an inline comment as done.Dec 4 2020, 3:41 PM
rriddle added inline comments.
mlir/include/mlir/IR/Operation.h
678

From the perspective of english, it still works. From confusion related to TrailingObject/PrefixObject less so. I can change if you want, but didn't see a strong need. I kind of look at whether it is after/before as more of an internal implementation detail unrelated to the naming of the class.

This revision was automatically updated to reflect the committed changes.
rriddle marked an inline comment as done.