Skip to content

Commit d2f4c5c

Browse files
committed
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 #toy.shape<[1, 2, 3]>: Earlier: // CHECK: #[['?']]<[1, 2, 3]> Now: // CHECK: #toy.shape<[1, 2, 3]>
1 parent d6c076e commit d2f4c5c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,13 @@ def generate_name(self, source_attribute_name):
145145
return attribute_name
146146

147147
# Get the saved substitution name for the given attribute name. If no name
148-
# has been generated for the given attribute yet, the source attribute name
149-
# itself is returned.
148+
# has been generated for the given attribute yet, None is returned.
150149
def get_name(self, source_attribute_name):
151-
return self.map[source_attribute_name] if source_attribute_name in self.map else '?'
150+
return (
151+
self.map[source_attribute_name]
152+
if source_attribute_name in self.map
153+
else None
154+
)
152155

153156
# Return the number of SSA results in a line of type
154157
# %0, %1, ... = ...
@@ -227,9 +230,9 @@ def process_attribute_references(line, attribute_namer):
227230
components = ATTR_RE.split(line)
228231
for component in components:
229232
m = ATTR_RE.match(component)
230-
if m:
231-
output_line += '#[[' + attribute_namer.get_name(m.group(1)) + ']]'
232-
output_line += component[len(m.group()):]
233+
attribute_name = attribute_namer.get_name(m.group(1)) if m else None
234+
if attribute_name:
235+
output_line += f"#[[{attribute_name}]]{component[len(m.group()):]}"
233236
else:
234237
output_line += component
235238
return output_line

0 commit comments

Comments
 (0)