diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -663,7 +663,7 @@ // Optimize each of the nodes within the SCC in parallel. if (failed(optimizeSCCAsync(nodesToVisit, context))) - return failure(); + return failure(); // Recompute the uses held by each of the nodes. for (CallGraphNode *node : nodesToVisit) @@ -678,7 +678,11 @@ // parallel. Note: The number of pass managers here needs to remain constant // to prevent issues with pass instrumentations that rely on having the same // pass manager for the main thread. - size_t numThreads = llvm::hardware_concurrency().compute_thread_count(); + // Note that this lining up is dependent on failableParallelForEach using + // the context thread pool under the covers (the thread count must be + // consistent). + llvm::ThreadPool &threadPool = ctx->getThreadPool(); + size_t numThreads = threadPool.getThreadCount(); if (opPipelines.size() < numThreads) { // Reserve before resizing so that we can use a reference to the first // element. @@ -700,6 +704,8 @@ bool expectedInactive = false; return isActive.compare_exchange_strong(expectedInactive, true); }); + assert(it != activePMs.end() && + "could not find active pass manager for thread"); unsigned pmIndex = it - activePMs.begin(); // Optimize this callable node.