platform/upstream/llvm.git
18 months agoMove isAllInactivePredicate and isAllActivePredicate definition upwards, NFC
Dinar Temirbulatov [Tue, 10 Jan 2023 14:23:29 +0000 (14:23 +0000)]
Move isAllInactivePredicate and isAllActivePredicate definition upwards, NFC

18 months ago[lld][COFF] Fix bug causing assertion in Chunk::setAlignment
Andrew Ng [Tue, 10 Jan 2023 14:03:48 +0000 (14:03 +0000)]
[lld][COFF] Fix bug causing assertion in Chunk::setAlignment

Reinstate use of FakeSection class to avoid constructing SectionChunk
from unintialised coff_section in FakeSectionChunk constructor.

Issue was caused by commit 5a58b19f9c93f3ac51bcde318508131ae78aa10c,
"[LLD] Remove global state in lld/COFF".

18 months ago[clang][dataflow] Unify `TransferOptions` and `DataflowAnalysisContext::Options`.
Yitzhak Mandelbaum [Tue, 27 Dec 2022 17:34:30 +0000 (17:34 +0000)]
[clang][dataflow] Unify `TransferOptions` and `DataflowAnalysisContext::Options`.

Merges `TransferOptions` into the newly-introduced
`DataflowAnalysisContext::Options` and removes explicit parameter for
`TransferOptions`, relying instead on the common options carried by the analysis
context. Given that there was no intent to allow different options between calls
to `transfer`, a common value for the options is preferable.

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

18 months ago[AMDGPU] Add GFX10/GFX11 wave64 test coverage in huge-private-buffer.ll
Jay Foad [Tue, 10 Jan 2023 14:13:16 +0000 (14:13 +0000)]
[AMDGPU] Add GFX10/GFX11 wave64 test coverage in huge-private-buffer.ll

18 months agoAvoid u8"" literals in tests, their type changes in C++20
Jens Massberg [Tue, 10 Jan 2023 11:20:09 +0000 (12:20 +0100)]
Avoid u8"" literals in tests, their type changes in C++20

Just specify the encoded bytes instead, which causes less confusion anyway.

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

18 months ago[AMDGPU] Fix duplicate -verify-machineinstrs option
Jay Foad [Tue, 10 Jan 2023 14:06:59 +0000 (14:06 +0000)]
[AMDGPU] Fix duplicate -verify-machineinstrs option

18 months ago[AArch64] Comprehensive tests for atomic operations
Tomas Matheson [Tue, 6 Dec 2022 11:18:16 +0000 (11:18 +0000)]
[AArch64] Comprehensive tests for atomic operations

There are a lot of variants of atomic operations, and AArch64 has several
distinct options to codegen them, and does different things depending on
available features, architecture version and optimisation level. The current
testing for atomic operations has been added gradually over time and does not
give full coverate.  Given how complex the codegen for atomic operations is, it
is valuable to cover the entire parameter space, i.e. test them all. The
resulting set of tests serve also as a reference for how each is codegened.

In order to keep the test files readable and avoid constant updating for
unrelated codegen changes, the test outputs are filtered to only include the
relevant instructions. This shows for each operation and feature which codegen
approach is taken (e.g. ll/sc loop, atomic instruction, library call).

The following parameter space is tested:
 - feature: +lse, +rcpc, etc
 - optimisation level: O0, O1 (covers GISel and SelectionDAG)
 - atomic instruction: load, store, cmpxchg, atomirmw*
 - size: i8, i16, i32, i64, i128
 - aligned/unaligned accesses
 - endianness: big, little
 - atomic ordering: release, acquire, etc
 - load atomic only: const/non-const
 - cmpxchg only: weak/strong
 - atomicrmw: update operation (add, sub, etc)

Notably not covered:
 - volatility: there should be no difference between volatile/non-volatile
 - atomicrmw fadd/fsub

The files are split by triple, LLVM instruction, and feature. This makes it
easy to diff between features and endianness for a given instruction.

The file that generates the tests is included.

There are 70 test files with an average of 2800 lines each.

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

18 months ago[mlir] verify that transform ops have memory effects
Alex Zinenko [Tue, 10 Jan 2023 12:19:53 +0000 (12:19 +0000)]
[mlir] verify that transform ops have memory effects

Add a verifier to the TransformOpInterface ensuring that operations
implementing the interface define memory effects on their operands and
results.

Add the missing effects to TileToForeachThreadOp, specifically for
operands that were added at a later version of the op without modifying
`getEffects` accordingly.

Reviewed By: nicolasvasilache

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

18 months agoRevert "[X86] Add RMPQUERY to SNP instructions"
Ganesh Gopalasubramanian [Tue, 10 Jan 2023 13:41:25 +0000 (19:11 +0530)]
Revert "[X86] Add RMPQUERY to SNP instructions"

This reverts commit 313b747c5bf293aa86caf0da57b978a9758cd57b.
It wasn't reviwed as yet.

18 months ago[X86] Add RMPQUERY to SNP instructions
Ganesh Gopalasubramanian [Tue, 10 Jan 2023 13:31:12 +0000 (19:01 +0530)]
[X86] Add RMPQUERY to SNP instructions

18 months ago[mlir][llvm] Call the instruction builders from a static method (NFC).
Tobias Gysi [Tue, 10 Jan 2023 13:16:38 +0000 (14:16 +0100)]
[mlir][llvm] Call the instruction builders from a static method (NFC).

Extract a static method to call the MLIR builders that translate LLVM IR
instructions to MLIR LLVM dialect operations. This change ensures the
MLIR builders have to use the moduleImport argument rather than calling
the import methods directly. As a result, both the intrinsic and the
instruction MLIR builders have to use a moduleImport argument and none
of them has direct access to private moduleImport methods. The revision
thus enforces consistent MLIR builder implementations for instructions
and intrinsics.

