platform/upstream/llvm.git
20 months ago[Clang][CodeGen] Use poison instead of undef for extra argument in __builtin_amdgcn_m...
Manuel Brito [Tue, 6 Dec 2022 12:39:38 +0000 (12:39 +0000)]
[Clang][CodeGen] Use poison instead of undef for extra argument in __builtin_amdgcn_mov_dpp [NFC]

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

20 months ago[mlir][SparseTensor] Apply ClangTidyLegacy finding (NFC).
Adrian Kuegel [Tue, 6 Dec 2022 12:29:47 +0000 (13:29 +0100)]
[mlir][SparseTensor] Apply ClangTidyLegacy finding (NFC).

Converting integer literal to bool, use bool literal instead.

20 months ago[AArch64] Implement __arm_rsr128/__arm_wsr128
Archibald Elliott [Wed, 30 Nov 2022 19:33:54 +0000 (19:33 +0000)]
[AArch64] Implement __arm_rsr128/__arm_wsr128

This only contains the SelectionDAG implementation. GlobalISel to
follow.

The broad approach is:
- Introduce new builtins for 128-bit wide instructions.
- Lower these to @llvm.read_register.i128/@llvm.write_register.i128
- Introduce target-specific ISD nodes which have legal operands (two
  i64s rather than an i128). These are named AArch64::{MRRS, MSRR} to
  match the instructions they are for. These are a little complex as
  they need to match the "shape" of what they're replacing or the
  legaliser complains.
- Select these using the existing tryReadRegister/tryWriteRegister to
  share the MDString parsing code, and introduce additional code to
  ensure these are selected into the right MRRS/MSRR instructions. What
  makes this hard is ensuring that the two i64s end up in an XSeqPair
  register pair, because SelectionDAG doesn't care that much about
  register classes if it can avoid doing so.

The main change to existing code is the reorganisation of
tryReadRegister and tryWriteRegister to try to keep the string parsing
code separate from the instruction creating code.

This also includes the changes to clang to define and use the ACLE
feature macro named `__ARM_FEATURE_SYSREG128`.

Contributors:
  Sam Elliott
  Lucas Prates

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

20 months ago[AArch64] implement GPR (U/S)(MIN/MAX) instruction SDag support
Ties Stuij [Tue, 6 Dec 2022 10:56:43 +0000 (10:56 +0000)]
[AArch64] implement GPR (U/S)(MIN/MAX) instruction SDag support

Using SelectionDag, lower umin, umax, smin, smax intrinsics to corresponding
UMIN, UMAX, SMIN, SMAX instructions when feat CSSC is available.

See specs for corresponding immediate and register versions in:
https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/

Reviewed By: lenary

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

20 months ago[IR] Don't assume readnone/readonly intrinsics are willreturn
Nikita Popov [Wed, 26 Oct 2022 09:55:46 +0000 (11:55 +0200)]
[IR] Don't assume readnone/readonly intrinsics are willreturn

This removes our "temporary" hack to assume that readnone/readonly
intrinsics are also willreturn. An explicit willreturn annotation,
usually via default intrinsic attributes, is now required.

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

20 months ago[AArch64] lower abs intrinsic to new ABS instruction in SelDag
Ties Stuij [Tue, 6 Dec 2022 10:44:05 +0000 (10:44 +0000)]
[AArch64] lower abs intrinsic to new ABS instruction in SelDag

When feature CSSC is available, the SelectionDag abs intrinsic should map to the
new scalar ABS instruction.

Additionally, the SIMDTwoScalarD tablegen defm includes a pattern match for
scalar i64, which we don't want to use when CSSC is enabled.

spec:
https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/ABS--Absolute-value-

Reviewed By: lenary

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

20 months ago[LLVM][ARM] Correct llvm feature for vfpv3d16 host feature
David Spickett [Mon, 5 Dec 2022 10:10:42 +0000 (10:10 +0000)]
[LLVM][ARM] Correct llvm feature for vfpv3d16 host feature

d16 was removed in https://reviews.llvm.org/D60691.

Reviewed By: efriedma

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

20 months ago[lld-macho] Fix map file test on 32 bit hosts
David Spickett [Tue, 6 Dec 2022 10:30:38 +0000 (10:30 +0000)]
[lld-macho] Fix map file test on 32 bit hosts

The test added in https://reviews.llvm.org/D137368 has been failing
on our 32 bit arm bots:
https://lab.llvm.org/buildbot/#/builders/178/builds/3460

You get this for the strings:
<<dead>> 0x883255000000003 [ 10] literal string: Hello, it's me
Instead of the expected:
<<dead>>  0x0000000F  [  3] literal string: Hello, it's me

This is because unlike symbols whose size is a uint64_t, strings
use a StringRef whose size is size_t. size_t changes size between
32 and 64 bit platforms.

This fixes the test by using %z to print the size of the strings,
this works for 32 and 64 bit.

20 months ago[AArch64] SelectionDag codegen for gpr CTZ instruction
Ties Stuij [Tue, 6 Dec 2022 10:42:06 +0000 (10:42 +0000)]
[AArch64] SelectionDag codegen for gpr CTZ instruction

When feature CSSC is available we should use instruction CTZ in SelectionDag
where applicable:

- CTTZ intrinsics are lowered to using the gpr CTZ instruction
- BITREVERSE -> CTLZ instruction pattern gets replaced by CTZ

spec:
https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/CTZ--Count-Trailing-Zeros-

Reviewed By: lenary

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

20 months ago[llvm-objdump] Avoid using mapping symbols as branch target labels
Kristina Bessonova [Fri, 18 Nov 2022 17:56:51 +0000 (19:56 +0200)]
[llvm-objdump] Avoid using mapping symbols as branch target labels

The main motivation for this change is to avoid ambiguity because
mapping symbol names may not be unique across a binary and do not allow uniquely
identifying target address. So that mapping symbols used as branch target
labels make llvm-objdump output less readable.

Another point is that mapping symbols sometimes appear in
non-allocatable sections, like debug info sections which make objdump
output even more confusing.

For example, a small AArch64 executable may contain plenty of `$d[.*]`
symbols and none of them would be useful as a label for resolving
a branch or a memory operand target address:

```
  0000000000000254 l       .note.ABI-tag 0000000000000000 $d
  00000000000008d4 l       .eh_frame            0000000000000000 $d
  0000000000000868 l       .rodata              0000000000000000 $d
  0000000000011028 l       .data                0000000000000000 $d
  0000000000010db8 l       .fini_array          0000000000000000 $d
  0000000000010db0 l       .init_array          0000000000000000 $d
  00000000000008e8 l       .eh_frame            0000000000000000 $d
  0000000000011034 l       .bss                 0000000000000000 $d
```

Note that GNU objdump doesn't use mapping symbols as branch target
labels for all targets that support such symbols (ARM, AArch64, CSKY).

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

20 months ago[mlir] Add hoisting of transfer ops in affine loops
Javier Setoain [Mon, 7 Nov 2022 21:27:36 +0000 (21:27 +0000)]
[mlir] Add hoisting of transfer ops in affine loops

The only way to do this with the current hoisting strategy is by
lowering Affine to Scf first, but that prevents further passes on
Affine.

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

20 months ago[SCEVExpander] Support cost evaluation of several SCEVs with same budget
Max Kazantsev [Tue, 6 Dec 2022 09:35:45 +0000 (16:35 +0700)]
[SCEVExpander] Support cost evaluation of several SCEVs with same budget

This is a follow-up from discussion in D138412. Sometimes we want to evaluate
the cost of expansion of several SCEVs together with same budget. For example,
if one of them is a bit above cheap limit, and the second one is free, then
we still want to expand. Checking each of them with "cheap" limit is a bit more
pessimistic.

