[Mlir-commits] [mlir] [mlir][core] Restore dropped printIR behavior. (PR #196628)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri May 8 12:55:00 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Yi Zhang (cathyzhyi)

<details>
<summary>Changes</summary>

Restore checking for module scope which is dropped in #<!-- -->195198

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


1 Files Affected:

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


``````````diff
diff --git a/mlir/lib/Pass/IRPrinting.cpp b/mlir/lib/Pass/IRPrinting.cpp
index 032d4f7e2d67d..006ce3cbe794a 100644
--- a/mlir/lib/Pass/IRPrinting.cpp
+++ b/mlir/lib/Pass/IRPrinting.cpp
@@ -48,6 +48,11 @@ class IRPrinterInstrumentation : public PassInstrumentation {
 
 static void printIR(Operation *op, bool printModuleScope, raw_ostream &out,
                     OpPrintingFlags flags) {
+  // Check to see if we are not printing at module scope.
+  if (!printModuleScope)
+    return op->print(out, op->getBlock() ? flags.useLocalScope() : flags);
+
+  // Otherwise, we are printing at module scope.
   // Find the top-level operation.
   auto *topLevelOp = op;
   while (auto *parentOp = topLevelOp->getParentOp())

``````````

</details>


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


More information about the Mlir-commits mailing list