[Mlir-commits] [mlir] bd106d7 - [mlir][Pass] Only enable/disable CrashRecovery once
River Riddle
llvmlistbot at llvm.org
Wed Nov 18 18:56:24 PST 2020
Author: River Riddle
Date: 2020-11-18T18:50:18-08:00
New Revision: bd106d74692fdc4d1eb79fb3a78da144f38791da
URL: https://github.com/llvm/llvm-project/commit/bd106d74692fdc4d1eb79fb3a78da144f38791da
DIFF: https://github.com/llvm/llvm-project/commit/bd106d74692fdc4d1eb79fb3a78da144f38791da.diff
LOG: [mlir][Pass] Only enable/disable CrashRecovery once
This prevents potential problems that occur when multiple pass managers register crash recovery contexts.
Added:
Modified:
mlir/lib/Pass/Pass.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index ae10d1059d83..ac236bbcc4a8 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -670,6 +670,8 @@ RecoveryReproducerContext::RecoveryReproducerContext(
// Make sure that the handler is registered, and update the current context.
llvm::sys::SmartScopedLock<true> producerLock(*reproducerMutex);
+ if (reproducerSet->empty())
+ llvm::CrashRecoveryContext::Enable();
registerSignalHandler();
reproducerSet->insert(this);
}
@@ -677,6 +679,8 @@ RecoveryReproducerContext::RecoveryReproducerContext(
RecoveryReproducerContext::~RecoveryReproducerContext() {
llvm::sys::SmartScopedLock<true> producerLock(*reproducerMutex);
reproducerSet->remove(this);
+ if (reproducerSet->empty())
+ llvm::CrashRecoveryContext::Disable();
}
LogicalResult RecoveryReproducerContext::generate(std::string &error) {
@@ -745,7 +749,6 @@ PassManager::runWithCrashRecovery(MutableArrayRef<std::unique_ptr<Pass>> passes,
verifyPasses);
// Safely invoke the passes within a recovery context.
- llvm::CrashRecoveryContext::Enable();
LogicalResult passManagerResult = failure();
llvm::CrashRecoveryContext recoveryContext;
recoveryContext.RunSafelyOnThread([&] {
@@ -754,7 +757,6 @@ PassManager::runWithCrashRecovery(MutableArrayRef<std::unique_ptr<Pass>> passes,
return;
passManagerResult = success();
});
- llvm::CrashRecoveryContext::Disable();
if (succeeded(passManagerResult))
return success();
More information about the Mlir-commits
mailing list