The revision also moves parseDataLayoutAlignment closer to its use.

Reviewed By: Dinistro

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

18 months ago[Support] avoid u8"" literals in tests, their type changes in C++20
Sam McCall [Mon, 9 Jan 2023 19:36:05 +0000 (20:36 +0100)]
[Support] avoid u8"" literals in tests, their type changes in C++20

Just specify the encoded bytes instead, which causes less confusion anyway.

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

18 months ago[AST] include decls owned by FriendDecl in -ast-dump
Sam McCall [Tue, 10 Jan 2023 09:51:34 +0000 (10:51 +0100)]
[AST] include decls owned by FriendDecl in -ast-dump

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

18 months ago[AMDGPU] Add GFX11 test coverage for FeatureBackOffBarrier
Jay Foad [Tue, 10 Jan 2023 12:02:55 +0000 (12:02 +0000)]
[AMDGPU] Add GFX11 test coverage for FeatureBackOffBarrier

18 months ago[AMDGPU] Regenerate checks in waitcnt-preexisting-vscnt.mir
Jay Foad [Tue, 10 Jan 2023 12:16:43 +0000 (12:16 +0000)]
[AMDGPU] Regenerate checks in waitcnt-preexisting-vscnt.mir

18 months ago[X86][NFC]Move and rephrase the comment, NFC
Alexey Bataev [Tue, 10 Jan 2023 12:34:16 +0000 (04:34 -0800)]
[X86][NFC]Move and rephrase the comment, NFC

18 months ago[NVPTX] Enforce minumum alignment of 4 for byval parametrs in a function prototype
Pavel Kopyl [Mon, 9 Jan 2023 14:59:47 +0000 (17:59 +0300)]
[NVPTX] Enforce minumum alignment of 4 for byval parametrs in a function prototype

As a result, we have identical alignment calculation of byval
parameters for:

  - LowerCall() - getting alignment of an argument (.param)

  - emitFunctionParamList() - getting alignment of a
    parameter (.param) in a function declaration

  - getPrototype() - getting alignment of a parameter (.param) in a
    function prototypes that is used for indirect calls

This change is required to avoid ptxas error: 'Alignment of argument
does not match formal parameter'. This error happens even in cases
where it logically shouldn't.

For instance:

  .param .align 4 .b8 param0[4];
  ...
  callprototype ()_ (.param .align 2 .b8 _[4]);
  ...

Here we allocate 'param0' with alignment of 4 and it should be fine to
pass it to a function that requires minimum alignment of 2.

At least ptxas v12.0 rejects this code.

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

18 months ago[NVPTX] Set default version of architecture to SM_30, PTX to 6.0.
Pavel Kopyl [Mon, 9 Jan 2023 14:55:55 +0000 (17:55 +0300)]
[NVPTX] Set default version of architecture to SM_30, PTX to 6.0.

Support of variadic functions triggers an assertion on several tests
from llvm/test/CodeGen/Generic/ if nvptx64-* is specified as a default
triplet:

Support for variadic functions (unsized array parameter) introduced in
PTX ISA version 6.0 and requires target sm_30.

That happens because those tests contain variadic function calls and
default versions of both PTX ISA (3.2) and architecture (sm_20) are
below the minimally required.

There were no observable problems with these tests before adding
support of variadic functions, because nvptx backend just didn't
handle them properly generating invalid PTX code.

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

18 months ago[GVNSink] Convert tests to opaque pointers (NFC)
Nikita Popov [Tue, 10 Jan 2023 11:45:06 +0000 (12:45 +0100)]
[GVNSink] Convert tests to opaque pointers (NFC)

Keeping bitcasts in the common_bitcast() test, otherwise sinking
no longer occurs there. GVNSink seems to have a silly cost model
where sinking just the stores is considered non-profitable, but
sinking the stores and bitcasts (which are free...) is profitable.

As this is not a default-enabled pass, and this problem would exist
without opaque pointers as well, I'm not trying to do anything
about this.

18 months ago[AArch64] lower abs intrinsic to new ABS instruction in GIsel
Ties Stuij [Tue, 10 Jan 2023 11:12:19 +0000 (11:12 +0000)]
[AArch64] lower abs intrinsic to new ABS instruction in GIsel

When feature CSSC is available, the abs intrinsic should map to the
new scalar ABS instruction when using GlobalIsel

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

Reviewed By: aemerson

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

18 months ago[GVNSink] Make tests more robust (NFC)
Nikita Popov [Tue, 10 Jan 2023 11:39:36 +0000 (12:39 +0100)]
[GVNSink] Make tests more robust (NFC)

Avoid use of no-op GEPs.

18 months agoRemove unnecessary template specifiers from truct constructors in tests.
Jens Massberg [Mon, 9 Jan 2023 16:56:10 +0000 (17:56 +0100)]
Remove unnecessary template specifiers from truct constructors in tests.

As far as I can see they are unnecessary and in C++20 they lead to errors.
Removing them the tests pass with C++20 and the default version.
Example error message:
```
llvm-project/llvm/unittests/IR/PassBuilderCallbacksTest.cpp:275:30: error: expected unqualified-id before ‘)’ token
  275 |   MockAnalysisHandle<Module>() { setDefaults(); }
```

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

18 months ago[GlobalMerge] Convert tests to opaque pointers (NFC)
Nikita Popov [Tue, 10 Jan 2023 11:33:04 +0000 (12:33 +0100)]
[GlobalMerge] Convert tests to opaque pointers (NFC)

