[Mlir-commits] [mlir] [MLIR] Fix crash when using --mlir-timing (PR #109463)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Sep 20 13:27:44 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Ian Wood (IanWood1)
<details>
<summary>Changes</summary>
Fixes use-after-free when a pipeline fails and `--mlir-timing` is used. The `TimingScope` objects in `activeThreadTimers` access `ownedTimingManager` in their destructor, so `activeThreadTimers` must be destroyed before `ownedTimingManager` is.
This doesn't affect running individual passes (only pipelines) because `PassTiming::runAfterPassFailed` clears `activeThreadTimers` after a pass fails.
---
Full diff: https://github.com/llvm/llvm-project/pull/109463.diff
1 Files Affected:
- (modified) mlir/lib/Pass/PassTiming.cpp (+3-3)
``````````diff
diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp
index 9554c5dd9cb19c..45852455aa7370 100644
--- a/mlir/lib/Pass/PassTiming.cpp
+++ b/mlir/lib/Pass/PassTiming.cpp
@@ -35,9 +35,6 @@ struct PassTiming : public PassInstrumentation {
/// parent thread into which the new thread should be nested.
DenseMap<PipelineParentInfo, unsigned> parentTimerIndices;
- /// A stack of the currently active timing scopes per thread.
- DenseMap<uint64_t, SmallVector<TimingScope, 4>> activeThreadTimers;
-
/// The timing manager owned by this instrumentation (in case timing was
/// enabled by the user on the pass manager without providing an external
/// timing manager). This *must* appear before the `ownedTimingScope` to
@@ -46,6 +43,9 @@ struct PassTiming : public PassInstrumentation {
std::unique_ptr<TimingManager> ownedTimingManager;
TimingScope ownedTimingScope;
+ /// A stack of the currently active timing scopes per thread.
+ DenseMap<uint64_t, SmallVector<TimingScope, 4>> activeThreadTimers;
+
/// The root timing scope into which timing is reported.
TimingScope &rootScope;
``````````
</details>
https://github.com/llvm/llvm-project/pull/109463
More information about the Mlir-commits
mailing list