This is an archive of the discontinued LLVM Phabricator instance.

[UTC] Keep function args parenthesis on label line (bumps version to 3)
ClosedPublic

Authored by jsilvanus on Aug 22 2023, 2:31 AM.

Details

Summary

If the function argument block contains patterns, we split argument
matching into a separate SAME line, because LABEL labels may not contain
pattern matches.

Until now, in this case we moved the parenthesis opening the argument block
into the second line.

This generates incorrect labels in case function names are not prefix-free.

For example, for a function foo we generated:

CHECK-LABEL: foo
CHECK-SAME: (<args of foo>)

If the output also contains a function foo.specialzied, then the label for
foo can match foo.specialized, depending on output order.

This patch moves opening parenthesis to the first line, breaking common prefixes:

CHECK-LABEL: foo(
CHECK-SAME: <args of foo>)

Bump the UTC version to 3, and only move the parenthesis for version 3 and later.

The test case is new. I'll precommit it if this patch is accepted.

Diff Detail

Event Timeline

jsilvanus created this revision.Aug 22 2023, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 2:31 AM
Herald added a subscriber: arichardson. · View Herald Transcript
jsilvanus requested review of this revision.Aug 22 2023, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 2:31 AM
jsilvanus updated this revision to Diff 552272.Aug 22 2023, 2:33 AM

Remove stale comment from test case.

jsilvanus added inline comments.Aug 22 2023, 4:53 AM
llvm/utils/UpdateTestChecks/common.py
1285

I'm not a fan of hardcoding "(" here, but this seems to be the only relevant case anyways?

Do we have a fixed policy on version bumps? This seems small enough to be applied to the repository, no?

mtrofin accepted this revision.Aug 28 2023, 10:48 AM

Also not enamored with the "(", but can't think of a better alternative.

This revision is now accepted and ready to land.Aug 28 2023, 10:48 AM
nikic accepted this revision.Aug 28 2023, 10:48 AM

Do we have a fixed policy on version bumps? This seems small enough to be applied to the repository, no?

As this change affects ~all tests, I think we do want to bump the version, even if the difference itself is small.

LGTM from my side.

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/named_function_arguments_split.ll.expected
10

This would also match if there's extra arguments before it, but I guess that's a less likely situation. Unless there's a way to get both, moving the parentheses seems fine...

jsilvanus added inline comments.Aug 29 2023, 7:40 AM
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/named_function_arguments_split.ll.expected
10

Good point. I don't see a way to support both at this point, but it would be possible with FileCheck support, e.g. a CHECK-SAME variant that requires a match to start right at the end of the previous match, similar to what CHECK-NEXT does with lines.

I'm committing this as-is to fix the existing issue of incorrect matches.
We can add the FileCheck support later if needed.