18 months ago[CostModel][AArch64] Add insert/extract element tests for neoverse cores. NFC.
Sjoerd Meijer [Tue, 10 Jan 2023 11:10:42 +0000 (11:10 +0000)]
[CostModel][AArch64] Add insert/extract element tests for neoverse cores. NFC.

18 months ago[mlir] GreedyPatternRewriter: fix counting of iterations
Matthias Springer [Tue, 10 Jan 2023 11:02:33 +0000 (12:02 +0100)]
[mlir] GreedyPatternRewriter: fix counting of iterations

The GreedyPatternRewriteDriver did previously not count the first iteration. I.e., when setting `config.maxIterations = 1`, two iterations were performed. In pratice, this number is not really important; we usually just need a limit in some reasonable order of magnitude. However, this fix allows us to write better convergence/worklist tests with carefully crafted test patterns to purposely trigger edge cases in the driver.

Similarly, the first rewrite was previously not counted towards `config.maxNumRewrites`.

For consistency, `OpPatternRewriteDriver` now uses `config.maxNumRewrites` instead of `config.maxIterations`; this driver does not have "iterations", it consists of a single loop (corresponding to the inner loop in the GreedyPatternRewriteDriver).

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

18 months agoReapply [Dominators] Add findNearestCommonDominator() for Instructions (NFC)
Nikita Popov [Fri, 6 Jan 2023 15:56:34 +0000 (16:56 +0100)]
Reapply [Dominators] Add findNearestCommonDominator() for Instructions (NFC)

Reapply with checks for instructions in unreachable blocks. A test
case for this was added in 1ee4a93b15bb.

-----

This is a recurring pattern: We want to find the nearest common
dominator (instruction) for two instructions, but currently only
provide an API for the nearest common dominator of two basic blocks.

Add an overload that accepts and return instructions.

18 months ago[DSE] Add test with different unreachable block order (NFC)
Nikita Popov [Tue, 10 Jan 2023 11:12:52 +0000 (12:12 +0100)]
[DSE] Add test with different unreachable block order (NFC)

18 months ago[lld][WebAssembly] Fix memory.fill argument in 64-bit mode
Sam Clegg [Wed, 4 Jan 2023 19:28:55 +0000 (11:28 -0800)]
[lld][WebAssembly] Fix memory.fill argument in 64-bit mode

This only effects folks building with wasm64 + shared memory which
is not currently a supported configuration in emscripten or any other
wasm toolchain.

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

18 months ago[UpdateTestChecks] Add wasm64 target
Luke Lau [Fri, 6 Jan 2023 13:55:28 +0000 (13:55 +0000)]
[UpdateTestChecks] Add wasm64 target

wasm32 was already supported, so here I've just reused the same regex. I'm not sure if this is actually correct: I don't know for certain if wasm32 and wasm64 have different output formats, but it seems to work.

Reviewed By: dschuff, asb

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

18 months agoRevert "[JumpThreading] Preserve profile metadata during select unfolding"
Dmitri Gribenko [Tue, 10 Jan 2023 10:37:49 +0000 (11:37 +0100)]
Revert "[JumpThreading] Preserve profile metadata during select unfolding"

This reverts commit 957952dbf2f34ed552e8e1f8c35eed17eee2ea38.

Addition in the newly added code can overflow.  As a result, the
constructor of `BranchProbability()` can trigger an assertion. See
the discussion on https://reviews.llvm.org/D138132 for more details.

18 months ago[AArch64] Add Issue #59898 test case for D141363
Simon Pilgrim [Tue, 10 Jan 2023 10:49:23 +0000 (10:49 +0000)]
[AArch64] Add Issue #59898 test case for D141363

18 months agoMove from llvm::makeArrayRef to ArrayRef deduction guides - last part
serge-sans-paille [Mon, 9 Jan 2023 17:11:07 +0000 (18:11 +0100)]
Move from llvm::makeArrayRef to ArrayRef deduction guides - last part

This is a follow-up to https://reviews.llvm.org/D140896, split into
several parts as it touches a lot of files.

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

18 months ago[AArch64] Regenerate rotate.ll test
Simon Pilgrim [Tue, 10 Jan 2023 10:44:26 +0000 (10:44 +0000)]
[AArch64] Regenerate rotate.ll test

Simplifies diff for D141363

18 months ago[LSR] Hoist IVInc to loop header if its all uses are in the loop header
chenglin.bi [Tue, 10 Jan 2023 10:33:33 +0000 (18:33 +0800)]
[LSR] Hoist IVInc to loop header if its all uses are in the loop header

When the latch block is different from header block, IVInc will be expanded in the latch loop. We can't generate the post index load/store this case.
But if the IVInc only used in the loop, actually we still can use the post index load/store because when exit loop we don't care the last IVInc value.
So, trying to hoist IVInc to help backend to generate more post index load/store.

Fix #53625

Reviewed By: eopXD

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

18 months ago[Clang][RISCV] Expose vlenb to user
eopXD [Sun, 8 Jan 2023 15:55:06 +0000 (07:55 -0800)]
[Clang][RISCV] Expose vlenb to user

This commit adds function `vlenb` into riscv_vector.h. `vlenb` is defined
through builtin function `__builtin_rvv_vlenb`, which is lowered to
`llvm.read_register`.

Reviewed By: kito-cheng, pcwang-thead

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

18 months ago[XCOFF][NFC] Update the test aix-xcoff-huge-relocs.ll
esmeyi [Tue, 10 Jan 2023 10:18:53 +0000 (05:18 -0500)]
[XCOFF][NFC] Update the test aix-xcoff-huge-relocs.ll

