diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -180,8 +180,10 @@ /// should not rely on any state accessible during the execution of a pass. /// For example, `getContext`/`getOperation`/`getAnalysis`/etc. should not be /// invoked within this hook. - /// Returns a LogicalResult to indicate failure, in which case the pass - /// pipeline won't execute. + /// This method is invoked after all dependent dialects for the pipeline are + /// loaded, and is not allowed to load any further dialects (override the + /// `geDependentDialects()` for this purpose instead). Returns a LogicalResult + /// to indicate failure, in which case the pass pipeline won't execute. virtual LogicalResult initialize(MLIRContext *context) { return success(); } /// Indicate if the current pass can be scheduled on the given operation type. diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -820,6 +820,9 @@ if (failed(getImpl().finalizePassList(context))) return failure(); + // Notify the context that we start running a pipeline for book keeping. + context->enterMultiThreadedExecution(); + // Initialize all of the passes within the pass manager with a new generation. llvm::hash_code newInitKey = context->getRegistryHash(); if (newInitKey != initializationKey) { @@ -831,9 +834,6 @@ // Construct a top level analysis manager for the pipeline. ModuleAnalysisManager am(op, instrumentor.get()); - // Notify the context that we start running a pipeline for book keeping. - context->enterMultiThreadedExecution(); - // If reproducer generation is enabled, run the pass manager with crash // handling enabled. LogicalResult result =