180 Commits

Author SHA1 Message Date
Luke Lau
856e815ca1
[DAGCombiner] Set disjoint flag in add->or and xor->or combines (#86925)
We check DAG.haveNoCommonBitsSet so the operands will be known to be
disjoint.

I couldn't think of a codegen test case since most targets aren't
checking hasDisjoint yet, apart from RISCV in the or_is_add pattern, but
it also falls back to computeKnownBits.
2024-03-28 18:08:59 +08:00
Noah Goldstein
ff63d628c4 [CodeExtractor] Terminate callsite blocks to new noreturn functions with unreachable
Since some of the users of `CodeExtractor` like `HotColdSplitting` run
late in the pipeline, returns are not cleaned to `unreachable`. So,
just emit `unreachable` directly if the function is `noreturn`.

Closes #84682
2024-03-18 15:11:55 -05:00
Nicolai Hähnle
3846019d8f update_test_checks: keep meta variables stable by default
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-08 04:33:38 +01:00
Nicolai Hähnle
b565126b4d Revert "update_test_checks: keep meta variables stable by default"
This reverts commit fb02f9ac84a6151e41aba8f7391edd132a9aaf14.

Looks like some Python version incompatibility, will investigate.
2024-03-08 04:25:07 +01:00
Nicolai Hähnle
fb02f9ac84 update_test_checks: keep meta variables stable by default
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-08 03:58:12 +01:00
Nicolai Hähnle
448419007e update_test_checks: precommit a test case
The test case demonstrates how meta variables are needlessly renamed,
making diffs harder to read.
2024-03-08 03:58:11 +01:00
wanglei
a5c90e48b6
[LoongArch] Switch to the Machine Scheduler (#83759)
The SelectionDAG scheduling preference now becomes source order
scheduling (machine scheduler generates better code -- even without
there being a machine model defined for LoongArch yet).

Most of the test changes are trivial instruction reorderings and
differing register allocations, without any obvious performance impact.

This is similar to commit: 3d0fbafd0bce43bb9106230a45d1130f7a40e5ec
2024-03-05 09:15:44 +08:00
Henrik G. Olsson
6a65b44322
[UTC] Don't leave dangling CHECK-SAME when removing CHECK lines (#82569)
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-28 17:08:36 -08:00
Craig Topper
86ce491f30
[DAGCombiner] Remove unneeded commonAlignment from reduceLoadWidth. (#81707)
We already have the PtrOff factored into MachinePointerInfo. Any calls
to getAlign on the new load with do commonAlignment with the
MachinePointerInfo offset and the base alignment.
2024-02-13 23:26:25 -08:00
Ikhlas Ajbar
76e3759d8d
[Hexagon] Order objects on the stack by their alignments (#81280)
This patch sorts stack objects by their alignment value from the largest
to the smallest. If two objects have the same alignment, then they are
sorted by their size from the largest to the smallest. This minimizes
padding and reduces run time stack size.
2024-02-10 14:42:50 -06:00
Jeremy Morse
66d4fe97d8
[DebugInfo][RemoveDIs] Final final test-maintenence patch (#80988)
This should be the final portion of shaping-up the test suite to be
ready for turning on non-intrinsic debug-info:
* Pin CostModel tests that expect to see intrinsics in their -debug
output to not use RemoveDIs. This is a spurious test output difference.
* Add 'tail' to a bunch of intrinsics in UpdateTestChecks. We're
cannonicalising intrinsics to be printed with "tail" in RemoveDI
conversion as dbg.values usually pick that up while being optimised.
This is another spurious output difference.
* The "DebugInfoDrop" pass used in the debugify unit-tests happens to
operate inside the pass manager, thus it sees non-intrinsic debug-info.
Update it to correctly drop it.
2024-02-07 14:31:52 +00:00
Ivan Kosarev
b6daac023a
[AMDGPU][True16] Remove the VGPR_LO/HI16 register classes. (#76500) 2023-12-29 12:13:24 +00:00
Mircea Trofin
bb6497ffa6
[BPI] Reuse the AsmWriter's BB naming scheme in BranchProbabilityPrinterPass (#73593)
When using `BranchProbabilityPrinterPass`, if a BB has no name, we get pretty unusable information like `edge -> has probability...` (i.e. we have no idea what the vertices of that edge are).

This patch uses `printAsOperand`, which uses the same naming scheme as `Function::dump`, so for example during debugging sessions, the IR obtained from a function and the names used by `BranchProbabilityPrinterPass` will match.

A shortcoming is that `printAsOperand` will result in the numbering algorithm re-running for every edge and every vertex (when `BranchProbabilityPrinterPass` is run on a function). If, for the given scenario, this is a problem, we can revisit this subsequently.

Another nuance is that the entry basic block will be numbered, which may be slightly confusing when it's anonymous, but it's easily identifiable - the first edge would have it as source (and the number should be easily recognizable)
2023-12-02 13:01:48 -08:00
Florian Hahn
08a6968127
[UTC] Support arm64-apple-macosx in update_llc_test_checks.py. (#73568)
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-28 10:06:20 +00:00
Matthias Braun
331111277a
Support BranchProbabilityInfo in update_analyze_test_checks.py (#72943)
- 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-21 17:08:44 -08: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
Florian Hahn
24839c3253
[UTC] Escape multiple {{ or }} in input for check lines. (#71790)
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-11-09 17:18:11 +00:00
Florian Hahn
129a91ec01
[UTC] Add test where double braces need to be escaped.
Test for #71790.
2023-11-09 15:00:08 +00:00
Zhaoxuan Jiang
1f54ef78d5
[AArch64] Only clear kill flags if necessary when merging str (#69680)
Previously the kill flags of the source register were unconditionally
cleared when a `str` pair was merged, which results in suboptimal
register allocation and inhibits some renaming opportunities which may
allow further merging `str`.
2023-11-02 17:03:21 -07:00
Ramkumar Ramachandra
4c01a58008
update_analyze_test_checks: support output from LAA (#67584)
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-31 14:33:53 +00:00
Henrik G. Olsson
da28c33094
[UTC] Recognise CHECK lines with globals matched literally (#70050)
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-10-30 13:17:26 +01:00
Ramkumar Ramachandra
ac466c7525
UpdateTestChecks: squelch warning on SCEV output (#67443)
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-26 19:40:13 +01:00
Ivan Kosarev
469b3bfad2 [AMDGPU] Add True16 register classes.
Reviewed By: rampitec, Joe_Nash

Differential Revision: https://reviews.llvm.org/D156099
2023-09-22 10:17:02 +01:00
Jay Foad
102838d3f6
update_mir_test_checks.py: match undef vreg subreg definitions (#66627)
Following on from D139466 which added support for dead vreg defs, this
patch adds support for "undef" defs of subregs.

Use this to regenerate checks for amx-greedy-ra-spill-shape.ll which
previously required manual tweaks to the autogenerated checks to fix an
EXPENSIVE_CHECKS failure; see commit
8b7c1fbd9647a5a6ef246a6b5b2543ea0f5a2337
2023-09-18 12:14:46 +01:00
Jay Foad
303eb50cf4 [update_mir_test_checks] Fix new test in non-X86 builds 2023-09-15 13:43:00 +01:00
Jay Foad
24a082878f
[update_mir_test_checks] Handle multiple defs of vreg (#66483)
When (post-SSA) MIR has multiple defs of the same vreg,
update_mir_test_checks would use different variable names for each def
like this, where DEF and DEF1 both refer to %0:
```
    %0:gr32 = IMPLICIT_DEF
    %0:gr32 = IMPLICIT_DEF
-->
    ; CHECK: [[DEF:%[0-9]+]]:gr32 = IMPLICIT_DEF
    ; CHECK-NEXT: [[DEF1:%[0-9]+]]:gr32 = IMPLICIT_DEF
```
This should be harmless, but it messed up the way that mangle_vreg
counts the number of names in vreg_map to come up with a new numeric
suffix, such that you could get the same variable name for different
vregs, like this, where DEF2 refers to both %0 and %2:
```
    %0:gr32 = IMPLICIT_DEF
    %1:gr32 = IMPLICIT_DEF
    %0:gr32 = IMPLICIT_DEF
    %2:gr32 = IMPLICIT_DEF
-->
    ; CHECK: [[DEF:%[0-9]+]]:gr32 = IMPLICIT_DEF
    ; CHECK-NEXT: [[DEF1:%[0-9]+]]:gr32 = IMPLICIT_DEF
    ; CHECK-NEXT: [[DEF2:%[0-9]+]]:gr32 = IMPLICIT_DEF
    ; CHECK-NEXT: [[DEF2:%[0-9]+]]:gr32 = IMPLICIT_DEF
```
Fix this by always using the same variable name for the same vreg.
2023-09-15 13:10:45 +01:00
Jay Foad
e4eb204333
[update_mir_test_checks] Precommit test for multiple defs of vreg (#66482)
XFAIL it until it is fixed by an upcoming commit.
2023-09-15 13:08:56 +01:00
Jannik Silvanus
1ed8760ee8 [UTC] Fix test named_function_arguments_split.ll
An outdated comment was removed from the expected output,
but not the actual test file.
2023-08-29 16:55:42 +02:00
Jannik Silvanus
998c323910 [UTC] Keep function args parenthesis on label line (bumps version to 3)
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-29 16:40:06 +02:00
Jannik Silvanus
dd1cf3a9aa [UTC] Precommit testcase for function definition line-splitting
Review of the actual change: https://reviews.llvm.org/D158497
2023-08-29 16:40:06 +02:00
Johannes Doerfert
dcd4d0a790 [UTC] Honor global-value-regex in UTC_ARGS
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-08-23 10:40:30 -07:00
Harvin Iriawan
db158c7c83 [AArch64] Update generic sched model to A510
Refresh of the generic scheduling model to use A510 instead of A55.
  Main benefits are to the little core, and introducing SVE scheduling information.
  Changes tested on various OoO cores, no performance degradation is seen.

  Differential Revision: https://reviews.llvm.org/D156799
2023-08-21 12:25:15 +01:00
pvanhout
490a867f16 [GlobalISel] Also set dead flags of implicit defs added by BuildMI
BuildMI automatically adds the implicit operands of the
instruction. This meant we couldn''t set the dead flag on
dead implicit defs in that case.

Fix it by introducing an opcode to mark a given implicit
def as dead.

Fixes #64565

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D157515
2023-08-11 08:38:37 +02:00
pvanhout
89e91e4c0c [AMDGPU] Remove post-PromoteAlloca SROA run
PromoteAlloca now uses SSAUpdater, it doesn't need SROA to clean-up after it anymore.

Internal testing shows no noticeable performance impact.

Reviewed By: #amdgpu, arsenm

Differential Revision: https://reviews.llvm.org/D156398
2023-08-11 08:29:21 +02:00
Matt Arsenault
1f0d24ce24 update_llc_test_checks: Fix broken amdgpu test
Use the correct address space for alloca. Also use opaque pointers.
2023-08-01 20:00:21 -04:00
Johannes Doerfert
6fa8244eb6 [IR] Mark llvm.trap as memory(inaccessiblemem: write)
Traps will not read/write the program state but they need an effect for
preservation, similar to `llvm.assume`. We really want a new memory kind
for that (see TODO), but for now `inaccessiblemem: write` is better than
any possible effect.

Differential Revision: https://reviews.llvm.org/D156476
2023-07-31 13:44:52 -07: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
Eddie Phillips
948375f0a6 update_mir_test_checks.py - separate different prefix checks
Matches behaviour in update_llc_test_checks.py etc.

Fixes #63112

Differential Revision: https://reviews.llvm.org/D152333
2023-07-06 11:49:52 +01: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
Jay Foad
e829eb9075 [update_mir_test_checks] Tolerate -simplify-mir output
D135579 added support for fixedStack, but did not cope with the output
of -simplify-mir which does not include the fixedStack section by
default.

Differential Revision: https://reviews.llvm.org/D152896
2023-06-14 13:16:00 +01:00
Juan Manuel MARTINEZ CAAMAÑO
abe6ecd7e5 [AsmPrinter][AMDGPU] Generate uwtable entries in .eh_frame
Consider only targets where `MCAsmInfo::ExceptionsType == ExceptionHandling::None`
and that support CFI (when `MCAsmInfo::UsesCFIForDebug` is set to true):
currently, only AMDGPU.

This patch enables the emission of CFI information in the .eh_frame
section when the uwtable attribute is present on a function.

Before, we could generate CFI information for debugging puproses only.

This patch prepares AMDGPU to support collecting GPU stack traces in the future.

I did a first implementation (https://reviews.llvm.org/D139024)
but at the time I had not realized that no other platform used
`UsesCFIForDebug`.

Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D151806
2023-06-07 09:54:47 +02:00
Johannes Doerfert
dbbe9b3776 [Attributor] Create AAMustProgress for the mustprogress attribute
Derive the mustprogress attribute based on the willreturn attribute
or the fact that all callers are mustprogress.

Differential Revision: https://reviews.llvm.org/D94740
2023-06-05 16:33:52 -07:00
Tobias Hieta
f84bac329b
[NFC][Py Reformat] Reformat lit.local.cfg python files in llvm
This is a follow-up to b71edfaa4ec3c998aadb35255ce2f60bba2940b0
since I forgot the lit.local.cfg files in that one.

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: barannikov88, kwk

Differential Revision: https://reviews.llvm.org/D150762
2023-05-17 17:03:15 +02:00
Jay Foad
caf22ec64a [UpdateTestChecks] More support for X86 exception handling
Differential Revision: https://reviews.llvm.org/D149971
2023-05-06 15:16:54 +01:00
Ilia Kuklin
9a9c6b8e75 [MSP430] Add CFI instructions for MSP430.
Implement emission of DWARF CFI instructions for MSP430. This includes descriptions of stack frame layout and location of callee-saved registers that could be used for backtracing.

Differential Revision: https://reviews.llvm.org/D146966
2023-04-05 15:53:01 -07:00
Jon Roelofs
aba4e4d6c1
[AArch64] Add hex comments to mov-imm spellings in the InstPrinter
Differential Revision: https://reviews.llvm.org/D146105
2023-03-15 14:29:44 -07:00
Koakuma
24e300190a [SPARC] Implement hooks for conditional branch relaxation
Integrate the BranchRelaxation pass to help with relaxing out-of-range
conditional branches.

This is mostly of concern for SPARCv9, which uses conditional branches with
much smaller range than its v8 counterparts.
(Some large autogenerated code, such as the ones generated by TableGen, already
hits this limitation when building in Release)

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D142458
2023-03-11 17:42:09 -05: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