18 months ago[AMDGPU] adding test for partially masked operands
Jessica Del [Tue, 10 Jan 2023 10:05:00 +0000 (11:05 +0100)]
[AMDGPU] adding test for partially masked operands

This test is testing whether the compiler behaves correctly when only
parts of an operand are masked.
In this case, no optimization is supposed to happen, since neither
the upper nor the lower half is
fully masked. Therefore, none
of the halves can be known to be zero.
The result is a regular multiplication.

18 months agoRevert "[clang-format] Add an option for breaking after C++11 attributes"
Krasimir Georgiev [Tue, 10 Jan 2023 09:23:44 +0000 (09:23 +0000)]
Revert "[clang-format] Add an option for breaking after C++11 attributes"

This reverts commit a28f0747c2f3728bd8a6f64f7c8ba80b4e0cda9f.

It appears that this regresses some function definitions, added an
example as a comment over at https://reviews.llvm.org/D140956.

18 months ago[AVR] Do not select unimplemented pseudo instructions
Ben Shi [Sun, 8 Jan 2023 03:50:50 +0000 (11:50 +0800)]
[AVR] Do not select unimplemented pseudo instructions

Reviewed By: aykevl, Miss_Grape

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

18 months ago[InstCombine] Combine lshr of add -> (a + b < a)
Pierre van Houtryve [Fri, 6 Jan 2023 13:33:49 +0000 (08:33 -0500)]
[InstCombine] Combine lshr of add -> (a + b < a)

Tries to perform
  (lshr (add (zext X), (zext Y)), K)
  ->  (icmp ult (add X, Y), X)
  where
    - The add's operands are zexts from a K-bits integer to a bigger type.
    - The add is only used by the shr, or by iK (or narrower) truncates.
    - The lshr type has more than 2 bits (other types are boolean math).
    - K > 1

This seems to be a pattern that just comes from OpenCL front-ends, so adding DAG/GISel combines doesn't seem to be worth the complexity.

Original patch D107552 by @abinavpp - adapted to use (a + b < a) instead of uaddo following discussion on the review.
See this issue https://github.com/RadeonOpenCompute/ROCm/issues/488

Reviewed By: spatel

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

18 months ago[flang] Lower addresses inside global initializers in HLFIR
Jean Perier [Tue, 10 Jan 2023 08:28:08 +0000 (09:28 +0100)]
[flang] Lower addresses inside global initializers in HLFIR

Move the code to lower an expression to address or a box in HLFIR from
Bridge.cpp to ConvertExpr.cpp so that it can be used inside
ConvertVariable.cpp (that needs to use a different symbol map that the
one held in the bridge).

Lower NULL to hlfir.null.

This allows lowering derived type constant structure constructors with
pointer components into fir.global.

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

18 months ago[InstCombine] Precommit D138814 tests
Pierre van Houtryve [Tue, 6 Dec 2022 08:29:08 +0000 (03:29 -0500)]
[InstCombine] Precommit D138814 tests

Separate commit for D138814's testcases to make review easier.

Reviewed By: spatel

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

18 months ago[flang] Allow and use fir.rebox in fir.global
Jean Perier [Tue, 10 Jan 2023 08:01:38 +0000 (09:01 +0100)]
[flang] Allow and use fir.rebox in fir.global

The current lowering of initial target in fir.global is relying
on how fir.box are created: instead of using a fir.rebox to add
the POINTER attribute to the created descriptor, it is looking
for a fir.embox defining operation and creating a copy of
it with a different result types.

The rational for doing so was that fir.rebox codegen was not possible
inside fir.global because it expects to manipulate the input fir.box
in memory, while objects cannot be manipulated in memory inside
a fir.global region that must be constant foldable.

But this approach has two problems:
- it won't work with hlfir where fir.box may be created by more
  operations than fir.embox (e.g. hlfir.delcare or hlfir.designate).
  In general, looking for a precise defining op for a value is
  fragile.
- manually copying and modifying an operation is risky: it is easy
  to forget copying some default operands (that could be added later).

This patch modifies the helpers to get descriptor fields so that they
can both operate on fir.box lowered in memory or in an llvm.struct
value. This enables the usage of fir.rebox in fir.global op.

The fallout in FIR tests is caused by the usage of constant index
when creating GEP (because extractOp requires constant indices).
MLIR builder uses i32 bit constant indices when non mlir::Value
indices are passed to the MLIR GEP op builder. Previously,
an 64 nist mlir constant value was created and passed to the GEP
builder. In this case, the builder respect the value type when
later generating the GEP.
Given this changes impact the "dimension" index that can, per
Fortran requirement, not be greated than 15, using a 32 bit index
is just fine and actually simplify the MLIR LLVM IR generation.

The fallout in lowering tests is caused by the introduction
of the fir.rebox everytime an initial target is created.

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

18 months agoRevert "[llvm-profdata] Add option to cap profile output size"
Douglas Yung [Tue, 10 Jan 2023 07:53:14 +0000 (23:53 -0800)]
Revert "[llvm-profdata] Add option to cap profile output size"

This reverts commit 5b72d0e4f5eeb8f90c744cac8e0728cffeca61a9.

The test added is failing on Mac/Windows. See review for buildbot failure links.

18 months agoRevert "[ProfileData] Fix a warning"
Douglas Yung [Tue, 10 Jan 2023 07:52:06 +0000 (23:52 -0800)]
Revert "[ProfileData] Fix a warning"

This reverts commit 9f4a9d3f44501fa755eb71fe855e15cf0e59e8b8.

Reverting this change which was a follow-up to 5b72d0e4f5eeb8f90c744cac8e0728cffeca61a9 which is being reverted due to test failures on Mac/Windows.

