[Mlir-commits] [mlir] [MLIR][Timing] Fix timing report of nested pass pipeline and negative Rest field when using -mlir-timing (PR #169615)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Nov 25 22:54:49 PST 2025


https://github.com/Xubaidu created https://github.com/llvm/llvm-project/pull/169615

This PR tries to close [[MLIR][Timing] Nested pipeline is displayed at top level and show negative Rest field when using -mlir-timing](https://github.com/llvm/llvm-project/issues/169443)

>From 3a6ef8c2bc01f3b27b1d0e076428534df3ea238d Mon Sep 17 00:00:00 2001
From: Chenyang Xu <chenyangx at nvidia.com>
Date: Wed, 26 Nov 2025 14:52:34 +0800
Subject: [PATCH] fix timing

---
 mlir/lib/Pass/PassTiming.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Pass/PassTiming.cpp b/mlir/lib/Pass/PassTiming.cpp
index dab56f09a72eb..8b78a99069cc9 100644
--- a/mlir/lib/Pass/PassTiming.cpp
+++ b/mlir/lib/Pass/PassTiming.cpp
@@ -90,6 +90,9 @@ struct PassTiming : public PassInstrumentation {
     auto &activeTimers = activeThreadTimers[tid];
     auto &parentScope = activeTimers.empty() ? rootScope : activeTimers.back();
 
+    // Record the parent information for this pass so nested pipelines can find it,
+    // regardless of whether this is an adaptor pass or a regular pass.
+    parentTimerIndices[{tid, pass}] = activeTimers.size();
     if (auto *adaptor = dyn_cast<OpToOpPassAdaptor>(pass)) {
       parentTimerIndices[{tid, pass}] = activeTimers.size();
       auto scope =
@@ -107,8 +110,8 @@ struct PassTiming : public PassInstrumentation {
 
   void runAfterPass(Pass *pass, Operation *) override {
     auto tid = llvm::get_threadid();
-    if (isa<OpToOpPassAdaptor>(pass))
-      parentTimerIndices.erase({tid, pass});
+    // Erase the parent index mapping for this pass (adaptor or not).
+    parentTimerIndices.erase({tid, pass});
     auto &activeTimers = activeThreadTimers[tid];
     assert(!activeTimers.empty() && "expected active timer");
     activeTimers.pop_back();



More information about the Mlir-commits mailing list