[Mlir-commits] [mlir] 4938949 - Revert "Avoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option is set"

Mehdi Amini llvmlistbot at llvm.org
Fri Jan 7 18:25:29 PST 2022


Author: Mehdi Amini
Date: 2022-01-08T02:25:18Z
New Revision: 493894931035fcf3b2cc3e5b682dd12382b69673

URL: https://github.com/llvm/llvm-project/commit/493894931035fcf3b2cc3e5b682dd12382b69673
DIFF: https://github.com/llvm/llvm-project/commit/493894931035fcf3b2cc3e5b682dd12382b69673.diff

LOG: Revert "Avoid creating a ThreadPool in MlirOptMain when `--mlir-disable-threading` option is set"

This reverts commit 45adf608024655d3594993d041af9602da41780f.
Build is broken

Added: 
    

Modified: 
    mlir/lib/Support/MlirOptMain.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Support/MlirOptMain.cpp b/mlir/lib/Support/MlirOptMain.cpp
index 94c7563b1b149..9a8b21d37f254 100644
--- a/mlir/lib/Support/MlirOptMain.cpp
+++ b/mlir/lib/Support/MlirOptMain.cpp
@@ -94,7 +94,7 @@ processBuffer(raw_ostream &os, std::unique_ptr<MemoryBuffer> ownedBuffer,
               bool verifyDiagnostics, bool verifyPasses,
               bool allowUnregisteredDialects, bool preloadDialectsInContext,
               PassPipelineFn passManagerSetupFn, DialectRegistry &registry,
-              llvm::ThreadPool *threadPool) {
+              llvm::ThreadPool &threadPool) {
   // Tell sourceMgr about this buffer, which is what the parser will pick up.
   SourceMgr sourceMgr;
   sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), SMLoc());
@@ -102,8 +102,7 @@ processBuffer(raw_ostream &os, std::unique_ptr<MemoryBuffer> ownedBuffer,
   // Create a context just for the current buffer. Disable threading on creation
   // since we'll inject the thread-pool separately.
   MLIRContext context(registry, MLIRContext::Threading::DISABLED);
-  if (threadPool)
-    context.setThreadPool(*threadPool);
+  context.setThreadPool(threadPool);
 
   // Parse the input file.
   if (preloadDialectsInContext)
@@ -145,15 +144,7 @@ LogicalResult mlir::MlirOptMain(raw_ostream &outputStream,
   // up into small pieces and checks each independently.
   // We use an explicit threadpool to avoid creating and joining/destroying
   // threads for each of the split.
-  ThreadPool *threadPool = nullptr;
-  // Create a temporary context for the sake of checking if
-  // --mlir-disable-threading was passed on the command line.
-  // We use the thread-pool this context is creating, and avoid
-  // creating any thread when disabled.
-  MLIRContext threadPoolCtx;
-  if (threadPoolCtx.isMultithreadingEnabled())
-    threadPool = &threadPoolCtx.getThreadPool();
-
+  llvm::ThreadPool threadPool;
   if (splitInputFile)
     return splitAndProcessBuffer(
         std::move(buffer),
@@ -161,14 +152,14 @@ LogicalResult mlir::MlirOptMain(raw_ostream &outputStream,
           return processBuffer(os, std::move(chunkBuffer), verifyDiagnostics,
                                verifyPasses, allowUnregisteredDialects,
                                preloadDialectsInContext, passManagerSetupFn,
-                               registry, threadPool.get());
+                               registry, threadPool);
         },
         outputStream);
 
   return processBuffer(outputStream, std::move(buffer), verifyDiagnostics,
                        verifyPasses, allowUnregisteredDialects,
                        preloadDialectsInContext, passManagerSetupFn, registry,
-                       threadPool.get());
+                       threadPool);
 }
 
 LogicalResult mlir::MlirOptMain(raw_ostream &outputStream,


        


More information about the Mlir-commits mailing list