/// Set the flag specifying if multi-threading is disabled by the context.
void disableMultithreading(bool disable = true);
+ void enableMultithreading(bool enable = true) {
+ disableMultithreading(!enable);
+ }
/// Return true if we should attach the operation to diagnostics emitted via
/// Operation::emit.
bool verifyPasses, SourceMgr &sourceMgr,
MLIRContext *context,
const PassPipelineCLParser &passPipeline) {
+ // Disable multi-threading when parsing the input file. This removes the
+ // unnecessary/costly context synchronization when parsing.
+ bool wasThreadingEnabled = context->isMultithreadingEnabled();
+ context->disableMultithreading();
+
+ // Parse the input file and reset the context threading state.
OwningModuleRef module(parseSourceFile(sourceMgr, context));
+ context->enableMultithreading(wasThreadingEnabled);
if (!module)
return failure();
// Parse pass names in main to ensure static initialization completed.
cl::ParseCommandLineOptions(argc, argv, "MLIR modular optimizer driver\n");
- MLIRContext context;
if(showDialects) {
llvm::outs() << "Registered Dialects:\n";
+ MLIRContext context;
for(Dialect *dialect : context.getRegisteredDialects()) {
llvm::outs() << dialect->getNamespace() << "\n";
}