aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
AgeCommit message (Collapse)AuthorFilesLines
2020-02-19[UpdateTestChecks] Add support for '.' in ir function namesSimon Pilgrim1-1/+1
Will let us regenerate from amdgpu float constant tests
2020-02-11[Utils] Allow "on-the-fly" argument changes for update_test_check scriptsJohannes Doerfert1-0/+26
Update test scripts were limited because they performed a single action on the entire file and if that action was controlled by arguments, like the one introduced in D68819, there was no record of it. This patch introduces the capability of changing the arguments passed to the script "on-the-fly" while processing a test file. In addition, an "on/off" switch was added so that processing can be disabled for parts of the file where the content is simply copied. The last extension is a record of the invocation arguments in the auto generated NOTE. These arguments are also picked up in a subsequent invocation, allowing updates with special options enabled without user interaction. To change the arguments the string `UTC_ARGS:` has to be present in a line, followed by "additional command line arguments". That is everything that follows `UTC_ARGS:` will be added to a growing list of "command line arguments" which is reparsed after every update. Reviewed By: arichardson Differential Revision: https://reviews.llvm.org/D69701
2020-01-02update_test_checks: match CHECK-EMPTY lines for replacement.James Y Knight1-1/+1
In a8a89c77ea3c16b45763fca6940bbfd3bef7884f, the script started adding CHECK-EMPTY lines, but the regex for which lines to replace was not updated.
2019-12-31[Utils] Deal with occasionally deleted functionsJohannes Doerfert1-4/+25
When functions exist for some but not all run lines we need to be careful when selecting the prefix. So far, a common prefix was potentially chosen as there was never a "conflict" that would have caused otherwise. With this patch we avoid common prefixes if they are used by run lines that do not emit the function. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D68850
2019-12-31[Utils] Reuse argument variable names in the bodyJohannes Doerfert1-4/+4
If we have `int foo(int a) { return a; }` and we run with --function-signature enabled, we want a single variable declaration for `a` which is reused later. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D69722
2019-12-31[Utils] Allow update_test_checks to scrub attribute annotationsJohannes Doerfert1-1/+3
Attribute annotations on calls, e.g., #0, are not useful on their own. This patch adds a flag to update_test_checks.py to scrub them. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D68851
2019-12-03[UpdateTestChecks] Fix parsing of RUN: lines with line continuationsAlex Richardson1-1/+1
I accidentally broke this in d9542db49e90457de62af3bfe395aaf4c47b68a5 due to incorrectly placed parentheses.
2019-12-02[update_cc_test_checks.py] Use CHECK_RE from commonAlex Richardson1-1/+1
Summary: This change modifies the common.CHECK_RE regex to also handle '//' comment prefixes which allows us to share it between clang and IR tests. Using the regex from common means that *-SAME lines are also stripped now. Before this change using the --function-signature flag would result in -SAME: lines from previous runs not being removed. Reviewers: MaskRay, jdoerfert Reviewed By: jdoerfert Subscribers: jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70890
2019-12-02[UpdateTestChecks] Share the code to parse RUN: lines between all scriptsAlex Richardson1-2/+29
Summary: This commit also introduces a common.debug() function to avoid many `if args.verbose:` statements. Depends on D70428. Reviewers: xbolva00, MaskRay, jdoerfert Reviewed By: MaskRay Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70432
2019-11-20[UptestTestChecks][NFC] Share some common command line options codeAlex Richardson1-0/+8
Summary: Add a function common.parse_commandline_args() that adds options common to all tools (--verbose and --update-only) and returns the parsed commandline arguments. I plan to use the shared parsing of --verbose in a follow-up commit to remove most of the `if args.verbose:` checks in the scripts. Reviewers: xbolva00, MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70428
2019-11-01[Utils] Hide the default behavior change of D68819 under a flagJohannes Doerfert1-2/+2
With D69701, the options used when running the script on a file will be recorded and reused on a rerun. This allows us to hide new features behind flags, starting with the "define" that was introduced in D68819.
2019-11-01[utils] Reflow asm check generation to tolerate blank linesSimon Atanasyan1-1/+4
This change introduces two fixes. The second fix allows to generate a test to check the first fix. - Output `CHECK-EMPTY` prefix for an empty line in ASM output. Before that fix `update_llc_test_checks.py` incorrectly emits `CHECK-NEXT: <space>` prefix. - Fix the `ASM_FUNCTION_MIPS_RE` regex to stop on a real function epilogue not on an inline assembler prologue and include inline assembler code into a test. Differential Revision: https://reviews.llvm.org/D47192
2019-10-30[Utils] Allow update_test_checks to check function informationJohannes Doerfert1-11/+46
Summary: This adds a switch to the update_test_checks that triggers arguments and other function annotations, e.g., personality, to be present in the check line. If not set, the behavior should be the same as before. If arguments are recorded, their names are scrubbed from the IR to allow merging. This patch includes D68153. Reviewers: lebedev.ri, greened, spatel, xbolva00, RKSimon, mehdi_amini Subscribers: bollu, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68819
2019-10-30[UpdateTestChecks] Fix invalid python string escapesAlex Richardson1-3/+3
2019-10-07Allow update_test_checks.py to not scrub names.David Greene1-2/+4
Add a --preserve-names option to tell the script not to replace IR names. Sometimes tests want those names. For example if a test is looking for a modification to an existing instruction we'll want to make the names. Differential Revision: https://reviews.llvm.org/D68081 llvm-svn: 373912
2019-08-07[UpdateTestChecks] Update tests optionDavid Bolvansky1-7/+16
Summary: Port of new feature introduced https://reviews.llvm.org/D65610 to other update scripts. - update_*_checks.py: add an alias -u for --update-only - port --update-only to other update_*_test_checks.py scripts - update script aborts if the test file was generated by another update_*_test_checks.py utility Reviewers: lebedev.ri, RKSimon, MaskRay, reames, gbedwell Reviewed By: MaskRay Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65793 llvm-svn: 368174
2019-07-29[UpdateTestChecks] Emit warning when invalid value for -check-prefix(es) optionDavid Bolvansky1-0/+25
Summary: The script is silent for the following issue: FileCheck %s -check-prefix=CHECK,POPCOUNT FileCheck will catch it later, but I think we can warn here too. Now it warns: ./update_llc_test_checks.py file.ll WARNING: Supplied prefix 'CHECK,POPCOUNT' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores. Did you mean --check-prefixes=CHECK,POPCOUNT? Reviewers: lebedev.ri, spatel, RKSimon, craig.topper, nikic, gbedwell Reviewed By: RKSimon Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64589 llvm-svn: 367244
2019-07-22[utils] Clean up UpdateTestChecks/common.pyFangrui Song1-6/+6
llvm-svn: 366664
2018-12-07[utils] Use operator "in" instead of bound function "has_key"Roger Ferrer Ibanez1-1/+1
has_key has been removed in Python 3. The in comparison operator can be used instead. Differential Revision: https://reviews.llvm.org/D55310 llvm-svn: 348576
2018-06-01[Utils][X86] Help update_llc_test_checks.py to recognise retl/retq to reduce ↵Simon Pilgrim1-9/+30
CHECK duplication (PR35003) This patch replaces the --x86_extra_scrub command line argument to automatically support a second level of regex-scrubbing if it improves the matching of nearly-identical code patterns. The argument '--extra_scrub' is there now to force extra matching if required. This is mostly useful to help us share 32-bit/64-bit x86 vector tests which only differs by retl/retq instructions, but any scrubber can now technically support this, meaning test checks don't have to be needlessly obfuscated. I've updated some of the existing checks that had been manually run with --x86_extra_scrub, to demonstrate the extra "ret{{[l|q]}}" scrub now only happens when useful, and re-run the sse42-intrinsics file to show extra matches - most sse/avx intrinsics files should be able to now share 32/64 checks. Tested with the opt/analysis scripts as well which share common code - AFAICT the other update scripts use their own versions. Differential Revision: https://reviews.llvm.org/D47485 llvm-svn: 333749
2018-04-06[UpdateTestChecks] Add update_analyze_test_checks.py for cost model analysis ↵Simon Pilgrim1-5/+21
generation The script allows the auto-generation of checks for cost model tests to speed up their creation and help improve coverage, which will help a lot with PR36550. If the need arises we can add support for other analyze passes as well, but the cost models was the one I needed to get done - at the moment it just warns that any other analysis mode is unsupported. I've regenerated a couple of x86 test files to show the effect. Differential Revision: https://reviews.llvm.org/D45272 llvm-svn: 329390
2018-04-05[UpdateTestChecks] Moved core functionality of add_asm_checks into add_checksSimon Pilgrim1-4/+12
As discussed on D45272 llvm-svn: 329270
2018-04-05[UpdateTestChecks] Split core functionality of add_ir_checks into add_checksSimon Pilgrim1-7/+13
Cherry picked from D45272, also added some setup for add_asm_checks to use add_checks as well. llvm-svn: 329266
2018-04-05[UpdateTestChecks] Remove unnecessary return from add_ir_checksSimon Pilgrim1-1/+0
llvm-svn: 329262
2018-03-14[UpdateTestChecks] Handle IR variables with a '-' in the nameAlexander Richardson1-1/+2
Summary: I noticed that clang will emit variables such as %indirect-arg-temp when running update_cc1_test_checks.py and therefore update_cc1_test_checks.py wasn't adding FileCheck captures for those variables. Reviewers: MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44459 llvm-svn: 327564
2018-03-14Fix LLVM IR check lines in utils/update_cc_test_checks.pyFangrui Song1-6/+9
Reviewers: arichardson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44400 llvm-svn: 327538
2018-03-02[utils] Add utils/update_cc_test_checks.pyFangrui Song1-2/+8
A utility to update LLVM IR in C/C++ FileCheck test files. Example RUN lines in .c/.cc test files: // RUN: %clang -S -Os -DXX %s -o - | FileCheck %s // RUN: %clangxx -S -Os %s -o - | FileCheck -check-prefix=IR %s Usage: % utils/update_cc_test_checks.py --llvm-bin=release/bin test/a.cc % utils/update_cc_test_checks.py --c-index-test=release/bin/c-index-test --clang=release/bin/clang /tmp/c/a.cc // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // RUN: %clang -emit-llvm -S -Os -DXX %s -o - | FileCheck -check-prefix=AA %s // RUN: %clangxx -emit-llvm -S -Os %s -o - | FileCheck -check-prefix=BB %s using T = #ifdef XX int __attribute__((vector_size(16))) #else short __attribute__((vector_size(16))) #endif ; // AA-LABEL: _Z3fooDv4_i: // AA: entry: // AA-NEXT: %add = shl <4 x i32> %a, <i32 1, i32 1, i32 1, i32 1> // AA-NEXT: ret <4 x i32> %add // // BB-LABEL: _Z3fooDv8_s: // BB: entry: // BB-NEXT: %add = shl <8 x i16> %a, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1> // BB-NEXT: ret <8 x i16> %add T foo(T a) { return a + a; } Differential Revision: https://reviews.llvm.org/D42712 llvm-svn: 326591
2018-02-28update_mir_test_checks: Use the regexes from UpdateTestChecks.commonJustin Bogner1-5/+6
Some of the update_*_test_checks regexes have been moved into a library, so we might as well use them in update_mir_test_checks. Also includes minor bugfixes to the regexes that are there so we don't regress update_mir_test_checks llvm-svn: 326288
2018-02-10[utils] Refactor utils/update_{,llc_}test_checks.py to share more codeFangrui Song1-13/+150
Summary: 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) Reviewers: asb, craig.topper, RKSimon, echristo Subscribers: llvm-commits, spatel Differential Revision: https://reviews.llvm.org/D42805 llvm-svn: 324803
2018-02-02Make utils/UpdateTestChecks/common.py Python 2/3 compatible and fix print ↵Fangrui Song1-6/+9
statements. Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42674 llvm-svn: 324104
2018-01-30[utils] De-duplicate utils/update_{llc_,}test_checks.pyFangrui Song1-0/+65
Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42654 llvm-svn: 323718