summaryrefslogtreecommitdiffstats
path: root/llvm/utils/update_cc_test_checks.py
Commit message (Collapse)AuthorAgeFilesLines
* Make mangled_names.test and update_cc_test_checks.py work with Python 2.Nico Weber2020-01-021-7/+12
| | | | Differential Revision: https://reviews.llvm.org/D71565
* [update_cc_test_checks.py] Use CHECK_RE from commonAlex Richardson2019-12-021-3/+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
* [update_cc_test_checks.py] Handle extern "C" and namespacesAlex Richardson2019-12-021-9/+18
| | | | | | | | | | | | | | | | | | Summary: My change to use the clang AST JSON dump did not handle functions declared inside scopes other than the root TranslationUnitDecl. After this change update_cc_test_checks.py also works for C++ test cases that use extern "C" and namespaces. Reviewers: MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70389
* [UpdateTestChecks] Share the code to parse RUN: lines between all scriptsAlex Richardson2019-12-021-27/+9
| | | | | | | | | | | | | | | | 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
* [update_cc_test_checks.py] Add the --function-signature flagAlex Richardson2019-11-201-2/+5
| | | | | | | | | | | | | | | | Summary: This was added to update_test_checks.py in D68819 and I believe having it in update_cc_test_checks.py is also useful. Reviewers: jdoerfert, MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70429
* [UptestTestChecks][NFC] Share some common command line options codeAlex Richardson2019-11-201-4/+1
| | | | | | | | | | | | | | | | | | | 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
* [update_cc_test_checks.py] Use -ast-dump=json to get mangled nameAlex Richardson2019-11-151-51/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Using c-index-test is fragile since it does not parse all the clang arguments that are used in the RUN: line. This can result in incorrect mangled names that do not match any of the generated IR. For example macOS triples include a leading underscore (which was handled with a hack in the current script). For the CHERI target we have added new qualifiers which affect C++ name mangling, but will be included added by update_cc_test_checks since it parses the source file with the host triple because it ignores the -triple= argument passed to clang -cc1. Using the new feature of including the mangled name in the JSON AST dump (see D69564), we can parse the output of the RUN: command with "-fsyntax-only -ast-dump=json" appended. This should make the script less fragile and also forks one process less. Reviewers: MaskRay, xbolva00 Reviewed By: MaskRay Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69565
* [Utils] Hide the default behavior change of D68819 under a flagJohannes Doerfert2019-11-011-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.
* [update_cc_test_checks.py] Pass the builtin include dir to clangAlex Richardson2019-10-311-0/+12
| | | | | | | | | | | | | | | | | | | Summary: This is required to update tests that make use of builtin headers. To fix this use the same command expansion as lit does for %clang_cc1. I tested this by updating clang/test/CodeGen/arm-mve-intrinsics/scalar-shifts.c. %clang_cc1 will now expand to `clang -cc1 -internal-isystem $LLVM_BUILD/lib/clang/$VERSION/include -nostdsysteminc`. Reviewers: MaskRay Reviewed By: MaskRay Subscribers: kristof.beyls, dmgreen, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69611
* [Utils][FIX] Unbreak update_XXX_test_checks after 3598b810029dJohannes Doerfert2019-10-311-1/+1
| | | | | The users of build_function_body_dictionary and add_checks need to be adjusted after the changes in UpdateTestChecks/common.py.
* [update_cc_test_checks.py] Fix invalid python string escape sequenceAlex Richardson2019-10-301-1/+1
| | | | This works with current python version but will be an error with 3.9
* [update_cc_test_checks] Support 'clang | opt | FileCheck'Simon Tatham2019-10-101-6/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some clang lit tests use a pipeline of the form // RUN: %clang [args] -O0 %s | opt [specific optimizations] | FileCheck %s to make the expected test output depend on as few optimization phases as possible, for stability. But when you write a RUN line of this form, you lose the ability to use update_cc_test_checks.py to automatically generate the expected output, because it only supports two-stage pipelines consisting of '%clang | FileCheck' (or %clang_cc1). This change extends the set of supported RUN lines so that pipelines with an invocation of `opt` in the middle can still be automatically handled. To implement it, I've adjusted `get_function_body()` so that it can cope with an arbitrary sequence of intermediate pipeline commands. But the code that decides which RUN lines to consider is more conservative: it only adds clang | opt | FileCheck to the set of supported lines, because I didn't want to accidentally include some other kind of line that doesn't output IR at all. (Also in this commit is the minimal change to make this script work at all, after r373912 added an extra parameter to `add_ir_checks`.) Reviewers: MaskRay, xbolva00 Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68406 llvm-svn: 374287
* [UpdateCCTestChecks] Detect function mangled name on separate lineDavid Greene2019-10-081-6/+20
| | | | | | | | | | | | Sometimes functions with large comment blocks in front of them have their declarations output on several lines by c-index-test. Hence the one-line function name/line/mangled pattern will not work to detect them. Break the pattern up into two patterns and keep state after seeing the name/line information until we finally see the mangled name. Differential Revision: https://reviews.llvm.org/D68272 llvm-svn: 374078
* [UpdateTestChecks] Update tests optionDavid Bolvansky2019-08-071-1/+14
| | | | | | | | | | | | | | | | | | | | | 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
* [UpdateTestChecks] Emit warning when invalid value for -check-prefix(es) optionDavid Bolvansky2019-07-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix LLVM IR check lines in utils/update_cc_test_checks.pyFangrui Song2018-03-141-2/+1
| | | | | | | | | | Reviewers: arichardson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44400 llvm-svn: 327538
* [utils] Add utils/update_cc_test_checks.pyFangrui Song2018-03-021-0/+242
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
OpenPOWER on IntegriCloud