aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks
AgeCommit message (Collapse)AuthorFilesLines
2025-06-14[utils] Add "aarch64-apple-macosx" triple to update_llc_test_checks.py (#144023)Tomer Shafir1-0/+1
Add a missing valid triple "aarch64-apple-macosx" for usability.
2025-05-22[GlobalISel] Add a update_givaluetracking_test_checks.py script (#140296)David Green1-0/+238
As with the other update scripts this takes the output of -passes=print<gisel-value-tracking> and inserts the results into an existing mir file. This means that the input is a lot like update_analysis_test_checks.py, and the output needs to insert into a mir file similarly to update_mir_test_checks.py. The code used to do the inserting has been moved to common, to allow it to be reused. Otherwise it tries to reuse the existing infrastructure, and update_givaluetracking_test_checks is kept relatively short.
2025-05-21[LAA] Tweak debug output for UTC stability (#140764)Ramkumar Ramachandra1-0/+1
UpdateTestChecks has a make_analyzer_generalizer to replace pointer addressess from the debug output of LAA with a pattern, which is an acceptable solution when there is one RUN line. However, when there are multiple RUN lines with a common pattern, UTC fails to recognize common output due to mismatched pointer addresses. Instead of hacking UTC scrub the output before comparing the outputs from the different RUN lines, fix the issue once and for all by making LAA not output unstable pointer addresses in the first place. The removal of the now-dead make_analyzer_generalizer is left as a non-trivial exercise for a follow-up.
2025-05-18[MC][AArch64][ARM][X86] Push target-dependent assembler flags into targets ↵Jessica Clarke1-5/+11
(#139844) The .syntax unified directive and .codeX/.code X directives are, other than some simple common printing code, exclusively implemented in the targets themselves. Thus, remove the corresponding MCAF_* flags and reimplement the directives solely within the targets. This avoids exposing all targets to all other targets' flags. Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its own function like other directives, simplifying its implementation. Note that, on X86, we now always need a target streamer when parsing assembly, as it's now used for directives that aren't COFF-specific. It still does not however need to do anything when producing a non-COFF object file, so this commit does not introduce any new target streamers. There is some churn in test output, and corresponding UTC regex changes, due to comments no longer being flushed by these various directives (and EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so even if we wanted to), but that was a bit odd to be doing anyway. This is motivated by Morello LLVM, which adds yet another assembler flag to distinguish A64 and C64 instruction sets, but did not update every switch and so emits warnings during the build. Rather than fix those warnings it seems better to instead make the problem not exist in the first place via this change.
2025-05-09update_test_checks: indent dbg records (#139230)Orlando Cazalet-Hyams1-0/+2
LLVM prints debug records like `#dbg_value` indented 2 additional spaces.
2025-04-24update_test_checks: Relax DIFile filename checks (#135692)Scott Linder1-1/+1
Avoid baking in absolute paths in check lines generated for DIFile metadata. Generated test checks cannot be sensitive to absolute paths anyway, as those vary with the environment, but there could be situations where some sensitivity to partial paths is required for certain tests. This implementation just assumes such tests aren't worth the effort to support, but it could be supported in the future. This is most useful for update_cc_test_checks with debug info enabled, where the test writer cannot manipulate the paths within the generated IR directly.
2025-03-18update_test_checks: add new --filter-out-after option (#129739)David Sherwood1-12/+59
Whilst trying to clean up some loop vectoriser IR tests (see test/Transforms/LoopVectorize/AArch64/partial-reduce-chained.ll for example) a reviewer on PR #129047 suggested it would be nice to have an option to stop generating CHECK lines after a certain point. Typically when performing a transformation with the loop vectoriser we don't usually care about any CHECK lines generated for the scalar tail of the loop, since the scalar loop is kept intact. Previously if you wanted to eliminate such unwanted CHECK lines you had to run the update script, then manually delete all the lines corresponding to the scalar loop. This can be very time consuming if the tests ever need changing. What I've tried to do here is add a new --filter-out-after option alongside the existing --filter* options that provides support for stopping the generation of any CHECK lines beyond the line that matches the filter. With the existing filter options we never generate CHECK-NEXT lines, but we still care about ordering with --filter-out-after so I've amended the code to ensure we treat this filter differently.
2025-02-19UpdateTestChecks: Don't check meta details in func definition w/--global ↵Jinsong Ji1-2/+15
none (#124205) When --check-globals none, we skipped all the globals in check lines. However, we are still checking the meta info in function defintion. The generated checks are still sensitive to metadata changes. This is to scrub the meta info and match them with {{.*}} instead.
2025-01-29[DA] enable update_analyze_test_checks.py (#123435)Sebastian Pop1-0/+1
Modify the DA pretty printer to match the output of other analysis passes. This enables update_analyze_test_checks.py to also work on DA tests. Auto generate all the Dependence Analysis tests.
2025-01-13Handle leading underscores in update_cc_test_checks.py (#121800)Momchil Velikov1-0/+16
For some ABIs `update_cc_test_checks.py` is unable to generate tests because of the mismatch between the mangled function names reported by clang's `-asd-dump` and the function names in LLVM IR. This patch fixes it by striping the leading underscore from the mangled name for global functions if the data layout string says they have one.
2025-01-08[UpdateTestChecks][NFC] - Fix typos (#121964)Jessica Del1-1/+1
substition -> substitution in-betweem -> in-between
2024-11-23[UTC] Add support for Xtensa (#117441)Sergei Barannikov1-0/+17
Regenerate the failing test as well.
2024-10-30[AMDGPU][test] fix the error case in update_mc_test_check script (#112731)Brox Chen1-0/+1
update_mc_test_check script handle the "error case testline" wrong in three cases: 1. when user select "--llvm-mc-binary" with a path, the script does not add "not" on top of the "--llvm-mc-binary" and thus getting non-zero exit code and failed. 2. When "not" is presented in runline while not all testlines are expected to fail, the script need to check if the "not" is needed when it execute llvm-mc line by line. Otherwise the script will fail on testline which is passing. 3. When there are multiple runlines, the error checkline need to use correct line offset for "[[LINE-X]]" This patch solve these three issues
2024-10-29[AMDGPU][test]added unique and sort options for update_mc_test_check script ↵Brox Chen1-1/+3
(#111769) add a unique and a sort option to the update_mc_test_check script. These mc asm/dasm files are usually large in number of lines, and these lines are mostly similar to each other. These options can be useful when maintainer is merging or resolving conflicts by making the file identifical Also fixed a small issue in asm/dasm such that the auto generated header line is 1. asm using ";" instead of "//" as comment marker 2. dasm using ";" instead of "#" as comment marker
2024-10-07update_test_checks: fix a simple regression (#111347)Nicolai Hähnle1-1/+1
Reported-by: Yingwei Zheng <dtcxzyw2333@gmail.com> Fixes: 02debcef12793b5 ("update_test_checks: improve IR value name stability (#110940)")
2024-10-04update_test_checks: collect original check lines for old versions of lit ↵Nicolai Hähnle1-1/+4
tests (#111148) Old versions of UTC produced function labels like: ; CHECK-LABEL: @func( Fix the regular expression used when scanning for old check lines to recognize this form of label. This allows meta variable stability to apply when running UTC on tests using this form of label. Reported-by: Nikita Popov <npopov@redhat.com>
2024-10-04update_test_checks: improve IR value name stability (#110940)Nicolai Hähnle1-27/+103
By default, UTC attempts to keep the produced diff small by keeping IR value name variables stable. The old algorithm was roughly: 1. Compute a diff between the old and new check lines, where "uncommitted" variable names are replaced by a wildcard. This leads to a set of non-crossing "candidate" pairs of (old line, new line) that we can try to make equal. 2. Greedily walk this list of candidates, committing to variable names that make candidate lines equal if possible. The greedy approach in the second step has the downside that committing to a variable name greedily can sometimes prevent many subsequent candidates from getting the variable name assignment that would make them equal. We keep the first step as-is, but replace the second one by an algorithm that finds a large independent set of candidates, i.e. candidate pairs of (old line, new line) which are non-conflicting in the sense that their desired variable name mappings are not in conflict. We find the large independent set by greedily assigning a coloring to the conflict graph and taking the largest color class. We then commit to all the variable name mappings which are desired by candidates in this largest color class. As before, we then recurse into regions between matching lines. This is required in large cases. For example, running this algorithm at the top-level of the new test case (stable_ir_values5.ll) matches up most of the instructions, but not the names of the result values of all the `load`s. This is because (unlike e.g. the getelementptrs) the load instructions are all equal except for variable names, and so step 1 (the diff algorithm) doesn't consider them as candidates. However, they are trivially matched by recursion. This also happens to fix a bug in tracking line indices that went unnoticed previously... As is usually the case with these changes, the quality improvement is hard to see from the diff of this patch. However, it becomes obvious when comparing the diff of stable_ir_values5.ll against stable_ir_value5.ll.expected before and after this change.
2024-09-23added a script to update llvm-mc test file (#107246)Brox Chen1-1/+1
Added a script to update the test file generated by llvm-mc binary. The script accepts .s and .txt for asm and dasm. For mc test I am targetting there is no function name which can be used as a key, thus no clear mapping between input and output. The script assumes the test are always line-by-line and it update the output marker for each test line-by-line. --------- Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
2024-08-30[NFC] Prefer subprocess.DEVNULL over os.devnull (#106500)Nicolas van Kempen1-9/+7
There is no need to support Python 2.7 anymore, Python 3.3+ has `subprocess.DEVNULL`. This is good practice and also prevents file handles from staying open unnecessarily. Also remove a couple unused or unneeded `__future__` imports.
2024-08-28[NVPTX] Support __usAtomicCAS builtin (#99646)Denis.G1-0/+1
Supported `__usAtomicCAS` builtin originally defined in `/usr/local/cuda/inlcude/crt/sm_70_rt.hpp` --------- Co-authored-by: Denis Gerasimov <Denis.Gerasimov@baikalelectronics.ru> Co-authored-by: Gonzalo Brito Gadeschi <gonzalob@nvidia.com> Co-authored-by: Denis.Gerasimov <dengzmm@gmail.com>
2024-08-09[update_llc_test_checks][AMDGPU] Update AMDGPU regexp in ↵Juan Manuel Martinez Caamaño1-0/+1
update_llc_test_checks.py (#102480) Updating `llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll` with `update_llc_test_checks.py` ended with several kernels with no checks. Llc's output contained the line ".amdgpu_hsa_kernel <funcname>" after the ".type <funcname>,@function" entry which was not considered by the regexp.
2024-07-03UTC: support debug output from LDist (#93208)Ramkumar Ramachandra1-2/+4
Tweak the LoopDistribute debug output to be prefixed with "LDist: ", get it to be stable, and extend update_analyze_test_checks.py trivially to support this output.
2024-06-04update_test_checks: drop the other arm64_32 handlersJon Roelofs1-5/+0
2024-06-03update_test_checks: support more arm64_32-apple-watchos triplesJon Roelofs1-1/+2
Having the version in `get_run_handlers` meant that a RUN line without the version in it would not match, and therefore UTC would generate a useless catch-all check of the form: ``` ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: ; CHECK: {{.*}} ``` This patch also adds `arm64_32` as a base-level run handler, and assumes it will always apply to a darwin target (which is currently the case for all arm64_32-* triples I see in tree currently).
2024-05-27update_llc_test_checks: better support for non-llc tools (#93135)Nicolai Hähnle1-1/+2
A full downstream fork can already hack up update_llc_test_checks.py to support custom tools that output assembly. An out-of-tree frontend which is meant to build against upstream llvm-project cannot do this, and so providing additional arguments to support a non-standard tool is useful. This also makes a minor adjustment to the regular expression for matching AMDGPU functions when fewer comments are enabled, which happens to be the case for our out-of-tree shader compiler (which motivated this change).
2024-05-23Fix update-test-checks.py on Python 3.6 (#93116)Eli Friedman1-1/+1
re.Match apparently doesn't exist in older versions.
2024-05-19update_test_checks: match IR basic block labels (#88979)Nicolai Hähnle3-462/+473
Labels are matched using a regexp of the form '^(pattern):', which requires the addition of a "suffix" concept to NamelessValue. Aside from that, the key challenge is that block labels are values, and we typically capture values including the prefix '%'. However, when labels appear at the start of a basic block, the prefix '%' is not included, so we must capture block label values *without* the prefix '%'. We don't know ahead of time whether an IR value is a label or not. In most cases, they are prefixed by the word "label" (their type), but this isn't the case in phi nodes. We solve this issue by leveraging the two-phase nature of variable generalization: the first pass finds all occurences of a variable and determines whether the '%' prefix can be included or not. The second pass does the actual substitution. This change also unifies the generalization path for assembly with that for IR and analysis, in the hope that any future changes avoid diverging those cases future. I also considered the alternative of trying to detect the phi node case using more regular expression special cases but ultimately decided against that because it seemed more fragile, and perhaps the approach of keeping a tentative prefix that may later be discarded could also be eventually applied to some metadata and attribute cases. Note that an early version of this change was reviewed as https://reviews.llvm.org/D142452, before version numbers were introduced. This is a substantially updated version of that change.
2024-04-17[RemoveDIs] Update update_test_checks script to recognize dbg_records (#87388)Stephen Tozer1-1/+1
As we've added new IR elements for the RemoveDIs project, we need the update_test_checks script to understand them. For the records themselves this is already done automatically, but their metadata arguments are not recognized as such due to lacking the `metadata` prefix, which means they won't be checked by the script. This patch fixes this by adding a check for all `![0-9]+` patterns as long as they are not at the start of a line (which avoids matching global values).
2024-04-17update_test_checks: keep names stable with generated functions (#87988)Nicolai Hähnle1-24/+35
Collect the original check lines in a manner that is independent of where the check lines appear in the file. This is so that we keep FileCheck variable names stable even when --include-generated-funcs is used. Reported-by: Ruiling Song <ruiling.song@amd.com>
2024-04-16update_test_checks: remove an unused functionNicolai Hähnle1-4/+0
2024-03-08update_test_checks: keep meta variables stable by defaultNicolai Hähnle1-18/+496
Resubmitting this after previous revert with the following changes: - Split table into table_rhs_idx and table_candidate_idx so that bisect.bisect_left can be used without the `key` argument, which was introduced in Python 3.10 - Remove a re.Pattern type annotation Original commit message: Prior to this change, running UTC on larger tests, especially tests with unnamed IR values, often resulted in a spuriously large diff because e.g. TMPnn variables in the CHECK lines were renumbered. This change attempts to reduce the diff by keeping those variable names the same. There are cases in which this "drift" of variable names can end up being more confusing. The old behavior can be re-enabled with the --reset-variable-names command line argument. The improvement may not be immediately apparent in the diff of this change. The point is that the diff of stable_ir_values.ll against stable_ir_values.ll.expected after this change is smaller. Ideally, we'd also keep meta variables for "global" objects stable, e.g. for attributes (#nn) and metadata (!nn). However, that would require a much more substantial refactoring of how we generate check lines, so I left it for future work.
2024-03-08Revert "update_test_checks: keep meta variables stable by default"Nicolai Hähnle1-494/+19
This reverts commit fb02f9ac84a6151e41aba8f7391edd132a9aaf14. Looks like some Python version incompatibility, will investigate.
2024-03-08update_test_checks: keep meta variables stable by defaultNicolai Hähnle1-19/+494
Prior to this change, running UTC on larger tests, especially tests with unnamed IR values, often resulted in a spuriously large diff because e.g. TMPnn variables in the CHECK lines were renumbered. This change attempts to reduce the diff by keeping those variable names the same. There are cases in which this "drift" of variable names can end up being more confusing. The old behavior can be re-enabled with the --reset-variable-names command line argument. The improvement may not be immediately apparent in the diff of this change. The point is that the diff of stable_ir_values.ll against stable_ir_values.ll.expected after this change is smaller. Ideally, we'd also keep meta variables for "global" objects stable, e.g. for attributes (#nn) and metadata (!nn). However, that would require a much more substantial refactoring of how we generate check lines, so I left it for future work.
2024-03-08update_test_checks: simplify get_ir_regexNicolai Hähnle1-2/+2
The match argument isn't used.
2024-03-08update_test_checks: simplify is_local_def_ir_valueNicolai Hähnle1-5/+5
The match argument is unused.
2024-02-28[UTC] Don't leave dangling CHECK-SAME when removing CHECK lines (#82569)Henrik G. Olsson1-2/+13
When removing only lines that are global value CHECK lines, a related CHECK-SAME line could be left dangling without a previous line to belong to. Resolves #78517
2024-02-20[UTC] Fix SyntaxWarning on Python 3.12 (#82327)Luke Lau1-1/+1
On Python 3.12 we now get a warning in common.py: llvm/utils/UpdateTestChecks/common.py:488: SyntaxWarning: invalid escape sequence '\s' This fixes it by using a raw string literal, see https://github.com/llvm/llvm-project/pull/78036 and https://docs.python.org/3/library/re.html
2024-02-08Fix test failure if CLANG_VENDOR contains spaces (#81017)Yi Kong1-1/+1
2023-12-05Include LLVM_VERSION_SUFFIX in the Clang version string. (#74469)James Y Knight1-1/+1
This causes current mainline to now report "18.0.0git" instead of "18.0.0". Fixes #53825
2023-11-28[UTC] Support arm64-apple-macosx in update_llc_test_checks.py. (#73568)Florian Hahn1-0/+1
arm64-apple-macosx is the default triple (usually with the macOS version number) on arm64 macOS. Support it in update_llc_test_checks.py.
2023-11-21Support BranchProbabilityInfo in update_analyze_test_checks.py (#72943)Matthias Braun1-6/+9
- Change `BranchProbabilityPrinterPass` output to match expectations of `update_analyze_test_checks.py`. - Add `Branch Probability Analysis` to list of supported analyses. - Process `llvm/test/Analysis/BranchProbabilityInfo/basic.ll` with `update_analyze_test_checks.py` as proof of concept. Leaving the other tests unchanged to reduce the amount of churn.
2023-11-13Recommit changes to global checks (#71171)Henrik G. Olsson1-21/+197
Recommits the changes from https://reviews.llvm.org/D148216. Explicitly named globals are now matched literally, instead of emitting a capture group for the name. This resolves #70047. Metadata and annotations, on the other hand, are captured and matched against by default, since their identifiers are not stable. The reasons for revert (#63746) have been fixed: The first issue, that of duplicated checkers, has already been resolved in #70050. This PR resolves the second issue listed in #63746, regarding the order of named and unnamed globals. This is fixed by recording the index of substrings containing global values, and sorting the checks according to that index before emitting them. This results in global value checks being emitted in the order they were seen instead of being grouped separately.
2023-11-09[UTC] Escape multiple {{ or }} in input for check lines. (#71790)Florian Hahn1-0/+7
SCEV expressions may contain multiple {{ or }} in the debug output, which needs escaping. See llvm/test/Analysis/LoopAccessAnalysis/loops-with-indirect-reads-and-writes.ll for a test that needs escaping.
2023-10-31update_analyze_test_checks: support output from LAA (#67584)Ramkumar Ramachandra1-48/+127
update_analyze_test_checks.py is an invaluable tool in updating tests. Unfortunately, it only supports output from the CostModel, ScalarEvolution, and LoopVectorize analyses. Many LoopAccessAnalysis tests use hand-crafted CHECK lines, and it is moreover tedious to generate these CHECK lines, as the output fom the analysis is not stable, and requires the test-writer to hand-craft FileCheck matches. Alleviate this pain, and support output from: $ opt -passes='print<loop-accesses>' This patch includes several non-trivial changes including: - Preserving whitespace at the beginning of the line, so that the LAA output can be properly indented. - Regexes matching the unstable output, which is basically a pointer address hex. - Separating is_analyze from preserve_names clearly, as the former was formerly used as an overload for the latter. To demonstate the utility of this patch, several tests in LoopAccessAnalysis have been auto-generated by update_analyze_test_checks.py.
2023-10-30[UTC] Recognise CHECK lines with globals matched literally (#70050)Henrik G. Olsson1-1/+1
Previously when using `-p` a.k.a. `--preserve-names` existing lines for checking globals were not recognised as such, leading to the line being kept while also being emitted again, resulting in duplicated CHECK lines. This resolves #70048.
2023-09-26UpdateTestChecks: squelch warning on SCEV output (#67443)Ramkumar Ramachandra1-1/+5
update_analyze_test_checks.py currently outputs a warning when updating a script with the run line: $ opt -passes='print<scalar-evolution>' saying that the script doesn't support its output, when it indeed does, as evidenced by several tests in test/Analysis/ScalarEvolution generated by this script. There is even a test for update_analyze_test_checks that makes sure that SCEV output is supported. Hence, squelch the warning. While at it, rename the update_analyze_test_checks test from basic.ll to a more explicit scev.ll.
2023-09-21[UpdateTestChecks] Add support for SPIRV in update_llc_test_checks.py (#66213)Paulo Matos1-0/+26
Support for SPIRV added, updated test SPV_INTEL_optnone.ll using the script. Previously https://reviews.llvm.org/D157858
2023-08-29[UTC] Keep function args parenthesis on label line (bumps version to 3)Jannik Silvanus1-2/+18
If the function argument block contains patterns, we split argument matching into a separate SAME line, because LABEL labels may not contain pattern matches. Until now, in this case we moved the parenthesis opening the argument block into the second line. This generates incorrect labels in case function names are not prefix-free. For example, for a function `foo` we generated: CHECK-LABEL: foo CHECK-SAME: (<args of foo>) If the output also contains a function `foo.specialzied`, then the label for `foo` can match `foo.specialized`, depending on output order. This patch moves opening parenthesis to the first line, breaking common prefixes: CHECK-LABEL: foo( CHECK-SAME: <args of foo>) Bump the UTC version to 3, and only move the parenthesis for version 3 and later. Differential Revision: https://reviews.llvm.org/D158497
2023-08-23[UTC] Honor global-value-regex in UTC_ARGSJohannes Doerfert1-0/+6
Without this we cannot update various clang OpenMP tests as the UTC_ARGS version of -global-value-regex is simply ignored. The handling of the flag should be changed to be in line with others, I left TODOs for now.
2023-07-14Revert "[UTC] Add fallback support for specific metadata, and check their defs"Johannes Doerfert1-151/+15
This reverts commit 8a3fdf7b908978625e9a7e57fbb443e4e6f98976 as it is broken. See https://github.com/llvm/llvm-project/issues/63746. Effectively fixes: https://github.com/llvm/llvm-project/issues/63746