[all-commits] [llvm/llvm-project] 47364f: [mlir][IR] Move the storage for results to before ...

River Riddle via All-commits all-commits at lists.llvm.org
Fri Dec 4 21:12:52 PST 2020


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 47364f95e810f96fd300ceaa095719f76683e6fa
      https://github.com/llvm/llvm-project/commit/47364f95e810f96fd300ceaa095719f76683e6fa
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2020-12-04 (Fri, 04 Dec 2020)

  Changed paths:
    M mlir/include/mlir/IR/Operation.h
    M mlir/include/mlir/IR/OperationSupport.h
    M mlir/lib/IR/Operation.cpp
    M mlir/lib/IR/OperationSupport.cpp

  Log Message:
  -----------
  [mlir][IR] Move the storage for results to before the Operation instead of after.

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.

Differential Revision: https://reviews.llvm.org/D92687




More information about the All-commits mailing list