This is an archive of the discontinued LLVM Phabricator instance.

Add update_any_test_checks.py convenience utility
ClosedPublic

Authored by nhaehnle on Dec 1 2022, 4:44 AM.

Details

Summary

Given a list of test files, this utility will run (optionally in
parallel) the corresponding update_*_test_checks tool for all given
tests that have automatically generated assertions.

Diff Detail

Event Timeline

nhaehnle created this revision.Dec 1 2022, 4:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 1 2022, 4:44 AM
nhaehnle requested review of this revision.Dec 1 2022, 4:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 1 2022, 4:44 AM
Herald added a subscriber: wdng. · View Herald Transcript
foad added a comment.Dec 1 2022, 4:52 AM

Great idea.

I always run update_llc_test_checks.py with --llc-binary=... and update_test_checks.py with --opt-binary=... How does this new tool support that? Or do I need to change my workflow?

Also, probably out of scope for this patch, but does it handle files that have checks generated by two or more tools, like test/CodeGen/AMDGPU/infinite-loop.ll?

mtrofin accepted this revision.Dec 1 2022, 7:20 AM

Nice!

could you run yapf or some other formatter, to avoid long lines (easier diffing in the future). Maybe leave a comment as to how to run yapf (or whatever tool), too?

(Hmm... thinking out loud, I think maybe we can add a yapf.cfg or something like that in the root of the repo, just like we have .clang-format. Anyway, not for this patch)

llvm/utils/update_any_test_checks.py
72

consider maybe also saying which file this unknown tool was found into?

This revision is now accepted and ready to land.Dec 1 2022, 7:20 AM
nhaehnle added a comment.EditedDec 1 2022, 8:04 AM

Thank you for the quick review! I will give yapf a try.

I always run update_llc_test_checks.py with --llc-binary=... and update_test_checks.py with --opt-binary=... How does this new tool support that? Or do I need to change my workflow?

It doesn't support it at the moment. In my local setup, I source an environment that has all the tools in its PATH. I find that more convenient for other reasons, so didn't try to figure out how to make the alternative work.

Also, probably out of scope for this patch, but does it handle files that have checks generated by two or more tools, like test/CodeGen/AMDGPU/infinite-loop.ll?

Huh, interesting. I think what we'd want to do is to run all the UTC tools in sequence, from the same executor submit. I played around with this just now, and it looks like the tools don't reliably update the header notes about autogenerated tests. So I'd keep that as a separate change if desired.

llvm/utils/update_any_test_checks.py
72

Good idea.

arsenm added a comment.Dec 1 2022, 8:09 AM

I still think having different update_test*_* scripts was a mistake and we should have had one script that understands multiple forms of output. The current situation is divergent behavior with multiple run lines. Currently one of update_test_checks, update_mir_test_checks, and update_llc_test_checks understands the other ones run lines, but the other doesn't. They also can mess up each others superfluous whitespace and "." checks

This revision was automatically updated to reflect the committed changes.

Thank you for the quick review! I will give yapf a try.

I always run update_llc_test_checks.py with --llc-binary=... and update_test_checks.py with --opt-binary=... How does this new tool support that? Or do I need to change my workflow?

It doesn't support it at the moment. In my local setup, I source an environment that has all the tools in its PATH. I find that more convenient for other reasons, so didn't try to figure out how to make the alternative work.

Also, probably out of scope for this patch, but does it handle files that have checks generated by two or more tools, like test/CodeGen/AMDGPU/infinite-loop.ll?

Huh, interesting. I think what we'd want to do is to run all the UTC tools in sequence, from the same executor submit. I played around with this just now, and it looks like the tools don't reliably update the header notes about autogenerated tests. So I'd keep that as a separate change if desired.

I think one of the problems is that tools refuse to update if there is no comment/a comment from another tool unless you pass the --force-update flag to ignore that.

IMO it would be nice if we had a single script to update everything (at least for _test_checks/llc_test_checks/cc_test_checks, not sure about the analyzer/mir ones since this scripts share less code).

Great idea.

I always run update_llc_test_checks.py with --llc-binary=... and update_test_checks.py with --opt-binary=... How does this new tool support that? Or do I need to change my workflow?

One option would be to forward those arguments - maybe all tools should just accept those flags and ignore them if the tool is not used (or --llvm-bin). Another alternative would be to generate a script inside the build dir and then you can run <buil-dir>/utils/update_any_test_checks <path to dir>. I did something like that for the crash testcase reduction tool in CHERI LLVM: https://github.com/CTSRD-CHERI/llvm-project/blob/master/clang/utils/creduce_crash_testcase.py.in