Skip to content

Commit fc643cc

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 fc643cc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,9 @@ 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 self.map.get(source_attribute_name)
152151

153152
# Return the number of SSA results in a line of type
154153
# %0, %1, ... = ...
@@ -227,9 +226,9 @@ def process_attribute_references(line, attribute_namer):
227226
components = ATTR_RE.split(line)
228227
for component in components:
229228
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()):]
229+
attribute_name = attribute_namer.get_name(m.group(1)) if m else None
230+
if attribute_name:
231+
output_line += f"#[[{attribute_name}]]{component[len(m.group()):]}"
233232
else:
234233
output_line += component
235234
return output_line

0 commit comments

Comments
 (0)