aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
AgeCommit message (Collapse)AuthorFilesLines
2021-05-05[Utils][NFC] Rename replace-function-regex in update_cc_test_checksGiorgis Georgakoudis1-4/+4
This patch renames the replace-function-regex to replace-value-regex to indicate that the existing regex replacement functionality can replace any IR value besides functions. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101934
2021-05-03[Utils] Add prof metadata to matched unnamed valuesGiorgis Georgakoudis1-0/+1
Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D101742
2021-04-28[update_(llc_)test_checks.py] Support pre-processing commandsAlex Richardson1-1/+14
This has been rather useful in our downstream CHERI target where we want to run tests both with addrspace(0) and addrspace(200) pointers. With this patch we can prefix the opt command with `sed -e 's/addrspace(200)/addrspace(0)/g' -e 's/-A200-P200-G200//g'` to test both cases using the same IR input. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D95137
2021-03-26[Utils] Add prefix parameter in update test checks to avoid FileCheck conflictsGiorgis Georgakoudis1-2/+19
IR values convert to check prefix FileCheck variables for IR checks. For example, nameless values, e.g., %0, convert to check prefix TMP FileCheck variables, e.g., [[TMP0:%.*]]. This check prefix may clash with named values that have the same name and that causes auto-generated tests to fail. Currently a warning is emitted to change the names of the IR values but this is not always possible, if for example they are generated by clang. Manual intervention to fix the FileCheck variable names is too tedious. This patch add a parameter to prefix conflicting FileCheck variable names with a user-provided string to automate the process. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D99415
2021-03-24[Utils][NFC] Fix regex substitution for update test checksGiorgis Georgakoudis1-3/+3
Relates to: https://reviews.llvm.org/D97107
2021-03-24[UpdateTestChecks] Fix typo & copy/paste in commentsThomas Preud'homme1-2/+2
2021-03-12Replace func name with regex for update test scriptsGiorgis Georgakoudis1-0/+30
The patch adds an argument to update test scripts, such as update_cc_test_checks, for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107
2021-03-12Revert "Replace func name with regex for update test scripts"Giorgis Georgakoudis1-30/+0
This reverts commit 5eaf70afb5f8ae6789587e60d51c60f56caf18b0.
2021-03-12Replace func name with regex for update test scriptsGiorgis Georgakoudis1-0/+30
The patch adds an argument to update test scripts, such as update_cc_test_checks, for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107
2021-03-11[Utils] Check for more global information in update_test_checksJohannes Doerfert1-39/+203
This allows to check for various globals (metadata/attributes/...) and also resolves problems with globals (metadata/attributes/...) being reused across different prefixes. Reviewed By: sstefan1 Differential Revision: https://reviews.llvm.org/D94741
2021-03-10Revert "Replace func name with regex in update_cc_test_checks"Giorgis Georgakoudis1-30/+0
This reverts commit bf58d6a1f92244c797a280d318a56d7d3fc4a704. Breaks tests, fix
2021-03-10Replace func name with regex in update_cc_test_checksGiorgis Georgakoudis1-0/+30
The patch adds an argument to update_cc_test_checks for replacing a function name matching a regex. This functionality is needed to match generated function signatures that include file hashes. Example: The function signature for the following function: `__omp_offloading_50_b84c41e__Z9ftemplateIiET_i_l30_worker` with `--replace-function-regex "__omp_offloading_[0-9]+_[a-z0-9]+_(.*)"` will become: `CHECK-LABEL: @{{__omp_offloading_[0-9]+_[a-z0-9]+__Z9ftemplateIiET_i_l30_worker}}(` Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D97107
2021-02-15[NFC] Remove spurious ';' on return line in python codeMircea Trofin1-1/+1
2021-02-08Revert "[Utils] Add a switch controlling prefix warnings in UpdateTestChecks"Mircea Trofin1-12/+3
This reverts commit 87f8a08ce36e5bc72f11129d2cf36b5848f86f63.
2021-02-01[Utils] Add a switch controlling prefix warnings in UpdateTestChecksMircea Trofin1-3/+12
The switch controls both unused prefix warnings, and warnings about functions which differ under different runs for a prefix, and, thus, end up not having asserts for that prefix. (If the latter case spans to all functions, then the former case kicks in) The switch is on by default, and can be disabled. Differential Revision: https://reviews.llvm.org/D95829
2020-12-17[NFC][utils] Factor remaining APIs under FunctionTestBuilderMircea Trofin1-70/+68
Finishing the refactoring started in D93413. Differential Revision: https://reviews.llvm.org/D93506
2020-12-16[NFC] factor update test function test builder as a classMircea Trofin1-1/+26
This allows us to have shared logic over multiple test runs, e.g. do we have unused prefixes, or which function bodies have conflicting outputs for a prefix appearing in different RUN lines. This patch is just wrapping existing functionality, and replacing its uses. A subsequent patch would then fold the current functionality into the newly introduced class. Differential Revision: https://reviews.llvm.org/D93413
2020-12-15[utils] The func_dict for a prefix may just be emptyMircea Trofin1-2/+2
Follow up from D92965 - since we try to find failed prefixes after each RUN line, it's possible the whole list of functions for a prefix be non-existent, which is fine - this happens when none of the RUN lines seen so far used the prefix.
2020-12-15[utils] Fix UpdateTestChecks case where 2 runs differ for last labelMircea Trofin1-7/+29
Two RUN lines produce outputs that, each, have some common parts and some different parts. The common parts are checked under label A. The differing parts are associated to a function and checked under labels B and C, respectivelly. When build_function_body_dictionary is called for the first RUN line, it will attribute the function body to labels A and C. When the second RUN is passed to build_function_body_dictionary, it sees that the function body under A is different from what it has. If in this second RUN line, A were at the end of the prefixes list, A's body is still kept associated with the first run's function. When we output the function body (i.e. add_checks), we stop after emitting for the first prefix matching that function. So we end up with the wrong function body (first RUN's A-association). There is no reason to special-case the last label in the prefixes list, and the fix is to always clear a label association if we find a RUN line where the body is different. Differential Revision: https://reviews.llvm.org/D93078
2020-09-18clang: Make changes in 7c8bb409f31e py2.7-compatibleNico Weber1-1/+3
2020-09-18[UpdateCCTestChecks] Include generated functions if askedDavid Greene1-6/+78
Add the --include-generated-funcs option to update_cc_test_checks.py so that any functions created by the compiler that don't exist in the source will also be checked. We need to maintain the output order of generated function checks so that CHECK-LABEL works properly. To do so, maintain a list of functions output for each prefix in the order they are output. Use this list to output checks for generated functions in the proper order. Differential Revision: https://reviews.llvm.org/D83004
2020-09-16[UpdateTestChecks] Allow $ in function namesDavid Greene1-3/+3
Some compilers generation functions with '$' in their names, so recognize those functions. This also requires recognizing function names inside quotes in some contexts in order to escape certain characters. Differential Revision: https://reviews.llvm.org/D82995
2020-09-16[UpdateTestChecks][NFC] Fix spellingJohannes Doerfert1-3/+3
2020-08-29[UpdateTestChecks] Don't skip attributes when comparing functionssstefan11-1/+1
2020-08-28[UpdateTestChecks] include { in function signature check linesstefan11-1/+1
After D85099, if we have attribute group in the function signature that hasn't been seen before, and later a callsite with the same attribute group, filecheck will evaluate the first attribute group to for example '#0 {'. We now include { in the args_and_sig group to avoid this. Differential Revision: https://reviews.llvm.org/D86769
2020-08-25[UpdatesTestChecks] Fix typo in common.pySam Parker1-1/+1
global_vars_see_dict -> global_vars_seen_dict
2020-08-12[UpdateTestChecks][FIX] Python 2.7 compatibility and use right prefixJohannes Doerfert1-1/+1
2020-08-12[UpdateTestChecks] Match unnamed values like "@[0-9]+" and "![0-9]+"Johannes Doerfert1-37/+109
With this patch we will match most *uses* of "temporary" named things in the IR via regular expressions, not their name at creation time. The new "values" we match are: - "unnamed" globals: `@[0-9]+` - debug metadata: `!dbg ![0-9]+` - loop metadata: `!loop ![0-9]+` - tbaa metadata: `!tbaa ![0-9]+` - range metadata: `!range ![0-9]+` - generic metadata: `metadata ![0-9]+` - attributes groups: `#[0-9]` We still don't match the declarations but that can be done later. This patch can introduce churn when existing check lines contain the old hardcoded versions of the above "values". We can add a flag to opt-out, or opt-in, if necessary. Reviewed By: arichardson, MaskRay Differential Revision: https://reviews.llvm.org/D85099
2020-08-03Fix update_cc_test_checks.py --llvm-bin after D78478Alex Richardson1-6/+11
Not passing --clang would result in a python exception after this change: (TypeError: expected str, bytes or os.PathLike object, not NoneType) because the --clang argument default was only being populated in the initial argument parsing pass but not later on. Fix this by adding an argparse callback to set the default values. Reviewed By: vitalybuka, MaskRay Differential Revision: https://reviews.llvm.org/D84511
2020-07-19[Utils][Fix] remove unnecessary ; at the endsstefan11-1/+1
2020-07-19[Utils] Check function attributes in update_test_checkssstefan11-15/+24
Summary: This introduces new flag to the update_test_checks and update_cc_test_checks that allows for function attributes to be checked in a check-line. If the flag is not set, the behavior should remain the same. Reviewers: jdoerfert Subscribers: arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D83629
2020-07-08[UpdateTestChecks] Move more update_test_checks.py logic to common.pyAlex Richardson1-3/+78
I intend to reuse this to add UTC_ARGS support for update_llc_test_checks.py and update_cc_test_checks.py in D78478. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D78618
2020-06-19[UpdateTestChecks] As part of using inclusive language within theEric Christopher1-6/+6
llvm project, migrate away from the use of blacklist and whitelist.
2020-06-01[utils] change default nameless value to "TMP"Sanjay Patel1-1/+1
This is effectively reverting rGbfdc2552664d to avoid test churn while we figure out a better way forward. We at least salvage the warning on name conflict from that patch though. If we change the default string again, we may want to mass update tests at the same time. Alternatively, we could live with the poor naming if we change -instnamer. This also adds a test to LLVM as suggested in the post-commit review. There's a clang test that is also affected. That seems like a layering violation, but I have not looked at fixing that yet. Differential Revision: https://reviews.llvm.org/D80584
2020-05-31[utils] change update_test_checks.py use of 'TMP' value namesSanjay Patel1-1/+5
As discussed in PR45951: https://bugs.llvm.org/show_bug.cgi?id=45951 There's a potential name collision between update_test_checks.py and -instnamer and/or manually-generated IR test files because all of them try to use the variable name that should never be used: "tmp". This patch proposes to reduce the odds of collision and adds a warning if we detect the problem. This will cause regression test churn when regenerating CHECK lines on existing files. Differential Revision: https://reviews.llvm.org/D80584
2020-04-23[UpdateTestChecks] Make generation of UTC_ARGS: comment more robustAlex Richardson1-12/+23
We now use the argparse Action objects to determine the name of the flags. This fixes cases where the key for the stored result ('dest') is not the same as the command line flag (e.g. --enable/--disable). Also add a test that --disabled can be part of the initial UTC_ARGS. This is split out from D78478 Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D78617
2020-04-10[PowerPC][UpdateTestChecks] Remove the extra # when scrubbing loop commentsKang Zhang1-0/+1
Summary: The patch D63957 is to avoid empty string when scrubbing loop comments, it will replace loop comments to a `#`, that's correct. But if the line has something else not only loop comments, we will get a extra `#`. The patch is to remove the extra `#`. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D77357
2020-04-01[Utils][FIX] Properly deal with occasionally deleted functionsJohannes Doerfert1-9/+4
While D68850 allowed functions to be deleted I accidentally saved some version of the function to be used once a suitable prefix was found. This turned out to be problematic when the occasionally deleted function is also occasionally modified. The test case is adjusted to resemble the case in which the problem was found. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D76586
2020-03-24[UpdateTestChecks] Use common ir function name matcher and extend to accept ↵Simon Pilgrim1-5/+5
periods in names (PR37586) Remove the local versions of the IR_FUNCTION_RE matcher (they weren't doing anything different), and ensure all the function name matchers accept '.' and '-'. We don't need to use '\.' inside python regex sets either, or '\-' as long as thats at the end of the set.
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.