[Mlir-commits] [mlir] [MLIR] Fix crash when using --mlir-timing (PR #109463)
Ian Wood
llvmlistbot at llvm.org
Fri Sep 20 12:55:52 PDT 2024
https://github.com/IanWood1 created https://github.com/llvm/llvm-project/pull/109463
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.
>From 6df1cc9b0d411016c90458eeffc5452df07aa516 Mon Sep 17 00:00:00 2001
From: Ian Wood <ianwood2024 at u.northwestern.edu>
Date: Fri, 20 Sep 2024 19:19:22 +0000
Subject: [PATCH] Reorder PassTiming members
Signed-off-by: Ian Wood <ianwood2024 at u.northwestern.edu>
---
mlir/lib/Pass/PassTiming.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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;
More information about the Mlir-commits
mailing list