[all-commits] [llvm/llvm-project] 82c6ee: [MLIR] Add a second map for registered OperationNa...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Sun Mar 31 12:28:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 82c6eeed08b1c8267f6e92d594c910fe57a9775e
      https://github.com/llvm/llvm-project/commit/82c6eeed08b1c8267f6e92d594c910fe57a9775e
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2024-03-31 (Sun, 31 Mar 2024)

  Changed paths:
    M mlir/include/mlir/Dialect/Arith/IR/Arith.h
    M mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h
    M mlir/include/mlir/IR/Builders.h
    M mlir/include/mlir/IR/OpDefinition.h
    M mlir/include/mlir/IR/OperationSupport.h
    M mlir/lib/IR/MLIRContext.cpp

  Log Message:
  -----------
  [MLIR] Add a second map for registered OperationName in MLIRContext (NFC) (#87170)

This speeds up registered op creation by 10-11% by allowing lookup by
TypeID instead of StringRef.

This can break your build/tests at runtime with an error that you're creating
an unregistered operation that you have registered. If so you are likely using
a class inheriting from the "real" operation. See for example in this patch the
case of:

  class ConstantIndexOp : public arith::ConstantOp {


If one is using `builder.create<ConstantIndexOp>()` they actually create an
`arith.constant` operation, but the builder will fetch the TypeID for 
the `ConstantIndexOp` class which does not correspond to any registered
operation. To fix it the `ConstantIndexOp` class got this addition:

  static ::mlir::TypeID resolveTypeID() { return TypeID::get<ConstantOp>(); }



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list