[Mlir-commits] [mlir] [mlir][python][nfc] Test `-print-ir-after-all` (PR #75742)

Rik Huijzer llvmlistbot at llvm.org
Sun Dec 17 09:33:19 PST 2023


https://github.com/rikhuijzer updated https://github.com/llvm/llvm-project/pull/75742

>From c09ccdaf6546cd18fe3c3b2df376a690f549539e Mon Sep 17 00:00:00 2001
From: Rik Huijzer <github at huijzer.xyz>
Date: Sun, 17 Dec 2023 17:04:17 +0100
Subject: [PATCH 1/3] [mlir][python] Add test for `-print-ir-after-all`

---
 mlir/test/python/pass_manager.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/mlir/test/python/pass_manager.py b/mlir/test/python/pass_manager.py
index 0face028b73ff1..ef12e47c0c8c7a 100644
--- a/mlir/test/python/pass_manager.py
+++ b/mlir/test/python/pass_manager.py
@@ -281,3 +281,26 @@ def testPostPassOpInvalidation():
         # CHECK:   return
         # CHECK: }
         log(module)
+
+
+# Test -print-ir-after-all.
+# CHECK-LABEL: TEST: testPrintIrAfterAll
+ at run
+def testPrintIrAfterAll():
+    with Context() as ctx:
+        module = ModuleOp.parse(
+            """
+          module {
+            func.func @main() {
+              %0 = arith.constant 10
+              return
+            }
+          }
+        """
+        )
+        pm = PassManager.parse("builtin.module(canonicalize)")
+        ctx.enable_multithreading(False)
+        pm.enable_ir_printing()
+        pm.run(module)
+        log(module)
+        # CHECK: IR Dump After Canonicalizer

>From f8c3feda92277c0efe208b7dc0f2ff83a8a57e3c Mon Sep 17 00:00:00 2001
From: Rik Huijzer <github at huijzer.xyz>
Date: Sun, 17 Dec 2023 18:30:02 +0100
Subject: [PATCH 2/3] More explicit print

Co-authored-by: Maksim Levental <maksim.levental at gmail.com>
---
 mlir/test/python/pass_manager.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/mlir/test/python/pass_manager.py b/mlir/test/python/pass_manager.py
index ef12e47c0c8c7a..601273352cb6cc 100644
--- a/mlir/test/python/pass_manager.py
+++ b/mlir/test/python/pass_manager.py
@@ -301,6 +301,20 @@ def testPrintIrAfterAll():
         pm = PassManager.parse("builtin.module(canonicalize)")
         ctx.enable_multithreading(False)
         pm.enable_ir_printing()
+        # CHECK: // -----// IR Dump Before Canonicalizer (canonicalize) ('builtin.module' operation) //----- //
+        # CHECK: module {
+        # CHECK:   func.func @main() {
+        # CHECK:     %[[C10:.*]] = arith.constant 10 : i64
+        # CHECK:     return
+        # CHECK:   }
+        # CHECK: }
+        # CHECK: 
+        # CHECK: 
+        # CHECK: // -----// IR Dump After Canonicalizer (canonicalize) ('builtin.module' operation) //----- //
+        # CHECK: module {
+        # CHECK:   func.func @main() {
+        # CHECK:     return
+        # CHECK:   }
+        # CHECK: }
         pm.run(module)
-        log(module)
         # CHECK: IR Dump After Canonicalizer

>From 9db9cdadec34d554aee153613298503cf2afaf3f Mon Sep 17 00:00:00 2001
From: Rik Huijzer <github at huijzer.xyz>
Date: Sun, 17 Dec 2023 18:33:09 +0100
Subject: [PATCH 3/3] Remove test description comment

---
 mlir/test/python/pass_manager.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mlir/test/python/pass_manager.py b/mlir/test/python/pass_manager.py
index 601273352cb6cc..43af80b53166cc 100644
--- a/mlir/test/python/pass_manager.py
+++ b/mlir/test/python/pass_manager.py
@@ -283,7 +283,6 @@ def testPostPassOpInvalidation():
         log(module)
 
 
-# Test -print-ir-after-all.
 # CHECK-LABEL: TEST: testPrintIrAfterAll
 @run
 def testPrintIrAfterAll():
@@ -308,8 +307,6 @@ def testPrintIrAfterAll():
         # CHECK:     return
         # CHECK:   }
         # CHECK: }
-        # CHECK: 
-        # CHECK: 
         # CHECK: // -----// IR Dump After Canonicalizer (canonicalize) ('builtin.module' operation) //----- //
         # CHECK: module {
         # CHECK:   func.func @main() {
@@ -317,4 +314,3 @@ def testPrintIrAfterAll():
         # CHECK:   }
         # CHECK: }
         pm.run(module)
-        # CHECK: IR Dump After Canonicalizer



More information about the Mlir-commits mailing list