[all-commits] [llvm/llvm-project] 84cc18: [mlir] Support DialectRegistry extension compariso...
Nikhil Kalra via All-commits
all-commits at lists.llvm.org
Mon Aug 5 16:32:57 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 84cc1865ef9202af39404ff4524a9b13df80cfc1
https://github.com/llvm/llvm-project/commit/84cc1865ef9202af39404ff4524a9b13df80cfc1
Author: Nikhil Kalra <nikhil.kalra at gmail.com>
Date: 2024-08-06 (Tue, 06 Aug 2024)
Changed paths:
M mlir/examples/transform/Ch2/lib/MyExtension.cpp
M mlir/examples/transform/Ch3/lib/MyExtension.cpp
M mlir/examples/transform/Ch4/lib/MyExtension.cpp
M mlir/include/mlir/IR/DialectRegistry.h
M mlir/lib/Conversion/ConvertToLLVM/ConvertToLLVMPass.cpp
M mlir/lib/Dialect/Affine/TransformOps/AffineTransformOps.cpp
M mlir/lib/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp
M mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
M mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp
M mlir/lib/Dialect/Linalg/TransformOps/DialectExtension.cpp
M mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
M mlir/lib/Dialect/NVGPU/TransformOps/NVGPUTransformOps.cpp
M mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp
M mlir/lib/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp
M mlir/lib/Dialect/Tensor/TransformOps/TensorTransformOps.cpp
M mlir/lib/Dialect/Transform/DebugExtension/DebugExtension.cpp
M mlir/lib/Dialect/Transform/IRDLExtension/IRDLExtension.cpp
M mlir/lib/Dialect/Transform/LoopExtension/LoopExtension.cpp
M mlir/lib/Dialect/Transform/PDLExtension/PDLExtension.cpp
M mlir/lib/Dialect/Vector/TransformOps/VectorTransformOps.cpp
M mlir/lib/IR/Dialect.cpp
M mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
M mlir/test/lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp
M mlir/unittests/Dialect/Transform/BuildOnlyExtensionTest.cpp
M mlir/unittests/IR/DialectTest.cpp
Log Message:
-----------
[mlir] Support DialectRegistry extension comparison (#101119)
`PassManager::run` loads the dependent dialects for each pass into the
current context prior to invoking the individual passes. If the
dependent dialect is already loaded into the context, this should be a
no-op. However, if there are extensions registered in the
`DialectRegistry`, the dependent dialects are unconditionally registered
into the context.
This poses a problem for dynamic pass pipelines, however, because they
will likely be executing while the context is in an immutable state
(because of the parent pass pipeline being run).
To solve this, we'll update the extension registration API on
`DialectRegistry` to require a type ID for each extension that is
registered. Then, instead of unconditionally registered dialects into a
context if extensions are present, we'll check against the extension
type IDs already present in the context's internal `DialectRegistry`.
The context will only be marked as dirty if there are net-new extension
types present in the `DialectRegistry` populated by
`PassManager::getDependentDialects`.
Note: this PR removes the `addExtension` overload that utilizes
`std::function` as the parameter. This is because `std::function` is
copyable and potentially allocates memory for the contained function so
we can't use the function pointer as the unique type ID for the
extension.
Downstream changes required:
- Existing `DialectExtension` subclasses will need a type ID to be
registered for each subclass. More details on how to register a type ID
can be found here:
https://github.com/llvm/llvm-project/blob/8b68e06731e0033ed3f8d6fe6292ae671611cfa1/mlir/include/mlir/Support/TypeID.h#L30
- Existing uses of the `std::function` overload of `addExtension` will
need to be refactored into dedicated `DialectExtension` classes with
associated type IDs. The attached `std::function` can either be inlined
into or called directly from `DialectExtension::apply`.
---------
Co-authored-by: Mehdi Amini <joker.eph at gmail.com>
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