Differential Revision: https://reviews.llvm.org/D138475
Reviewed By: lebedev.ri

20 months ago[Verifier]Remove API declaration that has never been implemented
HanSheng Zhang [Tue, 6 Dec 2022 09:59:02 +0000 (10:59 +0100)]
[Verifier]Remove API declaration that has never been implemented

Close https://github.com/llvm/llvm-project/issues/59244

Reviewed By: t.p.northover

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

20 months ago[CMake]Allow user specified CPack Options
HanSheng Zhang [Tue, 6 Dec 2022 09:55:17 +0000 (10:55 +0100)]
[CMake]Allow user specified CPack Options

This should allow downstream vendors to install multiple LLVM distributions in parallel.

Should we also patch the default values to allow multiple upstream llvm distribution?

Reviewed By: thieta

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

20 months ago[NFC] Remove const from return value of function
Juan Manuel MARTINEZ CAAMAÑO [Tue, 6 Dec 2022 09:22:52 +0000 (04:22 -0500)]
[NFC] Remove const from return value of function

20 months ago[RISCV] Generate .cfi_def_cfa_expression for RVV stack adjustment
Sergey Kachkov [Wed, 19 Oct 2022 15:12:33 +0000 (18:12 +0300)]
[RISCV] Generate .cfi_def_cfa_expression for RVV stack adjustment

Cannonical frame address after RVV stack adjustment is sp + StackSize +
RVVStackSize * vlenb, and since vlenb is unknown at compile-time (but it
is a constant for particular HW implementation), emit
.cfi_def_cfa_expression so libunwind can read VLENB CSR register at
run-time and obtain correct frame address.

Fixes https://github.com/llvm/llvm-project/issues/58356 (but additional
run-time support for reading CSR may be required)

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

20 months ago[clang] Add test for CWG600
Vlad Serebrennikov [Tue, 6 Dec 2022 09:42:07 +0000 (12:42 +0300)]
[clang] Add test for CWG600

