[Mlir-commits] [mlir] Fix references of attributes which are not defined earlier (PR #134364)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Apr 4 03:56:11 PDT 2025
https://github.com/tdanyluk created https://github.com/llvm/llvm-project/pull/134364
If an attribute is not defined earlier in the same file, but just referenced from its dialect directly, then currently not the correct check is being emited.
What would it emit for this:
Earlier:
// CHECK: #[['?']]<[1, 2, 3]>
Now:
// CHECK: #toy.shape<[1, 2, 3]>
>From e28309f83df9231a8f41190f9eb8f215a4cfe2e8 Mon Sep 17 00:00:00 2001
From: Thomas Danyluk <tdanyluk at nvidia.com>
Date: Fri, 4 Apr 2025 10:43:53 +0000
Subject: [PATCH] Fix references of attributes which are not defined earlier
If an attribute is not defined earlier in the same file, but just referenced
from its dialect directly, then currently not the correct check is being emited.
What would it emit for this:
Earlier:
// CHECK: #[['?']]<[1, 2, 3]>
Now:
// CHECK: #toy.shape<[1, 2, 3]>
---
mlir/utils/generate-test-checks.py | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/mlir/utils/generate-test-checks.py b/mlir/utils/generate-test-checks.py
index 749bfa13fe734..f15d0fee0ea11 100755
--- a/mlir/utils/generate-test-checks.py
+++ b/mlir/utils/generate-test-checks.py
@@ -145,10 +145,9 @@ def generate_name(self, source_attribute_name):
return attribute_name
# Get the saved substitution name for the given attribute name. If no name
- # has been generated for the given attribute yet, the source attribute name
- # itself is returned.
+ # has been generated for the given attribute yet, None is returned.
def get_name(self, source_attribute_name):
- return self.map[source_attribute_name] if source_attribute_name in self.map else '?'
+ return self.map[source_attribute_name] if source_attribute_name in self.map else None
# Return the number of SSA results in a line of type
# %0, %1, ... = ...
@@ -227,9 +226,9 @@ def process_attribute_references(line, attribute_namer):
components = ATTR_RE.split(line)
for component in components:
m = ATTR_RE.match(component)
- if m:
- output_line += '#[[' + attribute_namer.get_name(m.group(1)) + ']]'
- output_line += component[len(m.group()):]
+ attribute_name = attribute_namer.get_name(m.group(1)) if m else None
+ if attribute_name:
+ output_line += f'#[[{attribute_name}]]{component[len(m.group()):]}'
else:
output_line += component
return output_line
More information about the Mlir-commits
mailing list