18 months ago[XCOFF] support the overflow section (only relocation overflow is handled).
esmeyi [Tue, 10 Jan 2023 07:39:02 +0000 (02:39 -0500)]
[XCOFF] support the overflow section (only relocation overflow is handled).

Summary: This patch handles relocation field overflows in an XCOFF32 file. (XCOFF64 files may not have overflow section headers.) If a section has more than 65,534 relocation entries or line number entries, both of these fields are set to a value of 65535. In this case, an overflow section header with the s_flags field equal to STYP_OVRFLO is used to contain the relocation and line-number count information. Since line number is not supported, this patch only handles the relocation overflow.

Reviewed By: shchenz

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

18 months ago[OpenMP] Use Attributor to find underlying objects of stores
Johannes Doerfert [Fri, 23 Dec 2022 02:18:40 +0000 (18:18 -0800)]
[OpenMP] Use Attributor to find underlying objects of stores

When we see a store in generic mode we need to decide if we should guard
it for SPMDzation. This patch changes the getUnderlyingObjects call to
the more optimistic getAssumedUnderlyingObjects call to identify more
thread local pointers.

18 months agoFix build when LLVM_BUILTIN_TARGETS is not set
Yi Kong [Tue, 10 Jan 2023 05:56:03 +0000 (14:56 +0900)]
Fix build when LLVM_BUILTIN_TARGETS is not set

If LLVM_BUILTIN_TARGETS is not set, no OS specific variants will be
created, causing CMake build failure. Depend on the generic builtins
target if LLVM_BUILTIN_TARGETS is not set.

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

18 months ago[Clang] Silence a "unused variable" warning when building with MSVC
Alexandre Ganea [Tue, 10 Jan 2023 04:45:20 +0000 (23:45 -0500)]
[Clang] Silence a "unused variable" warning when building with MSVC

18 months ago[LLD] Remove global state in lld/COFF
Amy Huang [Tue, 10 Jan 2023 04:37:28 +0000 (23:37 -0500)]
[LLD] Remove global state in lld/COFF

Remove globals from the lldCOFF library, by moving globals into a context class.
This patch mostly moves the config object into COFFLinkerContext.

See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html for
context about removing globals from LLD.

Reviewed By: aganea

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

18 months agoRevert "Remove the ThreadLocal template from LLVM."
Owen Anderson [Tue, 10 Jan 2023 04:21:38 +0000 (21:21 -0700)]
Revert "Remove the ThreadLocal template from LLVM."

This reverts commit 54d78b639b9c18b42abd4fac5c6e76105f06b3ef.

18 months agoRevert "Fix warning when building with GCC."
Owen Anderson [Tue, 10 Jan 2023 04:21:29 +0000 (21:21 -0700)]
Revert "Fix warning when building with GCC."

This reverts commit 971786254cc4093eb1c56625b8da0fd3544f6512.

18 months agoFix warning when building with GCC.
Owen Anderson [Tue, 10 Jan 2023 04:17:51 +0000 (21:17 -0700)]
Fix warning when building with GCC.

18 months agoRemove the ThreadLocal template from LLVM.
Owen Anderson [Tue, 10 Jan 2023 03:48:20 +0000 (20:48 -0700)]
Remove the ThreadLocal template from LLVM.

This has been obsoleted by C++ thread_local for a long time.
As far as I know, Xcode was the last supported toolchain to add
support for C++ thread_local in 2016.

As a precaution, use LLVM_THREAD_LOCAL which provides even greater
backwards compatibility, allowing this to function even pre-C++11
versions of GCC.

Reviewed By: majnemer

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

18 months ago[SCEV] Add llvm.experimental.guard conditions to applyLoopGuards()
Joshua Cao [Tue, 10 Jan 2023 03:24:50 +0000 (19:24 -0800)]
[SCEV] Add llvm.experimental.guard conditions to applyLoopGuards()

Conditions for dominating branches and llvm.assumes are already
collected. This also adds conditions from guards.

Reviewed By: nikic

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

18 months ago[BOLT] Modify the print option to a meaningful value
hezuoqiang [Tue, 10 Jan 2023 03:03:05 +0000 (19:03 -0800)]
[BOLT] Modify the print option to a meaningful value

Using the option `-print-sorted-by=.` cause to core dump, so change to a legal value.

Reviewed By: maksfb

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

18 months ago[NFC] Fix a test faliing in AIX
Chuanqi Xu [Tue, 10 Jan 2023 02:36:50 +0000 (10:36 +0800)]
[NFC] Fix a test faliing in AIX

See https://reviews.llvm.org/D140867.

The signature of the constructor/destrucor of the global variables is
different in different targets. And the CHECKs in the test is
unavailable in other targets (e.g., AIX). So the patch tries to avoid
the test failure by requiring the target type.

18 months agoRevert "[GVN] Improve PRE on load instructions"
Guozhi Wei [Tue, 10 Jan 2023 02:35:35 +0000 (02:35 +0000)]
Revert "[GVN] Improve PRE on load instructions"

This reverts commit 1f1d501843e5cf8741599035d6ef66a3eb5e1e9e.

This patch caused several sanitizer tests failed. Revert it to unblock
others.

18 months ago[RISCV] Add codegen support for RISCV XTHeadVdot Extension
Jojo R [Fri, 30 Dec 2022 11:09:12 +0000 (19:09 +0800)]
[RISCV] Add codegen support for RISCV XTHeadVdot Extension

This patch adds codegen support for XTHeadVdot extension,
which is documented here, it's based on standard vector extension v1.0:
  https://github.com/T-head-Semi/thead-extension-spec

