Commit Graph

153 Commits

Author SHA1 Message Date
Mircea Trofin 6ddc4cd1c2 Fix break introduced by D124306
argparse.BooleanOptionalAction is not supported until python 3.9.
2022-05-26 11:55:19 -07:00
Mircea Trofin f15c60218d [UpdateTestChecks] Auto-generate stub bodies for unused prefixes
This is scoped to autogenerated tests.

The goal is to support having each RUN line specify a list of
check-prefixes where one can specify potentially redundant prefixes. For example,
for X86, if one specified prefixes for  both AVX1 and AVX2, and the codegen happened to
match today, one of the prefixes would be used and the onther one not.
If the unused prefix were dropped, and later, codegen differences were
introduced, one would have to go figure out where to add what prefix
(paraphrasing
https://lists.llvm.org/pipermail/llvm-dev/2021-February/148326.html)

To avoid getting errors due to unused prefixes, whole directories can be
opted out (as discussed on that thread), but that means that tests that
aren't autogenerated in such directories could have undetected unused
prefix bugs.

This patch proposes an alternative that both avoids the above, dir-level
optout, and supports the main autogen scenario discussed first. The autogen
tool appends at the end of the test file the list of unused prefixes,
together with a note explaining that is the case. Each prefix is set up
to always pass.

This way, unexpected unused prefixes are easily discoverable, and
expected cases "just work".

Differential Revision: https://reviews.llvm.org/D124306
2022-05-26 10:23:10 -07:00
Alex Richardson 996873cdcb [UpdateTestChecks] Use a counter for unpredictable FileCheck variables
Variable captures such as `<MCInst #` can change based on unrelated changes
to the LLVM backends, to avoid the generated test cases being different
use an incrementing counter for variable names instead of using the
actual value from the output file.
This change may also be beneficial for some nameless IR variables
(especially when combined with filtering of output), but for now I've
restricted this change to the obvious candidates (--asm-show-inst output).

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D125405
2022-05-14 14:40:50 +00:00
Alex Richardson 37a68497f1 [update_llc_test_checks] Use FileCheck captures for MCInst/MCReg output
To avoid test churn when backends add/rename new instructions/registers,
it makes sense to use FileCheck captures for the exact MCInst/Reg number.
This is motivated by D125307, where I use --asm-show-inst to differentiate
the output for multiple instructions with the same mnemonic.

This does not quite fix the churn issue yet: While files with the generated
checks will be immune to the numbers changing, the update script test
still suffers from this problem since the number is encoded in the
FileCheck variable name. I plan to address this in a follow-up patch.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D125307
2022-05-14 14:15:37 +00:00
Alex Richardson 4b5ad57d67 [UpdateTestChecks] Change global functions to NamelessValue members. NFCI
This avoids repeated calls to get_idx_from_ir_value_match() and will make
it easier for a future patch that adds new assembly-level nameless values
in addition to the IR ones.

Differential Revision: https://reviews.llvm.org/D125390
2022-05-14 14:15:36 +00:00
Jan Korous 0376c0f271 Revert "[utils] Avoid hardcoding metadata ids in update_cc_test_checks"
This reverts commit ce583b14b2.
2022-05-10 14:04:19 -07:00
Jan Korous ce583b14b2 [utils] Avoid hardcoding metadata ids in update_cc_test_checks
Specifically for: !tbaa, !tbaa.struct, !annotation, !srcloc, !nosanitize.

The goal is to avoid test brittleness caused by hardcoded values.

Differential Revision: https://reviews.llvm.org/D123273
2022-05-10 10:17:45 -07:00
Daniil Kovalev b1bb76a731 [NFC][UpdateTestChecks] Fix whitespace in common.py and asm.py
While working on D122986, noticed that indentation size varies even within
one file. Fixed that - now indentation is 2 spaces everywhere. This indentation

Differential Revision: https://reviews.llvm.org/D123859
2022-04-15 18:11:24 +03:00
Roman Lebedev 8fbed6870b
[UpdateTestChecks] Prevent rapid onset insanity when forced to write LoopVectorize-driven costmodel tests
Subj, or on other words, we have a lot of tests that are driven by
the LoopVectorizer's debug output, but we don't have
any meaningful way to autogenerate checklines in them,
which means that an insurmountable amount of manual work
is required when modifying the appropriate cost models.

That is not sustainable, so this presents a solution.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D121133
2022-04-15 15:37:29 +03:00
Daniil Kovalev 8e43cbab33 [UpdateTestChecks] Add NVPTX support in update_llc_test_checks.py
This patch makes possible generating NVPTX assembly check lines with
update_llc_test_checks.py utility.

Differential Revision: https://reviews.llvm.org/D122986
2022-04-15 11:01:53 +03:00
Roman Lebedev 2b5a16420f
UpdateTestChecks: fix handling of UTC with spaces
We can't just split by space, that's not going to give us the same
argv we'd have gotten from the shell, it could be in a string,
we must actually parse that as argv.
2022-03-07 20:25:23 +03:00
Roman Lebedev df6c26fd34
update_analyze_test_checks.py: fix --filter handling
In particular, after filtering the check lines can't necessarily
use `-NEXT`, they may not be one directly after another.
2022-03-07 15:41:13 +03:00
Sebastian Neubauer 473efae3a1 [UpdateTestChecks] Don't skip first line with --filter
body_start was never used, resulting in the first filtered line to be
skipped.
Fixes the --filter option introduced in D117694.

Differential Revision: https://reviews.llvm.org/D119704
2022-03-03 17:27:14 +01:00
Yatao Wang 8565b6f9f2 [UpdateLLCTestChecks] Add support for isel debug output in update_llc_test_checks.py
Add a check on run lines to pick up isel options in llc commands and allow
generating check lines of isel final output other than assembly. If llc command
line contains -debug-only=isel, update_llc_test_checks.py will try to scrub isel
output, otherwise, the script will fall back on default behaviour, which is try to
scrub assembly output instead.

The motivation of this change is to allow usage of update_llc_test_checks.py to
autogenerate checks of instruction selection results. In this way, we can detect
errors at an earlier stage before the compilation goes all the way to assembly.
It is an example of having some transparency for the stages between IR and
assembly. These generated tests are almost like "unit tests" of isel stage.

This patch only implements the initial change to differentiate isel output from
assembly output for Lanai. Other targets will not be supported for isel check
generation at the moment. Although adding support for it will only require
implementing the function regex and scrubber for corresponding targets.

The Lanai implementation was chosen mainly for the simplicity of demonstrating
the difference between isel checks and asm checks.

This patch also do not include the implementation of function prefix, which is
required for the generated isel checks to pass. I will put up a follow up revision
for the function prefix change to complete isel support.

Reviewed By: Flakebi

Differential Revision: https://reviews.llvm.org/D119368
2022-03-01 10:55:53 +01:00
David Greene ecd46edd61 [UpdateTestChecks] Re-add --filter and --filter-out options
Re-add filtering options with fixes for failed tests.  We were not passing the
is_filtered argument in all check generator calls in update_cc_test_checks.py

Enhance the various update_*_test_checks.py tools to allow filtering the tool
output with regular expressions.  The --filter option will emit only tool output
lines matching the given regular expression while the --filter-out option will
emit only tools output lines not matching the given regular expression.  Filters
are applied in order of appearance on the command line (or in UTC_ARGS) and the
first matching filter terminates the search.

This allows test authors to create more focused tests by removing irrelevant
tool output and checking only the pieces of output necessary to test the desired
functionality.

Differential Revision: https://reviews.llvm.org/D117694
2022-01-31 13:11:40 -08:00
David Greene 7e32d2b21a Revert "[UpdateTestChecks] Add --filter and --filter-out options"
Broke some update-test-checks tests.  Reverting while developing a fix.

This reverts commit 030f71698d.
2022-01-28 17:06:51 -08:00
David Greene 030f71698d [UpdateTestChecks] Add --filter and --filter-out options
Enhance the various update_*_test_checks.py tools to allow filtering the tool
output with regular expressions.  The --filter option will emit only tool output
lines matching the given regular expression while the --filter-out option will
emit only tools output lines not matching the given regular expression.  Filters
are applied in order of appearance on the command line (or in UTC_ARGS) and the
first matching filter terminates the search.

This allows test authors to create more focused tests by removing irrelevant
tool output and checking only the pieces of output necessary to test the desired
functionality.

Differential Revision: https://reviews.llvm.org/D117694
2022-01-28 14:08:07 -08:00
Jay Foad de37912f00 [update_test_checks] Fix option name in warning message 2022-01-28 14:45:47 +00:00
Zi Xuan Wu 6025ee79ae [CSKY] Add python script of CSKY asm update test check 2022-01-05 15:59:03 +08:00
Simon Moll 2810c3403e [VE] Add VE support to update_llc_test_checks
Add VE assembly scrubbing and triple support to update_llc_test_checks.

Reviewed By: kaz7

Differential Revision: https://reviews.llvm.org/D116104
2021-12-23 14:12:44 +01:00
Philip Reames 180625fcb4 Add a breadcrumb comment to make debugging a user error when using ./utils/update_analyze_test_checks.py easier.
We won't talk about how long it took me to figure this out.  The difference in batch vs interactive on the "did you mean to print bitcode" message made this confusing.
2021-11-18 09:07:19 -08:00
Alex Richardson a28177035b [UpdateTestChecks][NFC] Drop a python2 workaround 2021-09-28 17:57:36 +01:00
Alex Richardson 547e5e4ae6 [update_llc_test_checks.py] Fix MIPS ASM regex for functions with EH
On MIPS, functions with exception handling code emits an additional
temporary label at the start of the function (due to UseAssignmentForEHBegin):

    _Z8do_catchv:                           # @_Z8do_catchv
    .Ltmp3:
    .set .Lfunc_begin0, .Ltmp3
    .cfi_startproc
    .cfi_personality 128, DW.ref.__gxx_personality_v0
    .cfi_lsda 0, .Lexception0
    .frame	$c11,48,$c17
    .mask 	0x00000000,0
    .fmask	0x00000000,0
    .set	noreorder
    .set	nomacro
    .set	noat
    # %bb.0:                                # %entry

The `[^:]*` regex was terminating the search after .Ltmp<N>: and therefore
not detecting functions with exception handling.

Reviewed By: atanasyan, MaskRay

Differential Revision: https://reviews.llvm.org/D100027
2021-09-28 17:57:36 +01:00
Sebastian Neubauer ecd5145c27 [Utils] Replace llc with cat for tests
Make the update_llc_test_checks script test independant of llc behavior
by using cat with static files to simulate llc output.

This allows changing llc without breaking the script test case.

The update script is executed in a temporary directory, so the
llc-generated assembly files are copied there. %T is deprecated, but it
allows copying a file with a predictable filename.

Differential Revision: https://reviews.llvm.org/D110143
2021-09-22 10:10:35 +02:00
Sebastian Neubauer 4864893127 [Utils] Do not remove comments in llc test script
When checking if two prefixes can be merged for a function,
update_llc_test_checks.py removed IR comments before comparing
llc outputs of different RUN lines.
This means, if one RUN line emited lines starting with ';' and another
RUN line emited the same lines except the ones starting with ';', both
RUNs would be merged (if they share a prefix).

However, CHECK-NEXT lines check the comments, otherwise they fail, so
the script should not merge RUNs if they contain different comments.

Differential Revision: https://reviews.llvm.org/D101312
2021-07-29 13:03:05 +02:00
Joel E. Denny 5b0a948a81 [UpdateCCTestChecks] Implement --global-hex-value-regex
For example, in OpenMP offload codegen tests, global variables like
`.offload_maptypes*` are much easier to read in hex.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D104743
2021-07-20 11:23:20 -04:00
Joel E. Denny 2f5b2ea6cd [UpdateCCTestChecks] Implement --global-value-regex
`--check-globals` activates checks for all global values, and
`--global-value-regex` filters them.  For example, I'd like to use it
in OpenMP offload codegen tests to check only global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D104742
2021-07-20 11:23:20 -04:00
Joel E. Denny 9eaf0d120d [UpdateCCTestChecks] Support --check-globals
This option is already supported by update_test_checks.py, but it can
also be useful in update_cc_test_checks.py.  For example, I'd like to
use it in OpenMP offload codegen tests to check global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert, arichardson, ggeorgakoudis

Differential Revision: https://reviews.llvm.org/D104714
2021-06-25 13:17:56 -04:00
Joel E. Denny 38b7b1d4a2 [UpdateCCTestChecks][NFC] Permit other comments in common.py
Some parts of common.py already permit comment styles besides `;`.
Handle the remaining cases.  Specifically, a future patch will extend
update_cc_test_checks.py to call add_global_checks.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D104713
2021-06-23 11:12:42 -04:00
Roman Lebedev eb7ce97870
[NFC][ARM] Fix update_llc_test_checks for thumbv7-apple-darwin, autogenerate thumb2-ifcvt1.ll 2021-06-23 16:31:19 +03:00
Roman Lebedev 3c94869632
[NFC][ARM] Fix update_llc_test_checks for aarch64-apple-ios/thumbv7s-apple-darwin, autogenerate a few tests 2021-06-23 16:31:19 +03:00
Roman Lebedev 15be15073e
[NFC][ARM] Fix update_llc_test_checks for thumbv7-apple-ios, autogenerate switch-minsize.ll 2021-06-23 16:31:19 +03:00
Roman Lebedev 4de0c40031
[NFC][ARM] Fix update_llc_test_checks for armv7-apple-ios, autogenerate ifcvt5.ll/ifcvt6.ll 2021-06-23 16:31:19 +03:00
Joel E. Denny 2bfe0536e5 [UpdateCCTestChecks] Fix --replace-value-regex across RUN lines
Without this patch, llvm/utils/update_cc_test_checks.py fails to
perform `--replace-value-regex` replacements when two RUN lines
produce the same output and use the same single FileCheck prefix.  The
problem is that replacements in a RUN line's output are not performed
until after comparing against previous RUN lines' output, where
replacements have already been performed.  This patch fixes that.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D104566
2021-06-21 17:01:17 -04:00
Roman Lebedev b1f55c33d4
[UpdateTestUtils] Print test filename when complaining about conflicting prefix
Now that FileCheck eagerly complains when prefixes are unused,
the update script does the same, and  is becoming very common
to need to drop some prefixes, yet figuring out the file
it complains about isn't obvious unless it actually tells us.
2021-06-20 14:12:39 +03:00
Fangrui Song 5d9ea36baf [UpdateTestChecks] Default --x86_scrub_rip to False
True is a bad default: the useful symbol names and `@GOTPCREL` are scrubbed.

Change the default and add global variable tests to x86-basic.ll
(renamed from x86_function_name.ll since we now also test variables).
I updated some tests to show the differences.

Updated LCPI regex to include Darwin style `LCPI_[0-9]+_[0-9]+` (no
leading dot).

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D102588
2021-05-21 19:26:15 -07:00
Giorgis Georgakoudis 78a7d8c4dd [Utils][NFC] Rename replace-function-regex in update_cc_test_checks
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-05 14:19:30 -07:00
Giorgis Georgakoudis 404fa9a6cf [Utils] Add prof metadata to matched unnamed values
Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D101742
2021-05-03 15:15:34 -07:00
Alex Richardson 9692811b26 [update_(llc_)test_checks.py] Support pre-processing commands
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-04-28 12:19:19 +01:00
Craig Topper 0248e24071 [X86][update_llc_test_checks] Use a less greedy regular expression for replacing constant pool labels in tests.
While working on D97208 I noticed that these greedy regular
expressions prevent tests from failing when (%rip) appears after
a constant pool label when it didn't before.

Reviewed By: RKSimon, pengfei

Differential Revision: https://reviews.llvm.org/D99460
2021-03-28 11:39:46 -07:00
Giorgis Georgakoudis 8bc2c662d9 [Utils] Add prefix parameter in update test checks to avoid FileCheck conflicts
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-26 11:49:42 -07:00
Giorgis Georgakoudis 7ad55a3df5 [Utils][NFC] Fix regex substitution for update test checks
Relates to: https://reviews.llvm.org/D97107
2021-03-24 17:47:33 -07:00
Thomas Preud'homme 7dd90da79f [UpdateTestChecks] Fix typo & copy/paste in comments 2021-03-24 16:11:36 +00:00
Giorgis Georgakoudis 1ce846be04 Replace func name with regex for update test scripts
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-12 17:37:09 -08:00
Giorgis Georgakoudis 9f9a4dfda7 Revert "Replace func name with regex for update test scripts"
This reverts commit 5eaf70afb5.
2021-03-12 17:20:00 -08:00
Giorgis Georgakoudis 5eaf70afb5 Replace func name with regex for update test scripts
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-12 17:00:42 -08:00
Johannes Doerfert cd1bd6e587 [Utils] Check for more global information in update_test_checks
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-11 23:31:16 -06:00
Giorgis Georgakoudis ecf68972fd Revert "Replace func name with regex in update_cc_test_checks"
This reverts commit bf58d6a1f9.

Breaks tests, fix
2021-03-10 15:05:35 -08:00
Giorgis Georgakoudis bf58d6a1f9 Replace func name with regex in update_cc_test_checks
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-03-10 12:57:35 -08:00
Min-Yih Hsu c23a780c30 [M68k][test](6/8) Add all of the tests
And a small utilities -- extract-section.py -- that helps extracting
specific object file section and printing in textual format. This
utility is just a workaround for tests inside `Encoding`. Hopefully in
the future we can replace dependencies in those tests with existing tools
(e.g. llvm-readobj). Please refer to this bug for more context:
https://bugs.llvm.org/show_bug.cgi?id=49245

Note that since we don't have AsmParser for now, we are testing the MC
part using MIR as input and put those tests under the `Encoding` folder.
In the future when AsmParser (and disassembler) is finished, those tests
will be moved to `test/MC/M68k`.

Authors: myhsu, m4yers, glaubitz

Differential Revision: https://reviews.llvm.org/D88392
2021-03-08 12:30:57 -08:00