This is an archive of the discontinued LLVM Phabricator instance.

[UpdateTestChecks] Auto-generate stub bodies for unused prefixes
ClosedPublic

Authored by mtrofin on Apr 22 2022, 3:06 PM.

Details

Summary

This is scoped to autogenerated tests.

The goal is to support having each RUN line specify a list of
check-prefixes where one can specify potentially redundant prefixes. For example,
for X86, if one specified prefixes for both AVX1 and AVX2, and the codegen happened to
match today, one of the prefixes would be used and the onther one not.
If the unused prefix were dropped, and later, codegen differences were
introduced, one would have to go figure out where to add what prefix
(paraphrasing
https://lists.llvm.org/pipermail/llvm-dev/2021-February/148326.html)

To avoid getting errors due to unused prefixes, whole directories can be
opted out (as discussed on that thread), but that means that tests that
aren't autogenerated in such directories could have undetected unused
prefix bugs.

This patch proposes an alternative that both avoids the above, dir-level
optout, and supports the main autogen scenario discussed first. The autogen
tool appends at the end of the test file the list of unused prefixes,
together with a note explaining that is the case. Each prefix is set up
to always pass.

This way, unexpected unused prefixes are easily discoverable, and
expected cases "just work".

Diff Detail

Event Timeline

mtrofin created this revision.Apr 22 2022, 3:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2022, 3:06 PM
mtrofin requested review of this revision.Apr 22 2022, 3:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2022, 3:06 PM
MaskRay accepted this revision.May 21 2022, 3:03 PM
MaskRay added inline comments.
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected
33

NOTE is a regular comment, not a check prefix. I wonder whether using ;; for non-RUN non-CHECK lines will be clearer.

This revision is now accepted and ready to land.May 21 2022, 3:03 PM
mtrofin updated this revision to Diff 431520.May 23 2022, 4:24 PM
mtrofin marked an inline comment as done.

double-commenting the "NOTE", also fix in update_cc_test_checks

@RKSimon @lebedev.ri @probinson @nikic @xbolva00 - any pushback to this patch, is it helping/hindering in any way? Thanks!

nikic added a comment.May 24 2022, 8:18 AM

I haven't checked the implementation, but conceptually this looks reasonable.

[UpdateTestChecks] Auto-generate stub bodies for conflicting outputs

Patch title seems unrelated though?

I'm not entirely happy with adding the "unused" noise at the end of the file, but I understand the need for such a workaround to appease lit.

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected
34

Will the script strip these again if a later edit adds uses of a previously unused prefix?

mtrofin updated this revision to Diff 431717.May 24 2022, 10:33 AM

make sure 1) re-running tool doesn't repeat the unused note; and 2) adding a use for a previously unused label removes that label from the note list.

mtrofin marked an inline comment as done.May 24 2022, 10:35 AM
mtrofin added inline comments.
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_no_merge_comments.ll.expected
34

Good catch - added a test for that. Also made the 'note' a bit more verbose.

mtrofin retitled this revision from [UpdateTestChecks] Auto-generate stub bodies for conflicting outputs to [UpdateTestChecks] Auto-generate stub bodies for unused prefixes.May 24 2022, 5:25 PM
mtrofin marked an inline comment as done.

I haven't checked the implementation, but conceptually this looks reasonable.

[UpdateTestChecks] Auto-generate stub bodies for conflicting outputs

Patch title seems unrelated though?

Ah, yes, fixed. It's actually kind of related - turns out one reason some prefixes may end up unused is if they produce conflicting outputs for functions, but that's too specific of a nuance.

RKSimon added inline comments.May 26 2022, 2:38 AM
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1-next.ll
30

;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:

mtrofin updated this revision to Diff 432290.May 26 2022, 8:07 AM
mtrofin marked an inline comment as done.

fix

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/common-label-different-bodies-1-next.ll
30

fixed, thanks!

RKSimon accepted this revision.May 26 2022, 8:14 AM

LGTM

This revision was landed with ongoing or failed builds.May 26 2022, 10:34 AM
This revision was automatically updated to reflect the committed changes.
MatzeB added a subscriber: MatzeB.May 26 2022, 11:50 AM

This change is breaking the build for me: BooleanOptionalAction is only available in python 3.9!

MatzeB added a comment.EditedMay 26 2022, 11:50 AM

This change is breaking the build for me: BooleanOptionalAction is only available in python 3.9!

Well not failing the build but failing various tests for the scripts.

llvm/docs/GettingStarted.rst only asks for python >= 3.6 at the moment.

This change is breaking the build for me: BooleanOptionalAction is only available in python 3.9!

Well not failing the build but failing various tests for the scripts.

Sorry about that - fix coming in a moment.

dyung added a subscriber: dyung.EditedNov 19 2022, 8:47 AM

Wrong change, sorry!