[Mlir-commits] [mlir] [mlir] Add `MLIRContext::executeCriticalSection` and `Pass::getOpDependentDialects` methods. (PR #98953)
Fabian Mora
llvmlistbot at llvm.org
Mon Jul 15 16:37:23 PDT 2024
================
@@ -513,6 +513,21 @@ LogicalResult OpToOpPassAdaptor::run(Pass *pass, Operation *op,
};
pass->passState.emplace(op, am, dynamicPipelineCallback);
+ // Get any op dependent dialects.
+ DialectRegistry dependentDialects;
+ pass->getOpDependentDialects(op, dependentDialects);
+ MLIRContext &context = pass->getContext();
+ // Only append a non-empty non-trivial registry.
+ if (!dependentDialects.empty() &&
+ !dependentDialects.isSubsetOf(context.getDialectRegistry())) {
+ context.executeCriticalSection([&]() {
+ // Load the dialects.
+ context.appendDialectRegistry(dependentDialects);
+ for (StringRef name : dependentDialects.getDialectNames())
+ context.getOrLoadDialect(name);
----------------
fabianmcg wrote:
Isn't that in the realm of a bug or undefined behavior? If pass A required `FooOpInterface`, then it should have loaded it before running.
What I meant with my comment is, in a fully correct setup, I think loading a dialect shouldn't introduce non-determinism.
https://github.com/llvm/llvm-project/pull/98953
More information about the Mlir-commits
mailing list