[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:55:39 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: ChenyangXu (Xubaidu)

<details>
<summary>Changes</summary>

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)

---
Full diff: https://github.com/llvm/llvm-project/pull/169615.diff


1 Files Affected:

- (modified) mlir/lib/Pass/PassTiming.cpp (+5-2) 


``````````diff
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();

``````````

</details>


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


More information about the Mlir-commits mailing list