This revision refactors 1. parser 2. CHECK line adder of utils/update_{,llc_}test_checks.py
so that thir functionality can be re-used by other utility scripts (e.g. D42712)
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 14727 Build 14727: arc lint + arc unit
Event Timeline
These were actually deliberately split apart in the past year, so not sure what makes sense here.
Are you referring to rL305208? It seems to me that attempts to make update_test_checks also handle llc checks were abandoned, but this patch takes a different strategy: maintaining separate 'frontends' and separate logic where it makes sense, but adding common utility functions where possible.
Yep - I killed the duplicate functionality because people couldn't tell which script to use when updating llc tests (and the scripts produced slightly different output, so it was causing bogus diffs).
It's entirely my fault that I didn't do this refactoring myself because I don't know python well enough. So I fully support making these more maintainable by people who actually know what they're doing. :)
One thing that might make the usage clearer - change the script name from "update_test_checks.py" to "update_opt_test_checks.py"? We would then want to update every regression test file that has the old name as part of the 'ADVERT' string, but that should be a mechanical/scriptable change? Or better - use the new script on every test file with the old string to prove that nothing is broken in this refactoring.
If you prefer different scripts for different purposes:
utils/update_opt_test_checks.py input: LLVM IR ; CHECK lines: LLVM IR utils/update_llc_test_checks.py input: LLVM IR ; CHECK lines: assembly utils/update_cc_test_checks.py input: C/C++/ObjC/.. ; CHECK lines: assembly or LLVM IR
If you did not mind merging update_test_checks.py and update_llc_test_checks.py, we could rename and merge these scripts by their input format:
utils/update_ir_test_checks.py input: LLVM IR ; CHECK lines: assembly or LLVM IR utils/update_cc_test_checks.py input: LLVM IR ; CHECK lines: assembly or LLVM IR
Instead of just script name on the ADVERT line, we could also put an extra option to indicate its usage e.g.:
; NOTE: Assertions have been autogenerated by utils/update_ir_test_checks.py --llc ; NOTE: Assertions have been autogenerated by utils/update_ir_test_checks.py --opt
--llc and --opt restrict the script to update ; RUN lines that use the two tools, respectively. By merging the two scripts, we can reduce more boilerplate.
I can do that in another revision (after this revision and D42712 are landed)
I know little about MIR but it seems utils/update_mir_test_checks.py is totally different.
One script with an option to choose the output format sounds good to me.
Note that we do have some regression tests where we check both IR and asm in one file, so make sure that case still works. Recent example is in D42607 - test/Transforms/LoopStrengthReduce/X86/macro-fuse-cmp.ll
It still works
~/Dev/llvm/utils/update_llc_test_checks.py -v --llc-binary=~/Dev/llvm/release/bin/llc test/Transforms/LoopStrengthReduce/X86/macro-fuse-cmp.ll # No change ~/Dev/llvm/utils/update_test_checks.py -v --opt-binary=~/Dev/llvm/release/bin/opt test/Transforms/LoopStrengthReduce/X86/macro-fuse-cmp.ll # There are expected changes. After all the ADVERT line is update_llc_test_checks.py
Friendly ping :) Is anyone against the idea to clean up these utils/update*check_tests.py scripts?
llvm/trunk/utils/UpdateTestChecks/common.py | ||
---|---|---|
64 ↗ | (On Diff #133739) | Hi @MaskRay. I think there is something wrong with this particular line. If the whitespace isn't leading/trailing, removing it will change the line, This particular line breaks utils/update_analyze_test_checks.py |
llvm/trunk/utils/UpdateTestChecks/common.py | ||
---|---|---|
64 ↗ | (On Diff #133739) | Sorry but I don't have any idea what has been going on... When I spli clean up the script... utils/update_analyze_test_checks.py did not exist then.. |
llvm/trunk/utils/UpdateTestChecks/common.py | ||
---|---|---|
64 ↗ | (On Diff #133739) | I wouldn't be surprised if I got something wrong on the analyze script - I wrote it for cost models only so other analysis passes weren't tested. If you can create a bugzilla with a simple repro I'll take a look (but I may need guidance from people who spend more time with python that I do). |
llvm/trunk/utils/UpdateTestChecks/common.py | ||
---|---|---|
64 ↗ | (On Diff #133739) | This is the only problem. I think this line is just wrong. |