Reviewed By: craig.topper

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

18 months ago[mlir] Avoid crash of UnsignedWhenEquivalent for no integer type.
jacquesguan [Thu, 5 Jan 2023 09:06:35 +0000 (17:06 +0800)]
[mlir] Avoid crash of UnsignedWhenEquivalent for no integer type.

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

Reviewed By: Mogball

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

18 months ago[RISCV] Add H extension
Kito Cheng [Tue, 10 Jan 2023 01:51:07 +0000 (09:51 +0800)]
[RISCV] Add H extension

`h` was the prefix of multi-letter extension name, but it become a
extension name in later RISC-V isa spec.

Fortunately we don't have any extension really defined is prefixed
with `h`, so we can just change that.

Reviewed By: reames

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

18 months ago[libc++][test] Avoid MSVC constexpr bug
Casey Carter [Tue, 10 Jan 2023 01:18:08 +0000 (17:18 -0800)]
[libc++][test] Avoid MSVC constexpr bug

C++ constexpr allows a non-constant-expresssion lvalue to be used in a constant expression if it's not subject to lvalue-to-rvalue conversion. Subtly, this means you can make a constant-expression copy of a non-constant-expression object of empty type since the copy constructor doesn't perform lvalue-to-rvalue conversion. MSVC has had bugs with this usage forever, which will hopefully finally be mashed implementing C++23's relaxation on the use of pointers and references in constant expressions.

There's no need for this particular test to use this particular constexpr feature, we can simply make the predicates constant expressions.

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

18 months ago[XCore] Use the newly introduced generic MEMBARRIER node [not quite nfc]
Philip Reames [Tue, 10 Jan 2023 01:41:31 +0000 (17:41 -0800)]
[XCore] Use the newly introduced generic MEMBARRIER node [not quite nfc]

The target node being removed did not have side effects; the generic one does.  Nothing in the code indicates the lack was intentional, so this is probably fixing a bug.

18 months ago[AArch64] Add SVE int instructions to isAssociativeAndCommutative
KAWASHIMA Takahiro [Mon, 12 Dec 2022 05:25:32 +0000 (14:25 +0900)]
[AArch64] Add SVE int instructions to isAssociativeAndCommutative

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

18 months ago[AArch64] Add SVE FP instructions to isAssociativeAndCommutative
KAWASHIMA Takahiro [Mon, 12 Dec 2022 05:25:32 +0000 (14:25 +0900)]
[AArch64] Add SVE FP instructions to isAssociativeAndCommutative

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

18 months agoAdd a space for readability [nfc]
Philip Reames [Tue, 10 Jan 2023 01:10:31 +0000 (17:10 -0800)]
Add a space for readability [nfc]

18 months ago[X86] Reuse STDNone for MFENCE node [nfc]
Philip Reames [Tue, 10 Jan 2023 01:09:34 +0000 (17:09 -0800)]
[X86] Reuse STDNone for MFENCE node [nfc]

18 months ago[VE] Use generic MEMBARRIER SDAG node [nfc]
Philip Reames [Tue, 10 Jan 2023 01:07:40 +0000 (17:07 -0800)]
[VE] Use generic MEMBARRIER SDAG node [nfc]

18 months ago[OpenMP][FIX] Remove version specific check lines
Johannes Doerfert [Tue, 10 Jan 2023 01:04:56 +0000 (17:04 -0800)]
[OpenMP][FIX] Remove version specific check lines

18 months agofix : add missing open brace [OpenMP][FIX] Avoid using an Error object after a std...
Ron Lieberman [Tue, 10 Jan 2023 00:52:16 +0000 (19:52 -0500)]
fix : add missing open brace [OpenMP][FIX] Avoid using an Error object after a std::move.

18 months ago[RISCV] Add isel patterns to form tail undisturbed vwadd(u).wv from vwadd(u)_vl+vp_merge.
Craig Topper [Tue, 10 Jan 2023 00:35:44 +0000 (16:35 -0800)]
[RISCV] Add isel patterns to form tail undisturbed vwadd(u).wv from vwadd(u)_vl+vp_merge.

We use a special TIED instructions for vwadd(u).wv to avoid an
earlyclobber constraint preventing the first source and the destination
from being the same register.

This prevents our normal post process for forming TU instructions.
Add manual isel pattern instead. This matches what we do for FMA
for example.

18 months ago[RISCV] Update combineBinOp_VLToVWBinOp_VL to check the number users after we know...
Craig Topper [Tue, 10 Jan 2023 00:31:15 +0000 (16:31 -0800)]
[RISCV] Update combineBinOp_VLToVWBinOp_VL to check the number users after we know what combine we're going to do.

If we're forming vwadd(u).wv we don't care if the already wide
source operand has additional users. It's not affected by the
transform.

Fixes #59345

18 months ago[RISCV] Add test cases for PR59345. NFC
Craig Topper [Tue, 10 Jan 2023 00:26:42 +0000 (16:26 -0800)]
[RISCV] Add test cases for PR59345. NFC

These tests show failure to form vwadd(u).wv instructions.

One of the operands of the add is already wide and has an
additional user. We are unnecessary enforcing that operand to
have a single use.

18 months ago[Attributor] Allow cfg reasoning for thread-local objects
Johannes Doerfert [Wed, 21 Dec 2022 00:13:41 +0000 (16:13 -0800)]
[Attributor] Allow cfg reasoning for thread-local objects

If an object (=memory) is thread-local we do not need to worry about
threading effects.

18 months ago[Attributor][OpenMP][NFC] Cleanup tests via update script
Johannes Doerfert [Fri, 6 Jan 2023 22:15:02 +0000 (14:15 -0800)]
[Attributor][OpenMP][NFC] Cleanup tests via update script