P1787: //CWG600 is resolved by explaining that accessibility affects naming a member in the sense of the ODR.//
Wording: see changes to [class.access] p1 and p4.
Additional references: [[ http://eel.is/c++draft/basic.def.odr#8.sentence-2 | basic.def.odr/8 ]]: //A function is odr-used if it is named by a potentially-evaluated expression or conversion.//

Reviewed By: #clang-language-wg, aaron.ballman

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

20 months ago[Clang] make_cxx_dr_status download the issue list automatically
Corentin Jabot [Fri, 2 Dec 2022 18:35:13 +0000 (19:35 +0100)]
[Clang] make_cxx_dr_status download the issue list automatically

if none is provided

Reviewed By: aaron.ballman

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

20 months ago[clang] Mark CWG554 as N/A
Vlad Serebrennikov [Tue, 6 Dec 2022 09:38:38 +0000 (12:38 +0300)]
[clang] Mark CWG554 as N/A

P1787: //CWG554 is resolved by using the word “scope” instead of “declarative region”, consistent with its very common use in phrases like “namespace scope”.//

Reviewed By: #clang-language-wg, cor3ntin, aaron.ballman, shafik

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

20 months ago[LLVM][Release] Prevent empty runtime name in release script
David Spickett [Mon, 5 Dec 2022 11:53:06 +0000 (11:53 +0000)]
[LLVM][Release] Prevent empty runtime name in release script

Unlike projects, runtimes doesn't have a default set of names.
This means you get a leading space at the start, which gets converted
to a ';' giving ";<runtime name>;<runtime name>".

CMake then errors because the "" before the first ';' is treated
as a runtime name and of course it's not a valid name.

Fix this by removing the leading spaces from runtimes before we
insert the ';'.

Reviewed By: ldionne

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

20 months ago[Instcombine] Add baseline tests for logic-and/logic-or factorization; NFC
chenglin.bi [Tue, 6 Dec 2022 09:35:08 +0000 (17:35 +0800)]
[Instcombine] Add baseline tests for logic-and/logic-or factorization; NFC

20 months ago[clang] Add test for CWG405
Vlad Serebrennikov [Tue, 6 Dec 2022 09:33:56 +0000 (12:33 +0300)]
[clang] Add test for CWG405

P1787: //CWG405 is resolved by stating that argument-dependent lookup (sometimes) occurs after an ordinary unqualified lookup (making statements like “finding a variable prevents argument-dependent lookup” formally correct).//
Wording: see changes to [basic.lookup.argdep] p1 and p3

This issue seems a duplicate of CWG218, even though it is not officially recognized. A part of a test for CWG218 is reused here, adding cross-references.

Reviewed By: #clang-language-wg, aaron.ballman

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

20 months ago[CodeView] Add support for local S_CONSTANT records
Tobias Hieta [Tue, 22 Nov 2022 09:10:36 +0000 (10:10 +0100)]
[CodeView] Add support for local S_CONSTANT records

CodeView doesn't have the ability to represent variables
in other ways than as in registers or memory values, but
LLVM very often transforms simple values into constants,
consider this program:

int f () { int i = 123; return i; }

LLVM will transform `i` into a constant value and just
leave behind a llvm.dbg.value, this can't be represented
as a S_LOCAL record in CodeView. But we can represent it
as a S_CONSTANT record.

This patch checks if the location of a debug value is null,
then we will insert a S_CONSTANT record instead of a S_LOCAL
value with the flag "OptimizedAway".

In lld we then output the S_CONSTANT in the right scope, before
they where always inserted in the global stream, now we check
the scope before inserting it.

This has shown to improve debugging for our developers
internally.

Fixes to llvm/llvm-project#55958

Reviewed By: aganea

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

20 months ago[clang] Add test for CWG952
Vlad Serebrennikov [Tue, 6 Dec 2022 08:56:01 +0000 (11:56 +0300)]
[clang] Add test for CWG952

P1787: // [[ https://wg21.link/cwg952 | CWG952 ]] is resolved by refining the definition of “naming class” per Richard’s suggestion in [[ https://lists.isocpp.org/core/2020/09/9963.php | “CWG1621 and [class.static/2”]].//
Wording:
- [class.static]/2 removed;
- [class.access.base]/5 rephrased.

Currently behavior is the following: unqualified names undergo //unqualified name lookup// [1], which perform //unqualified search// in immediate scope [2]. This scope is the scope the definition of //naming class// [3] refers to. `A::I` is not //accessible// when named in classes `C` and `D` per [3]. In particular, the last item regarding base class ([class.access.base]/5.4) is not applicable, because class `A` is not //accessible// in both classes `C` and `D` per [4].

References:
1. [[ https://eel.is/c++draft/basic.lookup#unqual-4.sentence-2 | basic.lookup.unqual/4 ]]
2. [[ https://eel.is/c++draft/basic.lookup#unqual-3 | basic.lookup.unqual/3 ]]
3. [[ https://eel.is/c++draft/class.access#base-5.sentence-4 | class.access.base/5 ]]
4. [[ https://eel.is/c++draft/class.access#base-4 | class.access.base/4 ]]

Reviewed By: #clang-language-wg, erichkeane, aaron.ballman

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

20 months ago[MemCpyOpt] Use BatchAA when processing one instruction (NFCI)
Nikita Popov [Tue, 6 Dec 2022 09:14:00 +0000 (10:14 +0100)]
[MemCpyOpt] Use BatchAA when processing one instruction (NFCI)

While we can't use a single BatchAA instance for the entire
MemCpyOpt run without further justification, we can use BatchAA
while performing the queries related to a single instruction
(these will first perform some AA-based checks, and then modify
the IR only afterwards).

20 months ago[clang-format] Avoid breaking )( with BlockIndent
Gedare Bloom [Tue, 6 Dec 2022 08:58:30 +0000 (00:58 -0800)]
[clang-format] Avoid breaking )( with BlockIndent

The BracketAlignmentStyle BAS_BlockIndent was forcing breaks before a
closing right parenthesis yielding strange-looking results in case of
code structures that have a left parens immediately following a right
parens ")(" such as is seen with indirect function calls via function
pointers and with type casting.

Fixes 57250.
Fixes 58496.

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

20 months ago[libunwind][RISCV] Support reading of VLENB CSR register
Sergey Kachkov [Mon, 21 Nov 2022 08:48:26 +0000 (11:48 +0300)]
[libunwind][RISCV] Support reading of VLENB CSR register

Support reading of VLENB (vector byte length) control register, that can be
required for correct unwinding of RVV objects on stack.

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

20 months ago[DSE] Reuse BatchAA for MSSA clobber queries
Nikita Popov [Tue, 6 Dec 2022 08:43:42 +0000 (09:43 +0100)]
[DSE] Reuse BatchAA for MSSA clobber queries

This is not NFC because the DSE BatchAA is more powerful than the
default one due to EarliestEscape CaptureInfo, so this might
improve results in some cases.

20 months ago[flang] do not generate padding/truncation code when character length are equals
Jean Perier [Tue, 6 Dec 2022 08:33:48 +0000 (09:33 +0100)]
[flang] do not generate padding/truncation code when character length are equals

When generating character assignment operations, the generic code
generates some code to handle truncation and padding when the length
differ at runtime. A bypass already exists when the length are compile
time constant and match, but it was not used for the trivial case where
the RHS and LHS length is the same SSA value. In such case, even though,
the length is not know at compile time, it is known to be the same.

This will simplify the code creating character temporaries from a
variable in HLFIR that will use this assignment code.

Note that this probably has little impact on performance (llvm may be clever enough
to later catch that for us). But it makes the generated IR a lot more readable at
little cost.

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

20 months ago[AMDGPU] Fix GCNSubtarget::getMinNumVGPRs, add unit test to check consistency between...
Valery Pykhtin [Mon, 21 Nov 2022 16:15:32 +0000 (17:15 +0100)]
[AMDGPU] Fix GCNSubtarget::getMinNumVGPRs, add unit test to check consistency between GCNSubtarget's getMinNumVGPRs, getMaxNumVGPRs and getOccupancyWithNumVGPRs.

```
  /// \returns Minimum number of VGPRs that meets given number of waves per
  /// execution unit requirement supported by the subtarget.
  unsigned getMinNumVGPRs(unsigned WavesPerEU) const;

  /// \returns Maximum number of VGPRs that meets given number of waves per
  /// execution unit requirement supported by the subtarget.
  unsigned getMaxNumVGPRs(unsigned WavesPerEU) const;

  /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
  /// VGPRs
  unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
```

While working on RP tracking issues I noticed that getMinNumVGPRs return incorrect
values: the problem is large VGPR granule sizes on GFX10+ architectures. Some of the
occupancies aren't reachable because require the same amount of VGPR granules as others.
For example 19 waves occupancy on gfx1010 require the same amount of granules as 20 waves
so the resultng occupancy would be 20.

SGPRs have the same issue and even have inconsistency between getMaxNumSGPRs and getOccupancyWithNumSGPRs.
It will be addressed in the next patch.

Legend:
  # MinVGPR and MaxVGPR are values returned by getMinNumVGPRs and getMaxNumVGPRs for a given Occ.
  # (ONumber) is the value returned by getOccupancyWithNumVGPRs for a given MinVGPR or MaxVGPR.
  # R means range problem: MinVGPR should be less than MaxVGPR and both should refer to the same occupancy.

Unit test output without the fix:
```
./build/unittests/Target/AMDGPU/AMDGPUTests --gtest_filter=AMDGPU.TestVGPRLimitsPerOccupancy --print-cpu-reg-limits

 gfx90a gfx940:
Occ    MinVGPR        MaxVGPR
  8        0 (O8)     64  (O8)
  7       65 (O7)     72  (O7)
  6       73 (O6)     80  (O6)
  5       81 (O5)     96  (O5)
  4       97 (O4)     128 (O4)
  3      129 (O3)     168 (O3)
  2      169 (O2)     256 (O2)
  1      257 (O1)     512 (O1)

 gfx600 gfx600 gfx601 gfx601 gfx601 gfx602 gfx602 gfx602 gfx700 gfx700 gfx701 gfx701 gfx702 gfx703 gfx703 gfx703 gfx704 gfx704 gfx705 gfx801 gfx801 gfx802 gfx802 gfx802 gfx803 gfx803 gfx803 gfx803 gfx805 gfx805 gfx810 gfx810 gfx900 gfx902 gfx904 gfx906 gfx908 gfx909 gfx90c:
Occ    MinVGPR        MaxVGPR
 10        0 (O10)    24  (O10)
  9       25 (O9)     28  (O9)
  8       29 (O8)     32  (O8)
  7       33 (O7)     36  (O7)
  6       37 (O6)     40  (O6)
  5       41 (O5)     48  (O5)
  4       49 (O4)     64  (O4)
  3       65 (O3)     84  (O3)
  2       85 (O2)     128 (O2)
  1      129 (O1)     256 (O1)

 gfx1030w64 gfx1031w64 gfx1032w64 gfx1033w64 gfx1034w64 gfx1035w64 gfx1036w64 gfx1102w64 gfx1103w64:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    32  (O16)
 15       33 (O12) R  32  (O16)
 14       33 (O12) R  32  (O16)
 13       33 (O12) R  32  (O16)
 12       33 (O12)    40  (O12)
 11       41 (O10) R  40  (O12)
 10       41 (O10)    48  (O10)
  9       49 (O9)     56  (O9)
  8       57 (O8)     64  (O8)
  7       65 (O7)     72  (O7)
  6       73 (O6)     80  (O6)
  5       81 (O5)     96  (O5)
  4       97 (O4)     128 (O4)
  3      129 (O3)     168 (O3)
  2      169 (O2)     256 (O2)
  1      256 (O2) R   256 (O2)

 gfx1100w64 gfx1101w64:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    48  (O16)
 15       49 (O12) R  48  (O16)
 14       49 (O12) R  48  (O16)
 13       49 (O12) R  48  (O16)
 12       49 (O12)    60  (O12)
 11       61 (O10) R  60  (O12)
 10       61 (O10)    72  (O10)
  9       73 (O9)     84  (O9)
  8       85 (O8)     96  (O8)
  7       97 (O7)     108 (O7)
  6      109 (O6)     120 (O6)
  5      121 (O5)     144 (O5)
  4      145 (O4)     192 (O4)
  3      193 (O3)     252 (O3)
  2      253 (O2)     256 (O2)
  1      256 (O2) R   256 (O2)

 gfx1030w32 gfx1031w32 gfx1032w32 gfx1033w32 gfx1034w32 gfx1035w32 gfx1036w32 gfx1102w32 gfx1103w32:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    64  (O16)
 15       65 (O12) R  64  (O16)
 14       65 (O12) R  64  (O16)
 13       65 (O12) R  64  (O16)
 12       65 (O12)    80  (O12)
 11       81 (O10) R  80  (O12)
 10       81 (O10)    96  (O10)
  9       97 (O9)     112 (O9)
  8      113 (O8)     128 (O8)
  7      129 (O7)     144 (O7)
  6      145 (O6)     160 (O6)
  5      161 (O5)     192 (O5)
  4      193 (O4)     256 (O4)
  3      256 (O4) R   256 (O4)
  2      256 (O4) R   256 (O4)
  1      256 (O4) R   256 (O4)

 gfx1100w32 gfx1101w32:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    96  (O16)
 15       97 (O12) R  96  (O16)
 14       97 (O12) R  96  (O16)
 13       97 (O12) R  96  (O16)
 12       97 (O12)    120 (O12)
 11      121 (O10) R  120 (O12)
 10      121 (O10)    144 (O10)
  9      145 (O9)     168 (O9)
  8      169 (O8)     192 (O8)
  7      193 (O7)     216 (O7)
  6      217 (O6)     240 (O6)
  5      241 (O5)     256 (O5)
  4      256 (O5) R   256 (O5)
  3      256 (O5) R   256 (O5)
  2      256 (O5) R   256 (O5)
  1      256 (O5) R   256 (O5)

 gfx1010w64 gfx1011w64 gfx1012w64 gfx1013w64:
Occ    MinVGPR        MaxVGPR
 20        0 (O20)    24  (O20)
 19       25 (O18) R  24  (O20)
 18       25 (O18)    28  (O18)
 17       29 (O16) R  28  (O18)
 16       29 (O16)    32  (O16)
 15       33 (O14) R  32  (O16)
 14       33 (O14)    36  (O14)
 13       37 (O12) R  36  (O14)
 12       37 (O12)    40  (O12)
 11       41 (O11)    44  (O11)
 10       45 (O10)    48  (O10)
  9       49 (O9)     56  (O9)
  8       57 (O8)     64  (O8)
  7       65 (O7)     72  (O7)
  6       73 (O6)     84  (O6)
  5       85 (O5)     100 (O5)
  4      101 (O4)     128 (O4)
  3      129 (O3)     168 (O3)
  2      169 (O2)     256 (O2)
  1      256 (O2) R   256 (O2)

 gfx1010w32 gfx1011w32 gfx1012w32 gfx1013w32:
Occ    MinVGPR        MaxVGPR
 20        0 (O20)    48  (O20)
 19       49 (O18) R  48  (O20)
 18       49 (O18)    56  (O18)
 17       57 (O16) R  56  (O18)
 16       57 (O16)    64  (O16)
 15       65 (O14) R  64  (O16)
 14       65 (O14)    72  (O14)
 13       73 (O12) R  72  (O14)
 12       73 (O12)    80  (O12)
 11       81 (O11)    88  (O11)
 10       89 (O10)    96  (O10)
  9       97 (O9)     112 (O9)
  8      113 (O8)     128 (O8)
  7      129 (O7)     144 (O7)
  6      145 (O6)     168 (O6)
  5      169 (O5)     200 (O5)
  4      201 (O4)     256 (O4)
  3      256 (O4) R   256 (O4)
  2      256 (O4) R   256 (O4)
  1      256 (O4) R   256 (O4)
```

After the fix:
```
 gfx90a gfx940:
Occ    MinVGPR        MaxVGPR
  8        0 (O8)     64  (O8)
  7       65 (O7)     72  (O7)
  6       73 (O6)     80  (O6)
  5       81 (O5)     96  (O5)
  4       97 (O4)     128 (O4)
  3      129 (O3)     168 (O3)
  2      169 (O2)     256 (O2)
  1      257 (O1)     512 (O1)

 gfx600 gfx600 gfx601 gfx601 gfx601 gfx602 gfx602 gfx602 gfx700 gfx700 gfx701 gfx701 gfx702 gfx703 gfx703 gfx703 gfx704 gfx704 gfx705 gfx801 gfx801 gfx802 gfx802 gfx802 gfx803 gfx803 gfx803 gfx803 gfx805 gfx805 gfx810 gfx810 gfx900 gfx902 gfx904 gfx906 gfx908 gfx909 gfx90c:
Occ    MinVGPR        MaxVGPR
 10        0 (O10)    24  (O10)
  9       25 (O9)     28  (O9)
  8       29 (O8)     32  (O8)
  7       33 (O7)     36  (O7)
  6       37 (O6)     40  (O6)
  5       41 (O5)     48  (O5)
  4       49 (O4)     64  (O4)
  3       65 (O3)     84  (O3)
  2       85 (O2)     128 (O2)
  1      129 (O1)     256 (O1)

 gfx1030w64 gfx1031w64 gfx1032w64 gfx1033w64 gfx1034w64 gfx1035w64 gfx1036w64 gfx1102w64 gfx1103w64:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    32  (O16)
 15        0 (O16)    32  (O16)
 14        0 (O16)    32  (O16)
 13        0 (O16)    32  (O16)
 12       33 (O12)    40  (O12)
 11       33 (O12)    40  (O12)
 10       41 (O10)    48  (O10)
  9       49 (O9)     56  (O9)
  8       57 (O8)     64  (O8)
  7       65 (O7)     72  (O7)
  6       73 (O6)     80  (O6)
  5       81 (O5)     96  (O5)
  4       97 (O4)     128 (O4)
  3      129 (O3)     168 (O3)
  2      169 (O2)     256 (O2)
  1      169 (O2)     256 (O2)

 gfx1100w64 gfx1101w64:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    48  (O16)
 15        0 (O16)    48  (O16)
 14        0 (O16)    48  (O16)
 13        0 (O16)    48  (O16)
 12       49 (O12)    60  (O12)
 11       49 (O12)    60  (O12)
 10       61 (O10)    72  (O10)
  9       73 (O9)     84  (O9)
  8       85 (O8)     96  (O8)
  7       97 (O7)     108 (O7)
  6      109 (O6)     120 (O6)
  5      121 (O5)     144 (O5)
  4      145 (O4)     192 (O4)
  3      193 (O3)     252 (O3)
  2      253 (O2)     256 (O2)
  1      253 (O2)     256 (O2)

 gfx1030w32 gfx1031w32 gfx1032w32 gfx1033w32 gfx1034w32 gfx1035w32 gfx1036w32 gfx1102w32 gfx1103w32:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    64  (O16)
 15        0 (O16)    64  (O16)
 14        0 (O16)    64  (O16)
 13        0 (O16)    64  (O16)
 12       65 (O12)    80  (O12)
 11       65 (O12)    80  (O12)
 10       81 (O10)    96  (O10)
  9       97 (O9)     112 (O9)
  8      113 (O8)     128 (O8)
  7      129 (O7)     144 (O7)
  6      145 (O6)     160 (O6)
  5      161 (O5)     192 (O5)
  4      193 (O4)     256 (O4)
  3      193 (O4)     256 (O4)
  2      193 (O4)     256 (O4)
  1      193 (O4)     256 (O4)

 gfx1100w32 gfx1101w32:
Occ    MinVGPR        MaxVGPR
 16        0 (O16)    96  (O16)
 15        0 (O16)    96  (O16)
 14        0 (O16)    96  (O16)
 13        0 (O16)    96  (O16)
 12       97 (O12)    120 (O12)
 11       97 (O12)    120 (O12)
 10      121 (O10)    144 (O10)
  9      145 (O9)     168 (O9)
  8      169 (O8)     192 (O8)
  7      193 (O7)     216 (O7)
  6      217 (O6)     240 (O6)
  5      241 (O5)     256 (O5)
  4      241 (O5)     256 (O5)
  3      241 (O5)     256 (O5)
  2      241 (O5)     256 (O5)
  1      241 (O5)     256 (O5)

 gfx1010w64 gfx1011w64 gfx1012w64 gfx1013w64:
Occ    MinVGPR        MaxVGPR
 20        0 (O20)    24  (O20)
 19        0 (O20)    24  (O20)
 18       25 (O18)    28  (O18)
 17       25 (O18)    28  (O18)
 16       29 (O16)    32  (O16)
 15       29 (O16)    32  (O16)
 14       33 (O14)    36  (O14)
 13       33 (O14)    36  (O14)
 12       37 (O12)    40  (O12)
 11       41 (O11)    44  (O11)
 10       45 (O10)    48  (O10)
  9       49 (O9)     56  (O9)
  8       57 (O8)     64  (O8)
  7       65 (O7)     72  (O7)
  6       73 (O6)     84  (O6)
  5       85 (O5)     100 (O5)
  4      101 (O4)     128 (O4)
  3      129 (O3)     168 (O3)
  2      169 (O2)     256 (O2)
  1      169 (O2)     256 (O2)

 gfx1010w32 gfx1011w32 gfx1012w32 gfx1013w32:
Occ    MinVGPR        MaxVGPR
 20        0 (O20)    48  (O20)
 19        0 (O20)    48  (O20)
 18       49 (O18)    56  (O18)
 17       49 (O18)    56  (O18)
 16       57 (O16)    64  (O16)
 15       57 (O16)    64  (O16)
 14       65 (O14)    72  (O14)
 13       65 (O14)    72  (O14)
 12       73 (O12)    80  (O12)
 11       81 (O11)    88  (O11)
 10       89 (O10)    96  (O10)
  9       97 (O9)     112 (O9)
  8      113 (O8)     128 (O8)
  7      129 (O7)     144 (O7)
  6      145 (O6)     168 (O6)
  5      169 (O5)     200 (O5)
  4      201 (O4)     256 (O4)
  3      201 (O4)     256 (O4)
  2      201 (O4)     256 (O4)
  1      201 (O4)     256 (O4)
```

Reviewed By: #amdgpu, arsenm

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

20 months ago[mlir] Use std::nullopt instead of None in comments (NFC)
Kazu Hirata [Tue, 6 Dec 2022 08:03:44 +0000 (00:03 -0800)]
[mlir] Use std::nullopt instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[BOLT] Fix blocks layout reverse iterators
Vladislav Khmelevsky [Mon, 5 Dec 2022 16:40:32 +0000 (20:40 +0400)]
[BOLT] Fix blocks layout reverse iterators

Use container's reverse iterators

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

20 months ago[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 07:55:23 +0000 (23:55 -0800)]
[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[llvm] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 07:50:04 +0000 (23:50 -0800)]
[llvm] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[mlir] Add `replaceAllUsesExcept` to rewriter
Diego Caballero [Tue, 6 Dec 2022 07:30:28 +0000 (07:30 +0000)]
[mlir] Add `replaceAllUsesExcept` to rewriter

This patch adds `replaceAllUsesExcept` to the rewriter class.
The implementation is copy-pasted from Value + calling
`updateRootInPlace` to notify the listeners about the
corresponding IR changes.

Reviewed By: Mogball

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

20 months ago[lldb] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 07:32:18 +0000 (23:32 -0800)]
[lldb] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[MemorySSA] Use BatchAA for clobber walker
Nikita Popov [Mon, 5 Dec 2022 15:10:33 +0000 (16:10 +0100)]
[MemorySSA] Use BatchAA for clobber walker

While MemorySSA use optimization was already using BatchAA, the
publicly exposed MSSA walkers were using plain AAResults. This is
not great, because it is expected that clobber walking will make
repeated AA queries.

This patch makes the clobber API accept a BatchAAResults instance.
The plain APIs are kept as wrappers and will create a BatchAAResults
instance for the duration of the query. In the future, the explicit
BatchAAResults arguments will be used to share AA results across
queries, not just within one query.

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

20 months agoAdded connection to the library with name "re".
dbakunevich [Tue, 6 Dec 2022 07:24:57 +0000 (14:24 +0700)]
Added connection to the library with name "re".

Fixed a bug that the "re" library was used in
this python file, but there was no import of it.

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

20 months ago[TableGen] llvm::Optional => std::optional
Fangrui Song [Tue, 6 Dec 2022 07:21:02 +0000 (07:21 +0000)]
[TableGen] llvm::Optional => std::optional

20 months ago[lldb] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 07:18:15 +0000 (23:18 -0800)]
[lldb] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[RISCV][NFC] Add test coverage for insertelement/extractelement of widen vector type.
jacquesguan [Sun, 9 Oct 2022 07:28:42 +0000 (15:28 +0800)]
[RISCV][NFC] Add test coverage for insertelement/extractelement of widen vector type.

Reviewed By: reames

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

20 months ago[PartialInlining] Enable recursive partial inlining.
Mark Lacey [Wed, 19 Oct 2022 20:20:56 +0000 (13:20 -0700)]
[PartialInlining] Enable recursive partial inlining.

It seems unnecessarily limiting to disallow recursive partial
inlining, and there are clearly cases where it can benefit
code by avoiding a function call and potentially enabling
other transformations like dead argument elimination
in cases where an argument is only used prior to the early-out
test at the top of the function.

The pass already properly rewrites the recursive calls
within the body of the freshly cloned function, so the only
change here is removing the bail-out when recursion is
detected.

Reviewed By: efriedma

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

20 months ago[msan][CodeGen] Set noundef for C return value
Vitaly Buka [Mon, 5 Dec 2022 02:59:01 +0000 (18:59 -0800)]
[msan][CodeGen] Set noundef for C return value

Msan needs noundef consistency between interface and implementation. If
we call C++ from C we can have noundef on C++ side, and no noundef on
caller C side, noundef implementation will not set TLS for return value,
no noundef caller will expect it. Then we have false reports in msan.

The workaround could be set TLS to zero even for noundef return values.
However if we do that always it will increase binary size by about 10%.
If we do that selectively we need to handle "address is taken"
functions, any non local functions, and probably all function which have
musttail callers. Which is still a lot.

The existing implementation of HasStrictReturn refers to C standard as
the reason not enforcing noundef. I believe it applies only to the case
when return statement is omitted. Testing on Google codebase I never see
such cases, however I've see tens of cases where C code returns actual
uninitialized variables, but we ignore that it because of "omitted
return" case.

So this patch will:
1. fix false-positives with TLS missmatch.
2. detect bugs returning uninitialized variables for C as well.
3. report "omitted return" cases stricter than C, which is already a
   warning and very likely a bug in a code anyway.

Reviewed By: kda

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

20 months ago[Support] Include optional instead of None.h
Kazu Hirata [Tue, 6 Dec 2022 06:56:24 +0000 (22:56 -0800)]
[Support] Include optional instead of None.h

SMLoc uses std::nullopt_t, so it should include optional rather than
None.h.

20 months ago[lldb] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 06:43:53 +0000 (22:43 -0800)]
[lldb] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months agomlir/tosa: move tosa.pad from Linalg to Tensor conversion
Ramkumar Ramachandra [Thu, 1 Dec 2022 10:48:24 +0000 (11:48 +0100)]
mlir/tosa: move tosa.pad from Linalg to Tensor conversion

Since tosa.pad is lowered strictly to artih and tensor ops, move
ConvertPad from TosaToLinalg to TosaToTensor, benefitting non-Linalg
Tosa targets. TensorToLinalg exists, and is trivial, so nothing is lost.

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D139091

20 months ago[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 06:37:22 +0000 (22:37 -0800)]
[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 05:49:31 +0000 (21:49 -0800)]
[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months ago[lldb] Use std::nullopt instead of None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 04:54:05 +0000 (20:54 -0800)]
[lldb] Use std::nullopt instead of None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

20 months agoRemove "using llvm::None;" in *.cpp
Kazu Hirata [Tue, 6 Dec 2022 04:39:10 +0000 (20:39 -0800)]
Remove "using llvm::None;" in *.cpp

These .cpp files do not use llvm::None anymore.

Since these are not header files, we can remove them pretty safely
without deprecating them first.

20 months ago[mlir] UnsignedWhenEquivalent ignore dead code
Jeff Niu [Tue, 6 Dec 2022 04:00:38 +0000 (20:00 -0800)]
[mlir] UnsignedWhenEquivalent ignore dead code

The pass was not checking for uninitialized states due to dead code.
This patch also makes LLVMFuncOp correctly return a null body when it is
external.

Fixes #58807

Depends on D139388

Reviewed By: rriddle

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

20 months ago[mlir][llvm] Mark LLVMReturnOp as ReturnLike
Jeff Niu [Tue, 6 Dec 2022 03:34:14 +0000 (19:34 -0800)]
[mlir][llvm] Mark LLVMReturnOp as ReturnLike

Reviewed By: rriddle

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

20 months ago[RISCV] Fold vector binary operatrion into select with identity constant.
jacquesguan [Wed, 21 Sep 2022 07:51:18 +0000 (15:51 +0800)]
[RISCV] Fold vector binary operatrion into select with identity constant.

This patch implements shouldFoldSelectWithIdentityConstant for RISCV. It would try to generate vmerge after the binary instruction and let them folded to maksed instruction later.

Reviewed By: craig.topper

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

20 months ago[mlir][ods] Allow ArrayOfAttr implicit conversion to ArrayRef
Jeff Niu [Mon, 5 Dec 2022 21:15:27 +0000 (13:15 -0800)]
[mlir][ods] Allow ArrayOfAttr implicit conversion to ArrayRef

Reviewed By: rriddle

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

20 months ago[X86][clang] Lift _BitInt() supported max width.
Freddy Ye [Tue, 6 Dec 2022 02:19:12 +0000 (10:19 +0800)]
[X86][clang] Lift _BitInt() supported max width.

Reviewed By: mgehre-amd

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

20 months ago[OpenMP] Let predefined allocator fallback to default instead of returning null
Nawrin Sultana [Mon, 5 Dec 2022 23:53:54 +0000 (17:53 -0600)]
[OpenMP] Let predefined allocator fallback to default instead of returning null

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

20 months agoCallGraph: Fix IgnoreAssumeLikeCalls option to Function::hasAddressTaken
Matt Arsenault [Fri, 2 Dec 2022 23:30:19 +0000 (18:30 -0500)]
CallGraph: Fix IgnoreAssumeLikeCalls option to Function::hasAddressTaken

This was added in 29e2d9461a91b and likely never worked in a useful
way.

The test added for it fails when converted to opaque pointers, since
the lifetime intrinsic now directly uses the address. The code was
only trying to handle a user indirectly through a bitcast
instruction. That would never have been useful; a bitcast of a global
value would be folded to a ConstantExpr cast.

I also don't understand why it was special casing use_empty on the
cast. Relax the check to be either BitCastOperator or
AddrSpaceCastOperator. In practice, BitCastOperator won't appear
today.

I believe the change in parallel_deletion_cg_update is a correct
improvement but I didn't fully follow it. .omp_outlined..0 is used in
a constant expression cast to a call which ends up getting deleted.

20 months ago[RISCV][test] Add pre-commit test for D131551.
jacquesguan [Tue, 16 Aug 2022 07:45:28 +0000 (15:45 +0800)]
[RISCV][test] Add pre-commit test for D131551.

Reviewed By: craig.topper

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

20 months ago[lldb][Test] TestRerunAndExpr.py: skip on Windows
Michael Buch [Tue, 6 Dec 2022 02:13:59 +0000 (02:13 +0000)]
[lldb][Test] TestRerunAndExpr.py: skip on Windows

On Windows rebuilding the binary isn't enough to unload it
on progrem restart. But the assumption of the test is that on
program re-run LLDB destroys and replaces the old module with
the newly built version. One will have to try hard to evict the
module from the ModuleList (possibly including a call to
`SBDebugger::MemoryPressureDetected`.

See D138724

20 months ago[llvm-objcopy] Reland "Fix --add-section when section contain empty bytes"
Guilhem [Tue, 6 Dec 2022 02:04:45 +0000 (18:04 -0800)]
[llvm-objcopy] Reland "Fix --add-section when section contain empty bytes"

Implicit cast between char* and StringRef when writing sections.

Reproduce:
```
$> llvm-objcopy --dump-section=name=name.data out.wasm
$> llvm-objcopy --remove-section=name out.wasm out_no_name.wasm
$> llvm-objcopy --add-section=name=name.data out_no_name.wasm out_new_name.wasm

```

Reviewed By: dschuff

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

20 months agoDon't use root logger at import time
Stella Laurenzo [Tue, 6 Dec 2022 01:42:38 +0000 (17:42 -0800)]
Don't use root logger at import time

At import time, these calls to `logging.debug()` implicitly call `logging.basicConfig` (https://docs.python.org/3/library/logging.html#logging.basicConfig), setting logging config for the whole project which cannot then be overwritten later. For instance, consider the following test script:

```
import logging
import jax

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
logger.info('info')
```
This should log out `'info'`, but because when `import jax` is called, this `_mlir_lib/__init__.py` file is run and a `logging.debug` is called, calling `logging.basicConfig`, my `logging.basicConfig(level=logging.INFO)` does nothing.

Fix: instead of using root logger, use a module level logger.

Found in this issue: https://github.com/google/jax/issues/12526

Reviewed By: stellaraccident

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

20 months ago[NFC][SimplifyCFG] Add few more fold-branch-to-common-dest tests
Roman Lebedev [Tue, 6 Dec 2022 01:16:13 +0000 (04:16 +0300)]
[NFC][SimplifyCFG] Add few more fold-branch-to-common-dest tests

20 months agoDebugInfo: Add support for new DWARFv5 language codes
David Blaikie [Tue, 6 Dec 2022 01:13:44 +0000 (01:13 +0000)]
DebugInfo: Add support for new DWARFv5 language codes

20 months ago[RISCV]Keep (select c, 0/-1, X) during PerformDAGCombine
ChunyuLiao [Tue, 6 Dec 2022 01:10:00 +0000 (09:10 +0800)]
[RISCV]Keep (select c, 0/-1, X) during PerformDAGCombine

D135833, lowerSelect: (select C, -1/0, X) -> or/and
Keep (select c, 0/-1, X), thus making better use of lowerSelect to eliminate branch instructions.

Reviewed By: craig.topper

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

20 months agoRevert "[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a Spars...
Stella Stamenova [Tue, 6 Dec 2022 01:20:01 +0000 (17:20 -0800)]
Revert "[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorDescriptor class."

This reverts commit 8a7e69d145ff72e7e4fc10ce6b81c3aa4794201c.

This broke the windows mlir buildbot: https://lab.llvm.org/buildbot/#/builders/13/builds/29257

20 months ago[mlir][sparse] Cleaning up the dim/lvl distinction in SparseTensorConversion
wren romano [Fri, 2 Dec 2022 03:08:45 +0000 (19:08 -0800)]
[mlir][sparse] Cleaning up the dim/lvl distinction in SparseTensorConversion

This change cleans up the conversion pass re the "dim"-vs-"lvl" and "sizes"-vs-"shape" distinctions of the runtime. A quick synopsis includes:

* Adds new `SparseTensorStorageBase::getDimSize` method, with `sparseDimSize` wrapper in SparseTensorRuntime.h, and `genDimSizeCall` generator in SparseTensorConversion.cpp
* Changes `genLvlSizeCall` to perform no logic, just generate the function call.
* Adds `createOrFold{Dim,Lvl}Call` functions to handle the logic of replacing `gen{Dim,Lvl}SizeCall` with constants whenever possible. The `createOrFoldDimCall` function replaces the old `sizeFromPtrAtDim`.
* Adds `{get,fill}DimSizes` functions for iterating `createOrFoldDimCall` across the whole type. These functions replace the old `sizesFromPtr`.
* Adds `{get,fill}DimShape` functions for lowering a `ShapedType` into constants. These functions replace the old `sizesFromType`.
* Changes the `DimOp` rewrite to do the right thing.
* Changes the `ExpandOp` rewrite to compute the proper expansion size.

Depends On D138365

Reviewed By: aartbik

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

20 months agoRevert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in...
Roman Lebedev [Tue, 6 Dec 2022 00:49:23 +0000 (03:49 +0300)]
Revert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`"

Breaks cmake regeneration for me:
```
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda.nextgen" which requires target "PluginInterface" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64.nextgen" which requires target "PluginInterface" that is not in any export set.
```

This reverts commit 08c4081bd3605e1b01a7ccd6accc9052c8966250.

20 months ago[NFC][PPC] Autogenerate checklines in ppc-ctr-dead-code.ll to simplify update
Roman Lebedev [Tue, 6 Dec 2022 00:45:50 +0000 (03:45 +0300)]
[NFC][PPC] Autogenerate checklines in ppc-ctr-dead-code.ll to simplify update

20 months ago[NFC][LICM] Autogenerate checklines for one function to simplify update
Roman Lebedev [Tue, 6 Dec 2022 00:45:12 +0000 (03:45 +0300)]
[NFC][LICM] Autogenerate checklines for one function to simplify update

20 months ago[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins...
Shilei Tian [Tue, 6 Dec 2022 00:46:04 +0000 (19:46 -0500)]
[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`

This patch uses `add_llvm_library` to build the target `PluginInterface` since it can handle LLVM dependences much better. One temporary drawback of using this is that currently LLVM CMake macro doesn't support object libraries very well (there was a try a couple years ago but it was reverted later https://github.com/llvm/llvm-project/commit/29e57229497711a3a294f437b59afa6ddc36a3d8). After switching to that, `CXX_VISIBILITY_PRESET` can not be set correctly, which can cause runtime error that a function call from one plugin could go to another. As a consequence, `PluginInterface` is built as a static library for now. I have asked the question in CMake community (https://discourse.cmake.org/t/set-target-properties-doesnt-work-properly/7016). Once that issue is solved, I'll switch it back to object library. It is not necessarily too bad to use static library, especially `BUILDTREE_ONLY` is already set such that `PluginInterface.a` will not be installed.

Reviewed By: jhuber6

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

20 months ago[NFC][SimplifyCFG] Add one more fold-branch-to-common-dest test
Roman Lebedev [Mon, 5 Dec 2022 23:13:50 +0000 (02:13 +0300)]
[NFC][SimplifyCFG] Add one more fold-branch-to-common-dest test

20 months ago[CodeView] Don't generate dummy unnamed strcut/class/union type.
Zequan Wu [Mon, 5 Dec 2022 23:58:28 +0000 (07:58 +0800)]
[CodeView] Don't generate dummy unnamed strcut/class/union type.

20 months ago[RISCV] Remove some RISCVMatInt early exits.
Craig Topper [Tue, 6 Dec 2022 00:29:16 +0000 (16:29 -0800)]
[RISCV] Remove some RISCVMatInt early exits.

These were early exiting if we replaced a sequence with a 2 instruction
sequence since that is the best we could do. All the later optimizations
only occur if the sequence is more than 2 instructions so this wasn't a
functional check.

At best it helps the compiler generate better code, but I don't think
that was analyzed when it was added. Remove it to simplify the code.

20 months ago[Polly] Use std::nullopt to unbreak build.
Michael Kruse [Mon, 5 Dec 2022 23:27:10 +0000 (17:27 -0600)]
[Polly] Use std::nullopt to unbreak build.

20 months ago[Driver][test] Fix test by creating empty archive instead of empty file
Jacob Lambert [Wed, 2 Nov 2022 17:38:17 +0000 (10:38 -0700)]
[Driver][test] Fix test by creating empty archive instead of empty file

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

20 months agoRevert "[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers."
Artem Dergachev [Mon, 5 Dec 2022 23:38:40 +0000 (15:38 -0800)]
Revert "[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers."

This reverts commit 200007ec85f81122fd260a4e68308e54607ca37a.

20 months agoReland "[llvm] Teach FastISel for AArch64 about tagged globals"
Leonard Chan [Mon, 5 Dec 2022 23:26:50 +0000 (23:26 +0000)]
Reland "[llvm] Teach FastISel for AArch64 about tagged globals"

This reverts commit aacf17aa0ca8a67efc0ad2d4cfd90e551b5d6a7f.

Fixed by using the right register class for the movk.

20 months ago[gn build] Port 200007ec85f8
LLVM GN Syncbot [Mon, 5 Dec 2022 23:13:55 +0000 (23:13 +0000)]
[gn build] Port 200007ec85f8

20 months ago[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers.
Artem Dergachev [Fri, 2 Dec 2022 20:58:56 +0000 (12:58 -0800)]
[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers.

This is the initial commit for -Wunsafe-buffer-usage, a warning that helps
codebases (especially modern C++ codebases) transition away from raw buffer
pointers.

The warning is implemented in libAnalysis as it's going to become a non-trivial
analysis, mostly the fixit part where we try to figure out if we understand
a variable's use pattern well enough to suggest a safe container/view
as a replacement. Some parts of this analsysis may eventually prove useful
for any similar fixit machine that tries to change types of variables.

The warning is disabled by default.

RFC/discussion in https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734

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

20 months agoIncrease search for kernel image from 32MB to 128MB
Jason Molenda [Wed, 30 Nov 2022 20:28:47 +0000 (12:28 -0800)]
Increase search for kernel image from 32MB to 128MB

DynamicLoaderDarwinKernel::SearchForKernelNearPC() searches for a
Darwin kernel mach-o header starting at $pc and working backwards,
stopping on the first memory read error encountered.  The kernel,
and the kexts linked in to the kernel, have grown over the years
and the original 32MB scan limit is giving a high chance of failing
to find the kernel if we're in a random kext.

In non-kernel environments, firmware and bare board typically, we
will hit a memory read error on an unmapped page quickly so this
doesn't add a lot of random memory read requests in those environments.

We only check at one megabyte boundaries, so worst case this is 128
reads at the start of a gdb-remote connection.  The check for a
memory read error & stopping was a more recent addition (a few years
ago), so I kept the scan region a bit small.

20 months ago[mlir] List more elementwise ops in VectorToGPU MMA conversion
Lei Zhang [Mon, 5 Dec 2022 22:40:39 +0000 (22:40 +0000)]
[mlir] List more elementwise ops in VectorToGPU MMA conversion

Reviewed By: ThomasRaoux

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

20 months agoRevert "[llvm] Teach FastISel for AArch64 about tagged globals"
Leonard Chan [Mon, 5 Dec 2022 22:45:04 +0000 (22:45 +0000)]
Revert "[llvm] Teach FastISel for AArch64 about tagged globals"

This reverts commit 7358c29a42714eb8d7d7bcdb58688d20430689e4.

This broke an upstream builder:
https://lab.llvm.org/buildbot/#/builders/16/builds/39356

20 months ago[lldb-tests] Force system's libcxx on tests failing with debug symbols
Felipe de Azevedo Piovezan [Mon, 5 Dec 2022 20:49:13 +0000 (15:49 -0500)]
[lldb-tests] Force system's libcxx on tests failing with debug symbols

The tests in this patch expose failures of LLDBs expression evaluator
when a standard library is compiled with debug symbols. This is the case
for RelWithDebugInfo builds of llvm-project (with libcxx).

Until these bugs are fixed, we force these tests to use the system's
standard library.

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

20 months ago[mlir][spirv] Add extensions implied by SPIR-V 1.6
Jakub Kuderski [Mon, 5 Dec 2022 22:40:29 +0000 (17:40 -0500)]
[mlir][spirv] Add extensions implied by SPIR-V 1.6

This adds existing extensions as implied by SPIR-V 1.6.

Also clean up the surrounding code.

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

Reviewed By: antiagainst

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

20 months ago[mlir][spirv] Add GPU subgroup MMA to spirv.MMAMatrixTimesScalar
Lei Zhang [Mon, 5 Dec 2022 22:18:34 +0000 (22:18 +0000)]
[mlir][spirv] Add GPU subgroup MMA to spirv.MMAMatrixTimesScalar

Along the way, make the default pattern fail instead of crashing
when an elementwise op is not supported yet.

Reviewed By: kuhar

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

20 months agoRevert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"
Leonard Chan [Mon, 5 Dec 2022 22:20:51 +0000 (22:20 +0000)]
Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"

This reverts commit bec8a372fc0db95852748691c0f4933044026b25.

This causes many of these errors to appear when rebuilding runtimes part
of fuchsia's toolchain:

ld.lld: error:
/usr/local/google/home/paulkirth/llvm-upstream/build/lib/x86_64-unknown-linux-gnu/libunwind.a(libunwind.cpp.o)
is incompatible with elf64-x86-64

This can be reproduced by making a complete toolchain, saving any source
file with no changes, then rerunning ninja distribution.

20 months ago[llvm] Teach FastISel for AArch64 about tagged globals
Leonard Chan [Mon, 5 Dec 2022 22:16:55 +0000 (22:16 +0000)]
[llvm] Teach FastISel for AArch64 about tagged globals

This addresses https://github.com/llvm/llvm-project/issues/57750. For
some globals, the tag wasn't propagated correctly because the necessary
movk wasn't emitted sometimes.

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

20 months ago[mlir][spirv] Fix spirv.MatrixTimesScalar for cooperative matrix
Lei Zhang [Mon, 5 Dec 2022 22:03:54 +0000 (22:03 +0000)]
[mlir][spirv] Fix spirv.MatrixTimesScalar for cooperative matrix

spirv.MatrixTimesScalar is allowed to use cooperative matrix.

Reviewed By: kuhar

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

20 months ago[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorD...
Peiming Liu [Thu, 24 Nov 2022 00:42:43 +0000 (00:42 +0000)]
[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorDescriptor class.

This patch abstracts sparse tensor memory scheme into a SparseTensorDescriptor class. Previously, the field accesses are performed in a relatively error-prone way, this patch hides the hairy details behind a SparseTensorDescriptor class to allow users access sparse tensor fields in a more cohesive way.

Reviewed By: aartbik

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

20 months ago[mlir][tensor] Implement TilingInterface for tensor.pack op.
Hanhan Wang [Thu, 24 Nov 2022 02:07:12 +0000 (18:07 -0800)]
[mlir][tensor] Implement TilingInterface for tensor.pack op.

We can compute the offsets and sizes for the slice of input because the
iteration domain is defined over outer loops. If the dimension is tiled,
the i-th index is the product of offset_i and inner_tile_i.

Different from tiling a pad op, we do not have to deal with reading zero
data from input. Because the tiling sizes are indicated to packed outer
dimensions. We will read either the entire tile or partial tile for each
packed tile. The scf.if and tensor.generate ops are not needed in this
context.

Co-authored-by: Lorenzo Chelini <l.chelini@icloud.com>
Reviewed By: rengolin, mravishankar

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

20 months agoReland "[lld-macho] Overhaul map file code"
Jez Ng [Thu, 1 Dec 2022 05:57:16 +0000 (00:57 -0500)]
Reland "[lld-macho] Overhaul map file code"

This reverts commit 38d6202a425462ce5923d038bc54532115a80a1f.

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

20 months ago[lldb] Make sure the value of `eSymbolContextVariable` is not conflicting with `RESOL...
Argyrios Kyrtzidis [Thu, 1 Dec 2022 01:06:28 +0000 (17:06 -0800)]
[lldb] Make sure the value of `eSymbolContextVariable` is not conflicting with `RESOLVED_FRAME_CODE_ADDR`

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

20 months ago[mlir] Remove TypedAttr and ElementsAttr from DenseArrayAttr
Jeff Niu [Tue, 8 Nov 2022 04:20:59 +0000 (20:20 -0800)]
[mlir] Remove TypedAttr and ElementsAttr from DenseArrayAttr

This patch removes the implementation of TypedAttr and ElementsAttr
from DenseArrayAttr and, in doing so, removes the need store a shaped
type. The attribute now stores a size (number of elements), an MLIR type
as a discriminator, and a raw byte array.

The intent of DenseArrayAttr was not to be a drop-in replacement for DenseElementsAttr. It was meant to be a simple container of integers or floats that map to C++ types. The ElementsAttr implementation on DenseArrayAttr had many holes in it, and fixing those holes would require evolving DenseArrayAttr in a way that is incompatible with its original purpose.

Reviewed By: rriddle

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

20 months ago[InstCombine] Regenerate select-gep.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:19:05 +0000 (21:19 +0000)]
[InstCombine] Regenerate select-gep.ll test checks

Fixes superfluous diffs identified in D139253

20 months ago[InstCombine] Regenerate select-bitext.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:18:31 +0000 (21:18 +0000)]
[InstCombine] Regenerate select-bitext.ll test checks

Fixes superfluous diffs identified in D139253

20 months ago[InstCombine] Regenerate select-cmpxchg.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:15:49 +0000 (21:15 +0000)]
[InstCombine] Regenerate select-cmpxchg.ll test checks

20 months ago[InstCombine] Regenerate select-masked_load.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:15:02 +0000 (21:15 +0000)]
[InstCombine] Regenerate select-masked_load.ll test checks

20 months ago[InstCombine] Regenerate opaque-ptr.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:13:39 +0000 (21:13 +0000)]
[InstCombine] Regenerate opaque-ptr.ll test checks

Fixes superfluous diffs identified in D139253

20 months ago[X86] Remove unnecessary x87 overrides from znver1/znver2 model
Simon Pilgrim [Mon, 5 Dec 2022 21:12:07 +0000 (21:12 +0000)]
[X86] Remove unnecessary x87 overrides from znver1/znver2 model

Reported by D138359 - the overrides matched the base class schedule WriteMicrocoded definition

20 months ago[lld-macho] Canonicalize LSDA pointers
Jez Ng [Mon, 5 Dec 2022 21:18:15 +0000 (16:18 -0500)]
[lld-macho] Canonicalize LSDA pointers

This was causing an uncaught exception issue in one of our programs. The
issue was fairly subtle / rare as it required two identical LSDAs that were
referenced by a pair of non-identical compact unwind encodings.

Reviewed By: #lld-macho, smeenai

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