[PATCH] D75399: Ensure that multi-threading is disabled when enabling IRPrinting with module scope
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 28 22:13:33 PST 2020
mehdi_amini created this revision.
mehdi_amini added a reviewer: rriddle.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar.
Herald added 1 blocking reviewer(s): rriddle.
Herald added a project: LLVM.
This is avoid the user to shoot themselves in the foot. and encounter issues.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75399
Files:
mlir/include/mlir/Pass/PassManager.h
mlir/lib/Pass/IRPrinting.cpp
mlir/lib/Pass/Pass.cpp
Index: mlir/lib/Pass/Pass.cpp
===================================================================
--- mlir/lib/Pass/Pass.cpp
+++ mlir/lib/Pass/Pass.cpp
@@ -598,6 +598,10 @@
getImpl().disableThreads = disable;
}
+bool PassManager::isMultithreadingEnabled() {
+ return !getImpl().disableThreads;
+}
+
/// Enable support for the pass manager to generate a reproducer on the event
/// of a crash or a pass failure. `outputFile` is a .mlir filename used to write
/// the generated reproducer.
Index: mlir/lib/Pass/IRPrinting.cpp
===================================================================
--- mlir/lib/Pass/IRPrinting.cpp
+++ mlir/lib/Pass/IRPrinting.cpp
@@ -256,6 +256,9 @@
/// Add an instrumentation to print the IR before and after pass execution,
/// using the provided configuration.
void PassManager::enableIRPrinting(std::unique_ptr<IRPrinterConfig> config) {
+ if (config->shouldPrintAtModuleScope() && isMultithreadingEnabled())
+ llvm::report_fatal_error("IR printing can't be setup on a pass-manager "
+ "without disabling multi-threading first.");
addInstrumentation(
std::make_unique<IRPrinterInstrumentation>(std::move(config)));
}
Index: mlir/include/mlir/Pass/PassManager.h
===================================================================
--- mlir/include/mlir/Pass/PassManager.h
+++ mlir/include/mlir/Pass/PassManager.h
@@ -139,6 +139,9 @@
/// Disable support for multi-threading within the pass manager.
void disableMultithreading(bool disable = true);
+ /// Return true if the PassManager is configured with multi-threading enabled.
+ bool isMultithreadingEnabled();
+
/// Enable support for the pass manager to generate a reproducer on the event
/// of a crash or a pass failure. `outputFile` is a .mlir filename used to
/// write the generated reproducer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75399.247408.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200229/cf450c24/attachment.bin>
More information about the llvm-commits
mailing list