18 months ago[OpenMP][NFC] Rerun the update_cc_test_checks on most OpenMP tests
Johannes Doerfert [Sun, 8 Jan 2023 21:08:49 +0000 (13:08 -0800)]
[OpenMP][NFC] Rerun the update_cc_test_checks on most OpenMP tests

The script changes over time and unrelated changes to the test check
lines should not pollute future revisions.

18 months ago[mlir][llvm] Don't mark CallIntrinsicOp as Pure
Jeff Niu [Mon, 9 Jan 2023 23:49:14 +0000 (15:49 -0800)]
[mlir][llvm] Don't mark CallIntrinsicOp as Pure

This is a function call to intrinsics with unknown side effects.

Reviewed By: rriddle

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

18 months ago[DirectX backend] PartSize not include PartHeader
Xiang Li [Sun, 8 Jan 2023 04:31:26 +0000 (23:31 -0500)]
[DirectX backend] PartSize not include PartHeader

PartSize for a part in dx container is only the size of the content of the part, not include size of the PartHeader.

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

18 months ago[DirectX backend] Remove unused bitcode block for dxil
Xiang Li [Mon, 9 Jan 2023 22:45:53 +0000 (17:45 -0500)]
[DirectX backend] Remove unused bitcode block for dxil

DXIL doesn't need uselist strtab and symtab blocks which are not supported  by llvm3.7 bitcode.

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

18 months ago[OpenMP][FIX] Avoid using an Error object after a std::move.
Johannes Doerfert [Mon, 9 Jan 2023 21:03:28 +0000 (13:03 -0800)]
[OpenMP][FIX] Avoid using an Error object after a std::move.

The error was always a success even if the error case happened as the
std::move reseted the error object.

18 months ago[Intrinsics][FIX] Patchpoint intrinsics are not `nocallback`
Johannes Doerfert [Mon, 9 Jan 2023 22:16:22 +0000 (14:16 -0800)]
[Intrinsics][FIX] Patchpoint intrinsics are not `nocallback`

Avoid the default attributes for these two special intrinsics.
Found as part of D141190.

18 months ago[GVN][NFC] Precommit intrinsic bug test case, see D141190
Johannes Doerfert [Mon, 9 Jan 2023 22:14:01 +0000 (14:14 -0800)]
[GVN][NFC] Precommit intrinsic bug test case, see D141190

18 months ago[AAUnderlyingObjects] Initialize an uninitialized boolean.
Caroline Tice [Mon, 9 Jan 2023 23:38:01 +0000 (15:38 -0800)]
[AAUnderlyingObjects] Initialize an uninitialized boolean.

Recent commit introducing AA for getting underluying objects of a
pointer created an uninitialized boolean, which causes tests to fail
when built unter asan/ubsan. This initialized that variable.

18 months ago[GVN] Fold variable into assert. NFC
Benjamin Kramer [Mon, 9 Jan 2023 23:39:51 +0000 (00:39 +0100)]
[GVN] Fold variable into assert. NFC

Avoids unused variable warnings when asserts are disabled.

18 months ago[lldb] Limit trusting aranges to dSYMs only.
Jonas Devlieghere [Mon, 9 Jan 2023 23:31:24 +0000 (15:31 -0800)]
[lldb] Limit trusting aranges to dSYMs only.

Limit trusting the arange accelerator tables (8b259fe573e1) to dSYMs
only, and not any debug info object file.

Differential revision: https://reviews.llvm.org/D141330

18 months agoupdate_any_test_checks.py: run from any dir
Nick Desaulniers [Mon, 9 Jan 2023 23:34:21 +0000 (15:34 -0800)]
update_any_test_checks.py: run from any dir

Allow running llvm/utils/update_any_test_checks.py from working
directories other llvm/utils/.

Fixes:
$ ./llvm/utils/update_any_test_checks.py path/to/foo.ll
utils/update_llc_test_checks.py: not found (used in path/to/foo.ll)

Reviewed By: arichardson

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

18 months ago[AMDGPU] Cast sub-dword elements to i32 in concat_vectors
Stanislav Mekhanoshin [Mon, 9 Jan 2023 22:19:46 +0000 (14:19 -0800)]
[AMDGPU] Cast sub-dword elements to i32 in concat_vectors

This produces better code by avoiding repacking in some cases.

Fixes: SWDEV-373436

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

18 months ago[llvm][PPCISelDAGToDAG] rename ppc-codegen to ppc-isel
Nick Desaulniers [Mon, 9 Jan 2023 23:24:19 +0000 (15:24 -0800)]
[llvm][PPCISelDAGToDAG] rename ppc-codegen to ppc-isel

Every other subclass of SelectionDAGISel calls this pass "<arch>-isel".
No existing tests refer to ppc-codegen so this is purely a cosmetic
change to bring the pass name in line with other architecture's
SelectionDAGISel subclasses.

Reviewed By: MaskRay

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

18 months ago[SDAG] Introduce a common MEMBARRIER node [nfc]
Philip Reames [Mon, 9 Jan 2023 22:45:45 +0000 (14:45 -0800)]
[SDAG] Introduce a common MEMBARRIER node [nfc]

We have multiple targets which have defined custom instructions and sdag nodes to represent a compiler memory barrier. This patch consolidates the sdag node definition into common code.

This is a companion to D92842, but a bit different in focus. This change consolidates the existing sdag node definitions; that patch skipped defining a sdag node by instead going straight to a target node. That patch is also not NFC - as being so is quite hard for commoning up the instruction definitions.

