forked from OSchip/llvm-project
Ensure that multi-threading is disabled when enabling IRPrinting with module scope
This is avoid the user to shoot themselves in the foot and encounter strange crashes that are confusing until one run with TSAN. Differential Revision: https://reviews.llvm.org/D75399
This commit is contained in:
parent
692e0c9648
commit
07aa9ae23b
|
@ -139,6 +139,10 @@ public:
|
|||
/// Disable support for multi-threading within the pass manager.
|
||||
void disableMultithreading(bool disable = true);
|
||||
|
||||
/// Return true if the pass manager 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.
|
||||
|
|
|
@ -256,6 +256,9 @@ struct BasicIRPrinterConfig : public PassManager::IRPrinterConfig {
|
|||
/// 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)));
|
||||
}
|
||||
|
|
|
@ -598,6 +598,10 @@ void PassManager::disableMultithreading(bool disable) {
|
|||
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.
|
||||
|
|
Loading…
Reference in New Issue