86 Commits

Author SHA1 Message Date
David Sherwood
194eceff43
update_test_checks: add new --filter-out-after option (#129739)
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-03-18 09:46:43 +00:00
Momchil Velikov
5315f3f8cb
Handle leading underscores in update_cc_test_checks.py (#121800)
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-13 11:24:05 +00:00
Alexander Richardson
94c0db06ab
[update_cc_test_checks] Add test for missing handling of mangled names
We are missing MSVC C++ functions since the name is quoted in the LLVM IR,
so we don't find them in the generated IR and therefore don't add the test
checks. Additionally, there is an issue with finding functions using NEON
types (see https://github.com/llvm/llvm-project/pull/121800).

Pull Request: https://github.com/llvm/llvm-project/pull/121976
2025-01-07 16:00:13 -08:00
Hari Limaye
94473f4db6
[IRBuilder] Generate nuw GEPs for struct member accesses (#99538)
Generate nuw GEPs for struct member accesses, as inbounds + non-negative
implies nuw.

Regression tests are updated using update scripts where possible, and by
find + replace where not.
2024-08-09 13:25:04 +01:00
Henrik G. Olsson
e6eda66cbc
Recommit changes to global checks (#71171)
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-13 14:45:27 +01:00
Antonio Frighetto
970bf07d0b [clang][CodeGen] Ensure consistent mustprogress attribute emission
Emission of `mustprogress` attribute previously occurred only within
`EmitFunctionBody`, after generating the function body. Other routines
for function body creation may lack the attribute, potentially leading
to suboptimal optimizations later in the pipeline. Attribute emission
is now anticipated prior to generating the function body.

Fixes: https://github.com/llvm/llvm-project/issues/69833.
2023-11-11 09:43:03 +01:00
Johannes Doerfert
b9f1df7a04 Revert "[UTC] Add fallback support for specific metadata, and check their defs"
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
2023-07-14 13:53:37 -07:00
Johannes Doerfert
5b8b9b39cc Revert "[UTC] Adapt version matcher to glob CLANG_VENDOR"
This reverts commit 68f5d1be3d8f9b2ee2f25098203b24a32057b4e6 as it is
built on top of https://reviews.llvm.org/D148216 which is broken.

See also https://github.com/llvm/llvm-project/issues/63746
2023-07-14 13:53:36 -07:00
Henrik G. Olsson
68f5d1be3d [UTC] Adapt version matcher to glob CLANG_VENDOR
Both the pattern for finding the clang version metadata, and the emitted
checker, are now more robust, to handle a vendor prefix.

Differential Revision: https://reviews.llvm.org/D154520
2023-07-05 17:10:47 +00:00
Henrik G. Olsson
8a3fdf7b90 [UTC] Add fallback support for specific metadata, and check their defs
This prevents update_cc_tests.py from emitting hard-coded identifiers
for metadata (global variable checkers still check hard-coded
identifiers). Instead it emits regex checkers that match even if the
identifiers change. Also adds a new mode for --check-globals: instead of
simply being on or off, it now has the options 'none', 'smart' and
'all', with 'none' and 'all' corresponding to the previous modes.

The 'smart' mode only emits checks for global definitions referenced
in the IR or other metadata that itself has a definition checker
emitted, making the rule transitive. It does not emit checks for
attribute sets, since that is better checked by --check-attributes. This
mode is made the new default. To make the change in default mode
backwards compatible a version bump is introduced (to v3), and the
default remains 'none' in v1 & v2.

This will result in metadata checks being emitted more often, so filters
are added to not check absolute file paths and compiler version git
hashes.

rdar://105239218
2023-07-05 14:04:50 +02:00
Tobias Hieta
dd3c26a045
[NFC][Py Reformat] Reformat python files in clang and clang-tools-extra
This is an ongoing series of commits that are reformatting our
Python code.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: MatzeB

Differential Revision: https://reviews.llvm.org/D150761
2023-05-23 08:29:52 +02:00
Itay Bookstein
782c59a4ee [OpenMP] Prefix outlined and reduction func names with original func's name
This patch prefixes omp outlined helpers and reduction funcs
with the original function's name.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D140722
2023-04-19 23:00:26 +03:00
Itay Bookstein
6fdd13e0ec Revert "[OpenMP] Prefix outlined and reduction func names with original func's name"
This reverts commit 029bfc311d4d7d3cd90be81bb08c046848796d02.
2023-04-19 19:08:49 +03:00
Itay Bookstein
029bfc311d [OpenMP] Prefix outlined and reduction func names with original func's name
This patch attempts to prefix omp outlined helpers and reduction funcs
with the original function's name.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D140722
2023-04-19 19:05:21 +03:00
Nikita Popov
fb309041f0 [UTC] Enable --function-signature by default
This patch enables --function-signature by default under --version 2
and makes --version 2 the default. This means that all newly created
tests will check the function signature, while leaving old tests alone.

There's two motivations for this change:

* Without --function-signature, the generated check lines may fail
  in a very hard to understand way if the test both includes a
  function definition and a call to that function. (Though we could
  address this by making the CHECK-LABEL stricter, without checking
  the full signature.)
* This actually checks that uses of the arguments in the function
  body use the correct argument, instead of matching against any
  variable.

This is a replacement for D139006 and D140212 based on the
--version mechanism.

I did not include an opt-out flag --no-function-signature because
I'm not sure we need it. Would be happy to include it though,
if desired.

Differential Revision: https://reviews.llvm.org/D145149
2023-03-07 10:27:52 +01:00
Nikita Popov
a26d3031cf [UTC] Include return type/attributes under --version 2
If --function-signature is used with --version 2, then also include
the return type/attributes in the check lines. This is the
implementation of D133943 rebased on the --version mechanism from
D142473.

This doesn't bump the default version yet, because I'd like to do
that together with D140212 (which enables --function-signature by
default), as these changes seem closely related. For now this
functionality can be accessed by explicitly passing --version 2
to UTC.

Fixes https://github.com/llvm/llvm-project/issues/61058.

Differential Revision: https://reviews.llvm.org/D144963
2023-03-02 09:59:22 +01:00
Nikita Popov
57c81917d3 [Clang] Convert update_cc_test_checks tests to opaque pointers (NFC) 2023-02-17 09:07:15 +01:00
Nikita Popov
5375b638be [UTC] Add --version argument
We have a number of pending changes to update_test_checks.py
(and friends) that are essentially blocked on test churn:
If the output of UTC for an existing flag combination changes,
then the next time a test is regenerated, it will contain many
spurious changes. This makes changes to UTC default
behavior essentially impossible.

Examples of such changes are:

* D133943/D142373 want --function-signature to also check the
  return type/attributes.
* D139006/D140212 want to make --function-signature the default
  behavior.
* D142452 wants to add wildcards for block labels.

This patch tries to resolve this issue by adding a --version
argument, which works as follows:

* When regenerating an old test, the default version is 1.
* When generating a new test, the default version is the newest.
 When an explicit version is specified, that of course wins.

This means that any currently existing tests will keep using
--version 1 format, while any new tests will automatically embed
--version N where N is the latest version, and then keep using
that test format from then on.

This patch only implements the --version flag without bumping
the default version, so it does not have any visible behavior
change by itself.

Differential Revision: https://reviews.llvm.org/D142473
2023-01-30 09:57:26 +01:00
Nikita Popov
697bfa40a3 Revert "[UpdateTestChecks] Match define for labels"
This reverts commit a888825aeef8d6592c6cf5f4e5854cc39af49633.

This changes the default output of UTC, and as such introduces
spurious changes whenever existing tests are regenerated.

I've indicated in https://reviews.llvm.org/D139006#3989954 how
this can be implemented without causing test churn.
2022-12-13 09:15:35 +01:00
Sebastian Neubauer
a888825aee [UpdateTestChecks] Match define for labels
Previously, the label also matched function calls with the function
name, which caused tests to fail because the label matched on the wrong
line.
Add the `define` prefix, so only function defines are matched.

Differential Revision: https://reviews.llvm.org/D139006
2022-12-12 12:29:54 +01:00
Mircea Trofin
255e7e1c21 [UpdateTestChecks] Fix update_*_test_checks.py to add "unused" prefixes
The support introduced in D124306 was only added to
update_llc_test_checks.py, but the motivating usecases (see
https://lists.llvm.org/pipermail/llvm-dev/2021-February/148326.html)
cover update_test_checks.py, update_cc_test_checks.py, and
update_analyze_test_checks.py, too.

Issue #59220.

Differential Revision: https://reviews.llvm.org/D138836
2022-11-28 13:24:32 -08:00
Dhruva Chakrabarti
839ac62c50 Revert "[OpenMP] Codegen aggregate for outlined function captures"
This reverts commit 7539e9cf811e590d9f12ae39673ca789e26386b4.
2022-09-15 03:08:46 +00:00
Giorgis Georgakoudis
7539e9cf81 [OpenMP] Codegen aggregate for outlined function captures
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3)  forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call.

Reviewed By: jdoerfert, jhuber6, ABataev

Differential Revision: https://reviews.llvm.org/D102107
2022-09-15 00:54:05 +00:00
Tom Stellard
74384c7fce Disable update_cc_test_checks.py tests in stand-alone builds
The script is located in the llvm/ sub-directory, so it is not available
for when doing a stand-alone build.

See https://discourse.llvm.org/t/rfc-stand-alone-build-support/61291

Differential Revision: https://reviews.llvm.org/D123967
2022-08-11 20:53:37 -07:00
Nicolai Hähnle
5a4033c367 update-test-checks: safely handle tests with #if's
There is at least one Clang test (clang/test/CodeGen/arm_acle.c) which
has functions guarded by #if's that cause those functions to be compiled
only for a subset of RUN lines.

This results in a case where one RUN line has a body for the function
and another doesn't. Treat this case as a conflict for any prefixes that
the two RUN lines have in common.

This change exposed a bug where functions with '$' in the name weren't
properly recognized in ARM assembly (despite there being a test case
that was supposed to catch the problem!). This bug is fixed as well.

Differential Revision: https://reviews.llvm.org/D130089
2022-07-20 11:23:49 +02:00
Jan Korous
0376c0f271 Revert "[utils] Avoid hardcoding metadata ids in update_cc_test_checks"
This reverts commit ce583b14b2ec37b1c168bb92020680cb452502b3.
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
Nikita Popov
b16a3b4f3b [Clang] Add -no-opaque-pointers to more tests (NFC)
This adds the flag to more tests that were not caught by the
mass-migration in 532dc62b907554b3f07f17205674aa71e76fc863.
2022-04-07 12:53:29 +02:00
Nikita Popov
062b1ae7e0 Reapply [Utils] Fix %S substitution
%S refers to the directory of %s, not to the cwd. This is mostly
handled correctly, but update_cc_test_checks.py used the wrong
path for non-FileCheck RUN lines.

Reapplying this with a fix for an update_cc_test_checks test that
was based on cwd semantics.
2022-03-21 15:15:34 +01:00
Aaron Ballman
0dd49a5628 Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the eighth batch of tests being updated (there are a
significant number of other tests left to be updated).
2022-02-12 07:25:06 -05:00
Florian Hahn
67aa314bce
[IRGen] Do not overwrite existing attributes in CGCall.
When adding new attributes, existing attributes are dropped. While
this appears to be a longstanding issue, this was highlighted by D105169
which dropped a lot of attributes due to adding the new noundef
attribute.

Ahmed Bougacha (@ab) tracked down the issue and provided the fix in
CGCall.cpp. I bundled it up and updated the tests.
2022-01-20 13:45:19 +00:00
hyeongyu kim
1b1c8d83d3 [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D105169
2022-01-16 18:54:17 +09:00
Nikita Popov
1201a0f395 [OpenMP] Fix incorrect type when casting from uintptr
MakeNaturalAlignAddrLValue() expects the pointee type, but the
pointer type was passed. As a result, the natural alignment of
the pointer (usually 8) was always used in place of the natural
alignment of the value type.

Differential Revision: https://reviews.llvm.org/D116171
2021-12-23 08:57:11 +01:00
hyeongyu kim
fd9b099906 Revert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default"
This reverts commit aacfbb953eb705af2ecfeb95a6262818fa85dd92.

Revert "Fix lit test failures in CodeGenCoroutines"

This reverts commit 63fff0f5bffe20fa2c84a45a41161afa0043cb34.
2021-11-09 02:15:55 +09:00
hyeongyukim
aacfbb953e [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D105169

[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2)

This patch updates test files after D105169.
Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows:

(1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached.

(2) The remaining tests are updated manually.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D108453

Resolve lit failures in clang after 8ca4b3e's land

Fix lit test failures in clang-ppc* and clang-x64-windows-msvc

Fix missing failures in clang-ppc64be* and retry fixing clang-x64-windows-msvc

Fix internal_clone(aarch64) inline assembly
2021-11-06 19:19:22 +09:00
Juneyoung Lee
89ad2822af Revert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default"
This reverts commit 7584ef766a7219b6ee5a400637206d26e0fa98ac.
2021-11-06 15:39:19 +09:00
Juneyoung Lee
7584ef766a [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default
Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D105169
2021-11-06 15:36:42 +09:00
Juneyoung Lee
f193bcc701 Revert D105169 due to the two-stage failure in ASAN
This reverts the following commits:
37ca7a795b277c20c02a218bf44052278c03344b
9aa6c72b92b6c89cc6d23b693257df9af7de2d15
705387c5074bcca36d626882462ebbc2bcc3bed4
8ca4b3ef19fe82d7ad6a6e1515317dcc01b41515
80dba72a669b5416e97a42fd2c2a7bc5a6d3f44a
2021-10-18 23:52:46 +09:00
Juneyoung Lee
8ca4b3ef19 [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2)
This patch updates test files after D105169.
Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows:

(1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached.

(2) The remaining tests are updated manually.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D108453
2021-10-16 12:01:41 +09:00
Giorgis Georgakoudis
ac90dfc43a Revert "[OpenMP] Codegen aggregate for outlined function captures"
This reverts commit 1d66649adf28d48ae1731516d87fb899426e3349.

Revert to fix AMG GPU issue.
2021-09-21 13:20:39 -07:00
Giorgis Georgakoudis
1d66649adf [OpenMP] Codegen aggregate for outlined function captures
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3)  forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call.

Reviewed By: jdoerfert, jhuber6

Differential Revision: https://reviews.llvm.org/D102107
2021-09-21 10:50:04 -07:00
Yaron Keren
10d78a06ba [llvm-lit] unbreak clang-only builds by not assuming llvm-lit in build dir
Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D109000
2021-08-31 18:57:47 +03:00
Yaron Keren
5aa0f9cc9a Use installed llvm-lit.py instead of lit.py PR-51072
Three tests fail when building and testing LLVM from the Visual C++ environment
since they use the repo version of lit.py that do not have local customization
builtin_parameters = { 'build_mode' : 'Release' }
https://bugs.llvm.org/show_bug.cgi?id=51072

Reviewed By: dyung

Differential Revision: https://reviews.llvm.org/D108085
2021-08-18 09:06:06 +03:00
Jessica Clarke
0e79a94836 [Utils] Support class template specializations in update_cc_test_checks
ClassTemplateSpecializationDecl not within a ClassTemplateDecl
represents an explicit instatiation of a template and so should be
handled as if it were a normal CXXRecordDecl. Unfortunately, having an
equivalent for FunctionTemplateDecl remains a TODO in ASTDumper's
VisitFunctionTemplateDecl, with all the explicit instantiations just
being emitted inside the FunctionTemplateDecl along with all the other
specializations, meaning we can't easily support explicit function
instantiations in update_cc_test_checks.

Reviewed By: arichardson

Differential Revision: https://reviews.llvm.org/D106243
2021-07-28 16:03:41 +01: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
Giorgis Georgakoudis
fb0cf01795 Revert "[OpenMP] Codegen aggregate for outlined function captures"
This reverts commit e9c7291cb25f071f1a1dfa4049ed9f5a8a217b3e.

Fix failing tests
2021-07-19 07:54:26 -07:00
Giorgis Georgakoudis
e9c7291cb2 [OpenMP] Codegen aggregate for outlined function captures
Parallel regions are outlined as functions with capture variables explicitly generated as distinct parameters in the function's argument list. That complicates the fork_call interface in the OpenMP runtime: (1) the fork_call is variadic since there is a variable number of arguments to forward to the outlined function, (2) wrapping/unwrapping arguments happens in the OpenMP runtime, which is sub-optimal, has been a source of ABI bugs, and has a hardcoded limit (16) in the number of arguments, (3)  forwarded arguments must cast to pointer types, which complicates debugging. This patch avoids those issues by aggregating captured arguments in a struct to pass to the fork_call.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D102107
2021-07-16 23:27:44 -07:00
Tom Stellard
303ddb60a2 Fix utils/update_cc_test_checks/check-globals.test on stand-alone builds
We want to use LLVM_EXTERNAL_LIT if defined for the %lit substitution.

Reviewed By: jdenny

Differential Revision: https://reviews.llvm.org/D105873
2021-07-13 10:47:30 -07:00
Nikita Popov
ff8b1b1b9c Reapply [IR] Don't mark mustprogress as type attribute
Reapply with fixes for clang tests.

-----

This is a simple enum attribute. Test changes are because enum
attributes are sorted before type attributes, so mustprogress is
now in a different position.
2021-07-09 20:57:44 +02:00