I started with two backends to ensure the new common code was reusable while not having a massive diff. Once this lands, I'll submit a series of NFCs for backends where the changes are obvious, or reviews if more discussion is needed.

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

18 months ago[AMDGPU] More selectively attach implicit operands to agpr spills
Jeffrey Byrnes [Fri, 6 Jan 2023 00:38:25 +0000 (16:38 -0800)]
[AMDGPU] More selectively attach implicit operands to agpr spills

Implicit def operands are needed when we spill partially undef super registers by each individual subregister. The implicit-def operands will allow us to lower spills without the verifier complaining. Currently, we are overzeously attaching implicit operands, when we really only need them on the first sub reg spill op. By more selectively attached the implicit ops, we will free up some unneeded dependencies for the post-ra scheduler.

Moreover, this enables a previously incorrect optimization / resolves a correctness issue in indirectCopyToAGPR. When lowering AGPR copies on GFX908, we can improve CodeGen by reusing accvgpr_writes. However, we could not reliably determine which agprs accvgpr_writes actually define due to implicit-defs.

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

18 months ago[libc++][test] _VSTD => std:: in test code
Casey Carter [Mon, 9 Jan 2023 10:39:06 +0000 (02:39 -0800)]
[libc++][test] _VSTD => std:: in test code

No `_VSTD` allowed in test code!

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

18 months ago[GVN] Improve PRE on load instructions
Guozhi Wei [Mon, 9 Jan 2023 23:04:41 +0000 (23:04 +0000)]
[GVN] Improve PRE on load instructions

This patch implements the enhancement proposed by
https://github.com/llvm/llvm-project/issues/59312.

Suppose we have following code

   v0 = load %addr
   br %LoadBB

 LoadBB:
   v1 = load %addr
   ...

 PredBB:
   ...
   br %cond, label %LoadBB, label %SuccBB

 SuccBB:
   v2 = load %addr
   ...

Instruction v1 in LoadBB is partially redundant, edge (PredBB, LoadBB) is a
critical edge. SuccBB is another successor of PredBB, it contains another load
v2 which is identical to v1. Current GVN splits the critical edge
(PredBB, LoadBB) and inserts a new load in it. A better method is move the load
of v2 into PredBB, then v1 can be changed to a PHI instruction.

If there are two or more similar predecessors, like the test case in the bug
entry, current GVN simply gives up because otherwise it needs to split multiple
critical edges. But we can move all loads in successor blocks into predecessors.

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

18 months ago[clangd] Include the correct header for typeid()
Nathan Ridge [Sun, 8 Jan 2023 08:18:13 +0000 (03:18 -0500)]
[clangd] Include the correct header for typeid()

Fixes https://github.com/clangd/clangd/issues/1449

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

18 months ago[libc++][test] Silence MSVC warning
Casey Carter [Mon, 9 Jan 2023 09:38:14 +0000 (01:38 -0800)]
[libc++][test] Silence MSVC warning

Our static analyzer likes to warn when loop bodies are never executed, which is true for `make_string<T>("")`. Build the result with `basic_string`'s iterator-pair constructor instead, which is simpler (one liner), faster (single pass), and doesn't trigger the warning.

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

18 months agoReturn a shared_ptr from ScratchTypeSystemClang::GetForTarget()
Adrian Prantl [Mon, 9 Jan 2023 22:47:42 +0000 (14:47 -0800)]
Return a shared_ptr from ScratchTypeSystemClang::GetForTarget()

The current interface theoretically could lead to a use-after-free
when a client holds on to the returned pointer. Fix this by returning
a shared_ptr to the scratch typesystem.

rdar://103619233

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

18 months ago[libc++][test] Make some string tests MSVC-friendly
Casey Carter [Mon, 9 Jan 2023 05:58:56 +0000 (21:58 -0800)]
[libc++][test] Make some string tests MSVC-friendly

* Using one-or-two letter names for globals is asking for shadowing warnings.
* MSVCSTL's container proxy allocations strike again
* MSVCSTL's `<string>` doesn't define `std::out_of_range`
* `basic_string::substr` takes two arguments of type `size_type`. Let's use that type instead of `size_t` and `ptrdiff_t` to avoid narrowing warnings.

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

18 months ago[ProfileData] Fix a warning
Kazu Hirata [Mon, 9 Jan 2023 22:59:25 +0000 (14:59 -0800)]
[ProfileData] Fix a warning

This patch fixes:

  llvm/lib/ProfileData/SampleProfWriter.cpp:100:10: error: unused
  variable 'OriginalFunctionCount' [-Werror,-Wunused-variable]

18 months ago[AMDGPU] More tests for vector_shuffle.packed.ll. NFC.
Stanislav Mekhanoshin [Mon, 9 Jan 2023 22:53:02 +0000 (14:53 -0800)]
[AMDGPU] More tests for vector_shuffle.packed.ll. NFC.

Pre-commit tests before the next patch. Subtest shuffle_v16f16_concat
exposes the problem with suboptimal lowering.

18 months ago[JumpThreading] Fix test to require asserts
Alex Brachet [Mon, 9 Jan 2023 22:51:08 +0000 (22:51 +0000)]
[JumpThreading] Fix test to require asserts

18 months ago[mlir][sparse] Improve the rewriting for NewOp with dimension ordering.
bixia1 [Mon, 9 Jan 2023 16:45:18 +0000 (08:45 -0800)]
[mlir][sparse] Improve the rewriting for NewOp with dimension ordering.

Previously, we use a temporary tensor with identity ordering. We now use a
temporary tensor with the destination dimension ordering, to enable the use of
sort_coo for sorting the tensor.

Reviewed By: Peiming

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