[Mlir-commits] [mlir] [mlir] Update prettyprinters.py to print type id correctly (#132597) (PR #132599)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Mar 23 02:00:23 PDT 2025
https://github.com/CQUEE updated https://github.com/llvm/llvm-project/pull/132599
>From e54eed476685bdca2da5ace7af2d123627d69cdd Mon Sep 17 00:00:00 2001
From: Mark <qq694104630 at gmail.com>
Date: Sun, 23 Mar 2025 15:54:23 +0800
Subject: [PATCH 1/2] [mlir] Update prettyprinters.py to print type id
correctly (#132597)
---
mlir/utils/gdb-scripts/prettyprinters.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/mlir/utils/gdb-scripts/prettyprinters.py b/mlir/utils/gdb-scripts/prettyprinters.py
index 45fd0837c9391..215d84741cf75 100644
--- a/mlir/utils/gdb-scripts/prettyprinters.py
+++ b/mlir/utils/gdb-scripts/prettyprinters.py
@@ -1,6 +1,7 @@
"""GDB pretty printers for MLIR types."""
import gdb.printing
+import re
class StoragePrinter:
@@ -68,8 +69,10 @@ def _init_map(self):
for type_name in self.type_names:
concrete_type = gdb.lookup_type(type_name)
try:
+ # detail::TypeIDExported has been deprecated
+
storage = gdb.parse_and_eval(
- "&'mlir::detail::TypeIDExported::get<%s>()::instance'" % type_name
+ "&mlir::TypeID::get<%s>()" % type_name
)
except gdb.error:
# Skip when TypeID instance cannot be found in current context.
@@ -95,10 +98,15 @@ def __init__(self, string):
def to_string(self):
return self.string
- concrete_type = storage_type_map[val]
+ # Extract the concrete type from the string of storage field info of TypeID.
+ concrete_type = val["storage"]
if not concrete_type:
return None
- return TypeIdPrinter("mlir::TypeID::get<%s>()" % concrete_type)
+ pattern = re.compile(r'<mlir::detail::TypeIDResolver<([^,]+),')
+ match = pattern.search(str(concrete_type))
+ if match:
+ return TypeIdPrinter('mlir::TypeID::get<%s>()' % match.group(1))
+ return None
def get_attr_or_type_printer(val, get_type_id):
>From 6fa077471318f224c8074a4e3b01804ee9210065 Mon Sep 17 00:00:00 2001
From: Mark <qq694104630 at gmail.com>
Date: Sun, 23 Mar 2025 15:54:23 +0800
Subject: [PATCH 2/2] [mlir] Update prettyprinters.py to print type id
correctly (#132597)
---
mlir/utils/gdb-scripts/prettyprinters.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/mlir/utils/gdb-scripts/prettyprinters.py b/mlir/utils/gdb-scripts/prettyprinters.py
index 215d84741cf75..bfc4feab61090 100644
--- a/mlir/utils/gdb-scripts/prettyprinters.py
+++ b/mlir/utils/gdb-scripts/prettyprinters.py
@@ -70,10 +70,7 @@ def _init_map(self):
concrete_type = gdb.lookup_type(type_name)
try:
# detail::TypeIDExported has been deprecated
-
- storage = gdb.parse_and_eval(
- "&mlir::TypeID::get<%s>()" % type_name
- )
+ storage = gdb.parse_and_eval("&mlir::TypeID::get<%s>()" % type_name)
except gdb.error:
# Skip when TypeID instance cannot be found in current context.
continue
@@ -102,10 +99,10 @@ def to_string(self):
concrete_type = val["storage"]
if not concrete_type:
return None
- pattern = re.compile(r'<mlir::detail::TypeIDResolver<([^,]+),')
+ pattern = re.compile(r"<mlir::detail::TypeIDResolver<([^,]+),")
match = pattern.search(str(concrete_type))
if match:
- return TypeIdPrinter('mlir::TypeID::get<%s>()' % match.group(1))
+ return TypeIdPrinter("mlir::TypeID::get<%s>()" % match.group(1))
return None
More information about the Mlir-commits
mailing list