platform/upstream/llvm.git
17 months ago[clang][Interp] Compound assign operators for FP values
Timm Bäder [Tue, 20 Dec 2022 09:19:56 +0000 (10:19 +0100)]
[clang][Interp] Compound assign operators for FP values

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

17 months ago[clang][Interp][NFC] Get rid of InterpSize
Timm Bäder [Sat, 10 Dec 2022 07:15:09 +0000 (08:15 +0100)]
[clang][Interp][NFC] Get rid of InterpSize

17 months ago[clang][Interp][NFC] Remove an unused function
Timm Bäder [Wed, 7 Dec 2022 15:18:29 +0000 (16:18 +0100)]
[clang][Interp][NFC] Remove an unused function

17 months ago[AMDGCN] Fix device lib test to work with lib64
Siu Chi Chan [Tue, 24 Jan 2023 16:31:04 +0000 (11:31 -0500)]
[AMDGCN] Fix device lib test to work with lib64

This change fixes an issue introduced by
https://reviews.llvm.org/D140315.  A new unit test was added to validate
the search for the device libraries being placed in Clang's resource
directory; however, the test didn't take into account that certain
platforms use lib64 for 64-bit library directory.

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

Change-Id: I9c31a4f08fbc383350d82d6aba01987a3ef63e51

17 months ago[mlir][LLVM] Add result attribute import support
Christian Ulmann [Wed, 25 Jan 2023 14:52:59 +0000 (15:52 +0100)]
[mlir][LLVM] Add result attribute import support

This commit introduces support for importing result attributes.

Depends on D142372

Reviewed By: gysit

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

17 months ago[gn build] Port cb7f58221101
LLVM GN Syncbot [Wed, 25 Jan 2023 14:40:30 +0000 (14:40 +0000)]
[gn build] Port cb7f58221101

17 months agodoc: Fix typo in clang-tidy no-automatic-move doc
MarcoFalke [Wed, 25 Jan 2023 14:39:35 +0000 (15:39 +0100)]
doc: Fix typo in clang-tidy no-automatic-move doc

The latter version is called NotCool in the source code and on godbolt.

17 months agoReplace use of sprintf with snprint in SparseTensorRuntime.cpp (NFC)
Mehdi Amini [Wed, 25 Jan 2023 04:44:22 +0000 (20:44 -0800)]
Replace use of sprintf with snprint in SparseTensorRuntime.cpp (NFC)

This fixes a warning on MacOS:

warning: 'sprintf' is deprecated: This function is provided for compatibility
reasons only.  Due to security concerns inherent in the design of sprintf(3),
it is highly recommended that you use snprintf(3) instead.

17 months agoExclude running MLIR tests for Toy example Ch6 and Ch7 when JIT is unavailable
Mehdi Amini [Wed, 25 Jan 2023 04:43:38 +0000 (20:43 -0800)]
Exclude running MLIR tests for Toy example Ch6 and Ch7 when JIT is unavailable

17 months ago[ADT] FloatingPointMode.h - add missing closing namespace comment. NFC.
Simon Pilgrim [Wed, 25 Jan 2023 12:55:55 +0000 (12:55 +0000)]
[ADT] FloatingPointMode.h - add missing closing namespace comment. NFC.

Fixes clang-tidy warning

17 months ago[clang][Interp] Add empty messages to static_asserts
Timm Bäder [Wed, 25 Jan 2023 14:19:17 +0000 (15:19 +0100)]
[clang][Interp] Add empty messages to static_asserts

To satisfy builders:
https://lab.llvm.org/buildbot/#/builders/216/builds/16264

17 months ago[mlir][doc] Fix syntax for affine.dam_wait
Xiang Li [Tue, 17 Jan 2023 03:29:12 +0000 (22:29 -0500)]
[mlir][doc] Fix syntax for affine.dam_wait

Change dma_Start to dma_wait for affine.dma_wait.
Also change dma_Start to dma_start for affine.dma_start.

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

17 months agoRe-apply "[clang][Interp] Support floating-point values"
Timm Bäder [Wed, 25 Jan 2023 13:51:16 +0000 (14:51 +0100)]
Re-apply "[clang][Interp] Support floating-point values"

Don't move the Repr struct into Integral this time.

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

17 months ago[mlir][LLVM] Add param attr verifiers
Christian Ulmann [Wed, 25 Jan 2023 13:59:24 +0000 (14:59 +0100)]
[mlir][LLVM] Add param attr verifiers

This commit introduces unified parameter attribute verifiers to the LLVM
dialect and removes according checks in the export. As LLVM does not
verify the validity of certain attributes on return values, this commit
unifies the handling of argument and result attributes wherever possible.

Depends on D142212

Reviewed By: gysit

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

17 months agoFix one of the regressions found in revert of concept sugaring
Erich Keane [Tue, 24 Jan 2023 20:49:24 +0000 (12:49 -0800)]
Fix one of the regressions found in revert of concept sugaring

It seems that the sugaring patches had some pretty significant
interdependencies, and at least one issue exists that requires part of
the concept-sugaring patch.  I don't believe this to have anything to do
with the increased compile-times that were seen, so hopefully this will
fix our problems without further regressions.

See https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122
for discussion.

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

17 months ago[bazel] fix for 494734b06d62b54fdcbd982f96274dede572ba07
Krasimir Georgiev [Wed, 25 Jan 2023 14:00:10 +0000 (14:00 +0000)]
[bazel] fix for 494734b06d62b54fdcbd982f96274dede572ba07

17 months ago[Flang][Debug] Use pathnames from location of functions
Kiran Chandramohan [Wed, 25 Jan 2023 13:37:54 +0000 (13:37 +0000)]
[Flang][Debug] Use pathnames from location of functions

This ensures that functions in included files have the correct path
in their file metadata.

Note: This patch also sets all locations to have the full path names.

Reviewed By: vzakhari, PeteSteinfeld

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

17 months agoRevert "[clang][Interp] Support floating-point values"
Timm Bäder [Wed, 25 Jan 2023 13:48:16 +0000 (14:48 +0100)]
Revert "[clang][Interp] Support floating-point values"

This reverts commit 62f43c3eae2460d4ca3da7897fd2d7c56920638c.

This breaks a couple of builders, e.g.

https://lab.llvm.org/buildbot/#/builders/139/builds/34925

17 months ago[TableGen] Speed up computeUberSets. NFC.
Jay Foad [Tue, 24 Jan 2023 11:56:09 +0000 (11:56 +0000)]
[TableGen] Speed up computeUberSets. NFC.

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

17 months ago[MC] Remove MCInstrDesc::opInfo_begin/end, unused since D142213
Jay Foad [Wed, 25 Jan 2023 11:40:19 +0000 (11:40 +0000)]
[MC] Remove MCInstrDesc::opInfo_begin/end, unused since D142213

17 months ago[clang][Interp] Support floating-point values
Timm Bäder [Sun, 30 Oct 2022 06:28:56 +0000 (07:28 +0100)]
[clang][Interp] Support floating-point values

Add a new Floating type and a few new opcodes to support floating point
values.

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

17 months ago[Polly] Convert some tests to opaque pointers (NFC)
Nikita Popov [Wed, 25 Jan 2023 13:22:31 +0000 (14:22 +0100)]
[Polly] Convert some tests to opaque pointers (NFC)

Convert ScopInfo tests.

17 months ago[gn build] Port a7a4463acbe1
LLVM GN Syncbot [Wed, 25 Jan 2023 13:27:16 +0000 (13:27 +0000)]
[gn build] Port a7a4463acbe1

17 months ago[LoopVectorize] Enable integer Mul and Add as select reduction patterns
Matt Devereau [Mon, 16 Jan 2023 09:20:17 +0000 (09:20 +0000)]
[LoopVectorize] Enable integer Mul and Add as select reduction patterns

This patch vectorizes Phi node loop reductions for select's whos condition
comes from a floating-point comparison, with its operands being integers
for Add, Sub, and Mul reductions.

Example:

int foo(float *x, int n) {
    int sum = 0;
    for (int i=0; i<n; ++i) {
        float elem = x[i];
        if (elem > 0) {
            sum += 2;
        }
    }
    return sum;
}

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

17 months ago[clang][Interp] Array initialization via string literal
Timm Bäder [Sat, 5 Nov 2022 13:04:56 +0000 (14:04 +0100)]
[clang][Interp] Array initialization via string literal

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

17 months ago[MLIR] Remove LLVM typed pointer support
Nikita Popov [Wed, 25 Jan 2023 13:15:01 +0000 (14:15 +0100)]
[MLIR] Remove LLVM typed pointer support

This breaks lowering to typed pointers, and forces import to always
use opaque pointers.

This has no effect on MLIR-level typed pointer support in the
LLVMIR dialect.

17 months ago[mlir][arith] Don't crash when folding a & ~a -> 0 on vectors
Benjamin Kramer [Wed, 25 Jan 2023 13:07:48 +0000 (14:07 +0100)]
[mlir][arith] Don't crash when folding a & ~a -> 0 on vectors

m_Constant happily accepts vector splats, so just use the generic way of
getting a zero attribute.

17 months ago[clang][Interp] Start implementing builtin functions
Timm Bäder [Sat, 5 Nov 2022 12:08:40 +0000 (13:08 +0100)]
[clang][Interp] Start implementing builtin functions

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

17 months ago[mlir] Improve line breaks of code snippets in comments (NFC).
Ingo Müller [Wed, 25 Jan 2023 10:04:32 +0000 (10:04 +0000)]
[mlir] Improve line breaks of code snippets in comments (NFC).

Reviewed By: ingomueller-net

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

17 months ago[clang][Interp] Specify c++ standard used in switch test
Timm Bäder [Wed, 25 Jan 2023 12:32:21 +0000 (13:32 +0100)]
[clang][Interp] Specify c++ standard used in switch test

As a follow up for 024e4f16ca795b98a5dea371cab623f851858925.

This should fix builders defaulting to pre-c++17.
E.g. https://lab.llvm.org/buildbot/#/builders/139/builds/34918

17 months ago[SVE][InstrFormats] Explcitly set hasSideEffects for all SVE instructions.
Paul Walker [Thu, 19 Jan 2023 13:45:36 +0000 (13:45 +0000)]
[SVE][InstrFormats] Explcitly set hasSideEffects for all SVE instructions.

The instruction property hasSideEffects relies on the presence of
tablegen isel patterns when constructing its value, unless
specifically overriden. Since adding SVE scheduling information
we've noticed this property flip-flop as isel patterns have been
updated. To make things consistent (and correct) this patch
explicitly sets the property for all SVE instructions.

This has resulted in the following notable changes:
* Normal load and store instructions no longer report having side
  effects.
* All prefetch instructions correctly report having side effects.
* FFR related instructions continue to report having side effects.
  This is likely overkill but I've chosen to remain cautious here.
* Most all integer instructions no longer report having side effects.
* Most all floating point instructions no longer report having side
  effects, but do now report their potential for raising FP
  exceptions. I do not know how to test the latter so I've again
  took a caution route of taging all floating point instructions
  except for DUPs.
* The conflict detection intrinsics now report they don't touch
  memory.

NOTE: SVE isel makes significant use of psuedo instructions but
this patch makes no effort to update them.

NOTE: We'll need a similar patch for SME but without a scheduling
model it'll be harder to verify the results.

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

17 months ago[AArch64] Codegen for FEAT_LRCPC3
Tomas Matheson [Wed, 25 Jan 2023 12:03:47 +0000 (12:03 +0000)]
[AArch64] Codegen for FEAT_LRCPC3

Implements support for the following 128-bit atomic operations with +rcpc3:
 - 128-bit store-release -> STILP
 - 128-bit load-acquire -> LDIAPP

D126250 and D137590 added support for emitting LDAPR (Load-Acquire RCPc) rather
than LDAP (Load-Acquire) when +rcpc is available. This patch allows emitting
the 128-bit RCPc instructions added in FEAT_LRCPC3 (LDIAPP/STILP). The
implementation is different from LDAPR, because there are no non-RCPc
equivalents for these new instructions.

Support for the offset variants will be added in D141431.

Reviewed By: lenary

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

17 months ago[SCCP] Add extra tests for Add flag inference.
Florian Hahn [Wed, 25 Jan 2023 12:22:56 +0000 (12:22 +0000)]
[SCCP] Add extra tests for Add flag inference.

Add extra tests from #60280 and #60278 as well as test showing missed
optimization opportunity.

17 months ago[clang][Interp] Implement switch statements
Timm Bäder [Fri, 4 Nov 2022 12:27:22 +0000 (13:27 +0100)]
[clang][Interp] Implement switch statements

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

17 months ago[MLIR] Convert remaining tests to opaque pointers (NFC)
Nikita Popov [Wed, 25 Jan 2023 11:51:38 +0000 (12:51 +0100)]
[MLIR] Convert remaining tests to opaque pointers (NFC)

These were the final tests using -opaque-pointers=0 in mlir/.

17 months ago[AArch64] Codegen for FEAT_LSE128
Tomas Matheson [Wed, 25 Jan 2023 11:59:10 +0000 (11:59 +0000)]
[AArch64] Codegen for FEAT_LSE128

Codegen support for 128-bit atomicrmw (and|or|xchg).
      - store atomic -> swpp
      - atomicrmw xchg -> swpp
      - atomicrmw and -> ldclrp
      - atomicrmw or -> ldsetp

Reviewed By: lenary

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

17 months ago[clang][Interp] Reject invalid declarations and expressions
Timm Bäder [Fri, 4 Nov 2022 04:58:59 +0000 (05:58 +0100)]
[clang][Interp] Reject invalid declarations and expressions

Reject them early, since we will run into problems and/or assertions
later on anyway.

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

17 months ago[Support] Avoid using main thread for llvm::parallelFor().
Alexey Lapshin [Tue, 24 Jan 2023 13:05:43 +0000 (14:05 +0100)]
[Support] Avoid using main thread for llvm::parallelFor().

The llvm::parallelFor() uses threads created by ThreadPoolExecutor as well as main thread.
The index for the main thread matches with the index for the first thread created by ThreadPoolExecutor.
It results in that getThreadIndex returns the same value for different threads.
To avoid thread index clashing - do not use main thread for llvm::parallelFor():

parallel::TaskGroup TG;
for (; Begin + TaskSize < End; Begin += TaskSize) {
  TG.spawn([=, &Fn] {
    for (size_t I = Begin, E = Begin + TaskSize; I != E; ++I)
      Fn(I);
  });
}
for (; Begin != End; ++Begin)    <<<< executed by main thread.
  Fn(Begin);                     <<<<
return;                          <<<<

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

17 months ago[LTO] Remove OpaquePointers option from config (NFC)
Nikita Popov [Wed, 25 Jan 2023 11:37:56 +0000 (12:37 +0100)]
[LTO] Remove OpaquePointers option from config (NFC)

Always use opaque pointers.

17 months ago[AArch64][SME2] Add intrinsics to move multi-vectors to/from ZA.
Kerry McLaughlin [Wed, 25 Jan 2023 10:56:18 +0000 (10:56 +0000)]
[AArch64][SME2] Add intrinsics to move multi-vectors to/from ZA.

Adds intrinsics for the following:
 - mova: array to vector / vector to array
 - mova: tile to vector / vector to tile

Tablegen patterns have been added to match the ZA write intrinsics. As the
read intrinsics return a multi-vector, a function called SelectMultiVectorMove
has been added to AArch64ISelDAGToDAG to select the correct instruction. The
SelectSMETile function has also been added to check that the tile number
passed to read intrinsics is valid for the base register.

This patch also cleans up the sme_vector_to_tile_patterns multiclass to remove
the pattern for an offset of 0, which is handled by tileslice.

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

17 months ago[clang][Interp] Fix ImplicitValueInitExprs for pointer types
Timm Bäder [Wed, 2 Nov 2022 09:28:21 +0000 (10:28 +0100)]
[clang][Interp] Fix ImplicitValueInitExprs for pointer types

This previously ran into an "unknown type" assertion when trying to emit
a 'Zero' op for a pointer type. Emit a NullPtr op instead.

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

17 months ago[LLD] Remove no-opaque-pointers plugin option
Nikita Popov [Wed, 25 Jan 2023 11:29:59 +0000 (12:29 +0100)]
[LLD] Remove no-opaque-pointers plugin option

We always use opaque pointers. The opaque-pointers option is
retained as a no-op, same as no-lto-legacy-pass-manager.

17 months ago[gold] Remove no-opaque-pointers option
Nikita Popov [Wed, 25 Jan 2023 11:26:57 +0000 (12:26 +0100)]
[gold] Remove no-opaque-pointers option

The opaque-pointers option is retained as a no-op, same as with
new-pass-manager.

17 months ago[LTO] Remove -lto-opaque-pointers flag
Nikita Popov [Wed, 25 Jan 2023 11:04:51 +0000 (12:04 +0100)]
[LTO] Remove -lto-opaque-pointers flag

Always use the config default of OpaquePointers == true.

17 months ago[clang][Interp] Support inc/dec operators for pointers
Timm Bäder [Wed, 2 Nov 2022 08:09:23 +0000 (09:09 +0100)]
[clang][Interp] Support inc/dec operators for pointers

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

17 months ago[X86] Ensure the _mm_test_all_ones macro does not reuse argument (PR60006)
Simon Pilgrim [Wed, 25 Jan 2023 10:55:56 +0000 (10:55 +0000)]
[X86] Ensure the _mm_test_all_ones macro does not reuse argument (PR60006)

The macro _mm_test_all_ones(V) was defined as _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V))) - which could cause side effects depending on the source of the V value.

The _mm_cmpeq_epi32((V), (V)) trick was just to materialize an all-ones value, which can be more safely generated with _mm_set1_epi32(-1) .

Fixes #60006

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

17 months ago[AArch64][SME2] Add Multi-vector add/sub and accumulate into ZA intrinsic
Caroline Concatto [Wed, 25 Jan 2023 09:29:48 +0000 (09:29 +0000)]
[AArch64][SME2] Add Multi-vector add/sub and accumulate into ZA intrinsic

Add the following intrinsic:
    ADD
    SUB
    FADD
    FSUB
NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: kmclaughlin

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

17 months ago[NFC][WebAssembly] More fpclamptosat tests
Samuel Parker [Wed, 25 Jan 2023 10:19:51 +0000 (10:19 +0000)]
[NFC][WebAssembly] More fpclamptosat tests

17 months ago[clang][Interp] Fix dereferencing arrays with no offset applied
Timm Bäder [Mon, 31 Oct 2022 14:48:15 +0000 (15:48 +0100)]
[clang][Interp] Fix dereferencing arrays with no offset applied

A pointer to an array and a pointer to the first element of the array
are not the same in the interpreter, so handle this specially in
deref().

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

17 months ago[InstCombine] Add additional tests for dead phi cycles (NFC)
Nikita Popov [Wed, 25 Jan 2023 09:46:43 +0000 (10:46 +0100)]
[InstCombine] Add additional tests for dead phi cycles (NFC)

17 months ago[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out codegen to FIR.
Jean Perier [Wed, 25 Jan 2023 08:54:50 +0000 (09:54 +0100)]
[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out codegen to FIR.

Use runtime Assign to deal with the copy (and the temporary creation, so
that this code can deal with polymorphic temps without any change).

Using Assign for the copy is desired here since the copy happens when
the data is not contiguous, and it happens inside an if/then which
makes it hard to optimize.
See https://github.com/llvm/llvm-project/commit/2b60ed405b8110b20ab2e383839759ea34003127
for more details (note that, contrary to this last commit, the code at
hand is only dealing with copy-in/copy-out, it is not intended to deal
with preparing VALUE arguments).

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

17 months ago[AArch64][SME2] Add the IR intrinsics for SME2 fclamp, sclamp and uclamp instructions
David Sherwood [Mon, 23 Jan 2023 13:38:53 +0000 (13:38 +0000)]
[AArch64][SME2] Add the IR intrinsics for SME2 fclamp, sclamp and uclamp instructions

Adds intrinsics for the following SME2 instructions:

* fclamp (2 and 4 vectors)
* sclamp (2 and 4 vectors)
* uclamp (2 and 4 vectors)

I've added these new instructions to the existing sve2p1-* tests
because although they are included as part of SME2 they are still
SVE-like, in that they only operate on SVE vectors.

NOTE: These intrinsics are still in development and are subject to future changes.

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

17 months ago[clang][Interp] Re-apply "Implement missing compound assign operators"
Timm Bäder [Mon, 31 Oct 2022 11:44:38 +0000 (12:44 +0100)]
[clang][Interp] Re-apply "Implement missing compound assign operators"

Implement mul, div, rem, etc. compound assign operators.

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

17 months ago[clang][Interp] Fix compound assign operator types
Timm Bäder [Sun, 22 Jan 2023 20:09:35 +0000 (21:09 +0100)]
[clang][Interp] Fix compound assign operator types

Just like we do (or will do) for floating types, we need to take into
acocunt that the LHSComputationType, ResultType and type of the
expression (what we ultimately store) might be different.

Do this by emitting cast ops before and after doing the computation.

This fixes the test failures introduced by
490e8214fca48824beda8b508d6d6bbbf3d8d9a7 on big endian machines.

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

17 months agoUpdateTestChecks: cleanup NamelessValues constructor
Nicolai Hähnle [Tue, 17 Jan 2023 15:18:32 +0000 (16:18 +0100)]
UpdateTestChecks: cleanup NamelessValues constructor

Remove global_ir_{prefix,prefix_regexp} (one of which is misnamed),
since they are really quite redundant with ir_{prefix,regexp} and
default the is_before_functions argument, which basically just adds
noise to the table of NamelessValues.

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

17 months agoupdate_test_checks.py: pick up --tool from UTC_ARGS
Nicolai Hähnle [Mon, 23 Jan 2023 09:38:53 +0000 (10:38 +0100)]
update_test_checks.py: pick up --tool from UTC_ARGS

It's not clear to me how to write a test for this. The tests run in an
environment where the tools may not be in PATH, and so the existing
custom-tool.test needs to use --tool-binary when invoking
update_test_checks.py. But it can't do so without also using --tool.

This change does fix a problem though with using
update_any_test_checks.py in an environment where the tools *are*
available in PATH.

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

17 months ago[NFC][LLDB] Rename test file
Pavel Kosov [Wed, 25 Jan 2023 08:55:03 +0000 (11:55 +0300)]
[NFC][LLDB] Rename test file

Commit 92f0e4cca introduced test file with name TestChangeValue.py,
which leads to test failure because there already is a test files with the same name
In this commit a newly added file is renamed to fix this failure

17 months ago[Docs] Typed pointers are no longer supported
Nikita Popov [Wed, 25 Jan 2023 08:52:42 +0000 (09:52 +0100)]
[Docs] Typed pointers are no longer supported

As promised, typed pointers are no longer supported on the main
branch, as a matter of policy.

17 months ago[AMDGPU][MC][NFC] MUBUF code cleanup
Piotr Sobczak [Wed, 25 Jan 2023 08:42:53 +0000 (09:42 +0100)]
[AMDGPU][MC][NFC] MUBUF code cleanup

- Simplify concatenation
- Common up expressions

17 months ago[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out operations
Jean Perier [Wed, 25 Jan 2023 08:50:19 +0000 (09:50 +0100)]
[flang][hlfir] Add hlfir.copy_in and hlfir.copy_out operations

These operations implement the optional copy of a non contiguous
variable into a temporary before a call, and the copy back from the
temporary after the call.

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

17 months ago[mlir][linalg] Convert tensor.from_elements to destination style
Matthias Springer [Wed, 25 Jan 2023 08:07:59 +0000 (09:07 +0100)]
[mlir][linalg] Convert tensor.from_elements to destination style

This can be a pre-processing for bufferization and allows for more efficient lowerings without an alloc.

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

17 months ago[flang] Fix bounds array creation for pointer remapping calls
Valentin Clement [Wed, 25 Jan 2023 08:17:27 +0000 (09:17 +0100)]
[flang] Fix bounds array creation for pointer remapping calls

`PointerAssociateRemapping` expect a descriptor holding
a newRank x 2 array of int64. The previous lowering was wrong.
Adapt the lowering to fit the expectation of the runtime.
Use the `bounds` to get the rank.

Reviewed By: PeteSteinfeld

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

17 months ago[libc][Obvious] Disable log10_test as it is failing on the x86_64 builders.
Siva Chandra Reddy [Wed, 25 Jan 2023 08:13:45 +0000 (08:13 +0000)]
[libc][Obvious] Disable log10_test as it is failing on the x86_64 builders.

17 months ago[lldb] Consider all breakpoints in breakpoint detection
Pavel Kosov [Wed, 25 Jan 2023 07:50:02 +0000 (10:50 +0300)]
[lldb] Consider all breakpoints in breakpoint detection

Currently in some cases lldb reports stop reason as "step out" or "step over" (from thread plan completion) instead of "breakpoint", if the user breakpoint happens to be set on the same address.
The part of https://github.com/llvm/llvm-project/commit/f08f5c99262ff9eaa08956334accbb2614b0f7a2 seems to overwrite internal breakpoint detection logic, so that only the last breakpoint for the current stop address is considered.
Together with step-out plans not clearing its breakpoint until they are destrouyed, this creates a situation when there is a user breakpoint set for address, but internal breakpoint makes lldb report a plan completion stop reason instead of breakpoint.
This patch reverts that internal breakpoint detection logic to consider all breakpoints

Reviewed By: jingham

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

17 months ago[llvm] Use llvm::bit_ceil instead of PowerOf2Ceil (NFC)
Kazu Hirata [Wed, 25 Jan 2023 08:05:33 +0000 (00:05 -0800)]
[llvm] Use llvm::bit_ceil instead of PowerOf2Ceil (NFC)

The arguments to PowerOf2Ceil in this patch are all known to be
nonzero, so we can safely use llvm::bit_ceil here.

17 months ago[libc][NFC] Detect host CPU features using try_compile instead of try_run.
Guillaume Chatelet [Wed, 25 Jan 2023 07:48:04 +0000 (07:48 +0000)]
[libc][NFC] Detect host CPU features using try_compile instead of try_run.

This implements the same behavior as D141997 but makes sure that the same detection mechanism is used between CMake and source code.

Reviewed By: sivachandra, lntue

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

17 months ago[LLDB] Fixes summary formatter for libc++ map allowing modification of contained...
Pavel Kosov [Wed, 25 Jan 2023 07:48:04 +0000 (10:48 +0300)]
[LLDB] Fixes summary formatter for libc++ map allowing modification of contained value

Reviewed By: clayborg

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

17 months ago[IndVars] Expand icmp in preheader rather than in loop
Max Kazantsev [Wed, 25 Jan 2023 07:06:08 +0000 (14:06 +0700)]
[IndVars] Expand icmp in preheader rather than in loop

The motivation is that 'createInvariantCond' unconditionally
builds icmp in the loop block,  while it could always do it
in preheader. Build it in preheader instead.

Patch by Aleksandr Popov!

Differential Revision: https://reviews.llvm.org/D141994
Reviewed By: nikic

17 months ago[LLDB] Fix for libc++ atomic allowing modification of contained value
Pavel Kosov [Wed, 25 Jan 2023 07:39:50 +0000 (10:39 +0300)]
[LLDB] Fix for libc++ atomic allowing modification of contained value

Reviewed By: clayborg

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

17 months agolibcxx: Don't apply ABI tags to extern "C" fns
Arsen Arsenović [Wed, 25 Jan 2023 07:34:55 +0000 (07:34 +0000)]
libcxx: Don't apply ABI tags to extern "C" fns

GCC rejects ABI tags on non mangled functions, as they would otherwise
be a no-op.  This commit replaces such instances with equivalent
_LIBCPP_HIDE_FROM_ABI constants but without ABI tags attached.

  .../include/c++/v1/__support/musl/xlocale.h:28:68: error: 'abi_tag'
  attribute applied to extern "C" declaration 'long long int
  strtoll_l(const char*, char**, int, locale_t)'
     28 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) {
        |                                                                    ^

Bug: https://bugs.gentoo.org/869038

Reviewed By: #libc, ldionne

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

17 months ago[X86] Use llvm::countr_zero instead of findFirstSet (NFC)
Kazu Hirata [Wed, 25 Jan 2023 07:26:08 +0000 (23:26 -0800)]
[X86] Use llvm::countr_zero instead of findFirstSet (NFC)

At the call site of findFirstSet, ZMask | (1 << DstIdx) always have
exactly 3 bits set, and they are all among the 4 least significant
bits, so (ZMask | (1 << DstIdx)) ^ 15 has exactly one bit set.  Since
the argument to findFirstSet is nonzero, we can safely switch to
llvm::countr_zero.

17 months ago[MLIR] Expose LocationAttrs in the C API
Andrew Young [Wed, 25 Jan 2023 07:13:20 +0000 (23:13 -0800)]
[MLIR] Expose LocationAttrs in the C API

This patch adds three functions to the C API:
- mlirAttributeIsALocation: returns true if the attribute is a LocationAttr,
  false otherwise.
- mlirLocationGetAttribute: returns the underlying LocationAttr of a Location.
- mlirLocationFromAttribute: gets a Location from a LocationAttr.

Reviewed By: mikeurbach, Mogball

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

17 months ago[libc][NFC] Another round of replacement of "inline" with "LIBC_INLINE".
Siva Chandra Reddy [Tue, 24 Jan 2023 22:31:51 +0000 (22:31 +0000)]
[libc][NFC] Another round of replacement of "inline" with "LIBC_INLINE".

Reviewed By: michaelrj

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

17 months agoBump the trunk major version to 17
Tom Stellard [Wed, 25 Jan 2023 06:55:53 +0000 (22:55 -0800)]
Bump the trunk major version to 17

17 months ago[CodeGen] Use llvm::bit_ceil (NFC)
Kazu Hirata [Wed, 25 Jan 2023 06:54:53 +0000 (22:54 -0800)]
[CodeGen] Use llvm::bit_ceil (NFC)

If we know that x is nonzero and not a power of 2, then
llvm::findLastSet(x) + 1 is the index of the bit just above the
highest set bit in x.  That is, 1 << (llvm::findLastSet(x) + 1) is the
same as llvm::bit_ceil(x).

Since llvm::bit_ceil is a nop on a power of 2, we can unconditionally
call llvm::bit_ceil.  The end result actually matches the comment.

17 months ago[SystemZ] Use llvm::bit_floor (NFC)
Kazu Hirata [Wed, 25 Jan 2023 06:10:02 +0000 (22:10 -0800)]
[SystemZ] Use llvm::bit_floor (NFC)

If x is known to be nonzero, findLastSet(x) returns the index of the
highest set bit counting from the LSB, so 1 << findLastSet(x) is the
same as llvm::bit_floor(x).

17 months ago[M68k][MC] Make immediate operands relocatable
Min-Yih Hsu [Tue, 11 Oct 2022 05:07:48 +0000 (22:07 -0700)]
[M68k][MC] Make immediate operands relocatable

Sometimes memory addresses are treated as immediate values. Thus
immediate operands have to be relocatable.

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

17 months ago[M68k][Disassembler] Use custom decoder for 32-bit immediates
Min-Yih Hsu [Mon, 21 Nov 2022 06:38:09 +0000 (22:38 -0800)]
[M68k][Disassembler] Use custom decoder for 32-bit immediates

32-bit immediates require special cares because they go across the
normal word (16 bits) boundaries.
This patch also fixes some incorrect disassembler test cases.

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

17 months ago[TableGen] Support custom decoders for variable length instructions
Min-Yih Hsu [Mon, 21 Nov 2022 06:35:27 +0000 (22:35 -0800)]
[TableGen] Support custom decoders for variable length instructions

Just like the encoder directive for variable-length instructions, this
patch adds a new decoder directive to allow custom decoder function on
an operand.

Right now, due to the design of DecoderEmitter each operand can only
have a single custom decoder in a given instruction.

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

17 months ago[zero-call-used-regs] Mark only non-debug instruction's register as used
Shivam Gupta [Mon, 23 Jan 2023 18:16:04 +0000 (23:46 +0530)]
[zero-call-used-regs] Mark only non-debug instruction's register as used

zero-call-used-regs pass generate an xor instruction to help mitigate
return-oriented programming exploits via zeroing out used registers. But
in this below test case with -g option there is dbg.value instruction
associating the register with the debug-info description of the formal
parameter d, which makes the register appear used, therefore it zero the
register edi in -g case and makes binary different from without -g option.

The pass should be looking only at the non-debug uses.

$ cat test.c
char a[];
int b;
__attribute__((zero_call_used_regs("used"))) char c(int d) {
  *a = ({
    int e = d;
    b;
  });
}

This fixes https://github.com/llvm/llvm-project/issues/57962.

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

17 months agoRevert "[SCCP] Use range info to prove AddInst has NUW flag."
Douglas Yung [Wed, 25 Jan 2023 05:19:25 +0000 (21:19 -0800)]
Revert "[SCCP] Use range info to prove AddInst has NUW flag."

This reverts commit de122cb920080fd9e24b2777114271fbef932d5e.

This change causes assertion failures in many of our internal tests.
I have filed #60280 for this issue.

17 months agoRevert "[clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions...
Carlos Galvez [Wed, 25 Jan 2023 05:06:43 +0000 (05:06 +0000)]
Revert "[clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions options"

This reverts commit 4240c9146248ac0a91c45dee421c6ef07709ba74.

The current solution won't work since getLocalOrGlobal does not
support returning a vector. More work needs to be put into
ensuring both the local and global way of setting the options
are available during the transition period.

17 months agoFix running MLIR tests when enabling examples but the native backends isn't configure...
Mehdi Amini [Wed, 25 Jan 2023 04:32:20 +0000 (20:32 -0800)]
Fix running MLIR tests when enabling examples but the native backends isn't configured (NFC)

17 months ago[Transform] Rewrite LowerSwitch using APInt
Peter Rong [Thu, 12 Jan 2023 18:58:38 +0000 (10:58 -0800)]
[Transform] Rewrite LowerSwitch using APInt

This rewrite fixes https://github.com/llvm/llvm-project/issues/59316.

Previously LowerSwitch uses int64_t, which will crash on case branches using integers with more than 64 bits.
Using APInt fixes this problem. This patch also includes a test

Reviewed By: RKSimon

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

17 months ago[AssumptionCache] caches @llvm.experimental.guard's
Joshua Cao [Mon, 23 Jan 2023 07:26:37 +0000 (23:26 -0800)]
[AssumptionCache] caches @llvm.experimental.guard's

As discussed in https://github.com/llvm/llvm-project/issues/59901

This change is not NFC. There is one SCEV and EarlyCSE test that have an
improved analysis/optimization case. Rest of the tests are not failing.

I've mostly only added cleanup to SCEV since that is where this issue
started. As a follow up, I believe there is more cleanup opportunity in
SCEV and other affected passes.

There could be cases where there are missed registerAssumption of
guards, but this case is not so bad because there will be no
miscompilation. AssumptionCacheTracker should take care of deleted
guards.

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

17 months ago[Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table
Shilei Tian [Wed, 25 Jan 2023 03:48:56 +0000 (22:48 -0500)]
[Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

In Clang, in order to determine the type of `omp_allocator_handle_t`, Clang
checks the type of those predefined allocators. The first one it checks is
`omp_null_allocator`. If the language is C, and the system is 64-bit, what Clang
gets is a `int`, instead of an enum of size 8, given the fact how we define
`omp_allocator_handle_t` in `omp.h`.  If the allocator is captured by a region,
let's say a parallel region, the allocator will be privatized. Because Clang deems
`omp_allocator_handle_t` as an `int`, it will first cast the value returned by
the runtime library (for `libomp` it is a `void *`) to `int`, and then in the
outlined function, it casts back to `omp_allocator_handle_t`. This two casts
completely shaves the first 32-bit of the pointer value returned from `libomp`,
and when the private "new" pointer is fed to another runtime function
`__kmpc_allocate()`, it causes segment fault. That is the root cause of PR54082.
I have no idea why `-fno-pic` could hide this bug.

In this patch, we detect `omp_allocator_handle_t` using roughly the same method
as `omp_event_handle_t`, by looking it up into the identifier table.

Fix #54082.

Reviewed By: ABataev

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

17 months ago[lldb] Remove legacy six module for py2->py3
Jordan Rupprecht [Wed, 25 Jan 2023 03:46:26 +0000 (19:46 -0800)]
[lldb] Remove legacy six module for py2->py3

LLDB only supports Python3 now, so the `six` shim for Python2 is no longer necessary.

Reviewed By: JDevlieghere

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

17 months ago[lldb] Don't create Clang AST nodes in GetDIEClassTemplateParams
Arthur Eubanks [Mon, 23 Jan 2023 23:37:57 +0000 (15:37 -0800)]
[lldb] Don't create Clang AST nodes in GetDIEClassTemplateParams

Otherwise we may be inserting a decl into a DeclContext that's not fully defined yet.

This simplifies/removes some clang AST node creation code. Instead, use
clang::printTemplateArgumentList().

Reviewed By: Michael137

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

17 months ago[Clang] Fix test that sometimes fails depending on the temp name
Joseph Huber [Wed, 25 Jan 2023 03:11:15 +0000 (21:11 -0600)]
[Clang] Fix test that sometimes fails depending on the temp name

Summary:
This test has a negative check for an extra file. it turns out that
sometimes the temp name can match it. Be more specific with it.

17 months ago[OpenMP] Create a temp file in /tmp if /dev/shm is not accessible
Shilei Tian [Wed, 25 Jan 2023 02:45:32 +0000 (21:45 -0500)]
[OpenMP] Create a temp file in /tmp if /dev/shm is not accessible

When `libomp` is initialized, it creates a temp file in `/dev/shm` to store
registration flag. Some systems, like Android, don't have `/dev/shm`, then this
feature is disabled by the macro `KMP_USE_SHM`, though most Linux distributions
have that. However, some customized distribution, such as the one reported in
https://github.com/llvm/llvm-project/issues/53955, doesn't support it either.
It causes a core dump. In this patch, if it is the case, we will try to create a
temporary file in `/tmp`, and if it still doesn't make it, then we error out.
Note that we don't consider in this patch if the temporary directory has been
set to `TMPDIR` in this patch. If `/tmp` is not accessible, we error out.

Fix #53955.

Reviewed By: jdoerfert

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

17 months ago[clang-format] Put peekNextToken(/*SkipComment=*/true) to good use
Owen Pan [Mon, 23 Jan 2023 23:30:38 +0000 (15:30 -0800)]
[clang-format] Put peekNextToken(/*SkipComment=*/true) to good use

To prevent potential bugs in situations where we want to peek the next
non-comment token.

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

17 months ago[libc++] Introduce a compile-time mechanism to override __libcpp_verbose_abort
Louis Dionne [Mon, 9 Jan 2023 21:59:59 +0000 (16:59 -0500)]
[libc++] Introduce a compile-time mechanism to override __libcpp_verbose_abort

This changes the mechanism for verbose termination (again!) to make it
support compile-time customization in addition to link-time customization,
which is important for users who need fine-grained control over what code
gets generated around sites that call the verbose termination handler.

This concern had been raised to me both privately by prospecting users
and in https://llvm.org/D140944, so I think it is clearly worth fixing.

We still support _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED for
a limited time since the same functionality can be achieved by overriding
the _LIBCPP_VERBOSE_ABORT macro.

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

17 months agotest-release.sh: Only build clang for stage1 and stage2
Tom Stellard [Wed, 25 Jan 2023 02:09:13 +0000 (18:09 -0800)]
test-release.sh: Only build clang for stage1 and stage2

The stage1 and stage2 builds aren't packaged, so we only need to build
enough of the toolchain to build the next phase.

Reviewed By: thieta, amyk

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

17 months ago[compiler-rt] Remove XFAIL decorator trampoline_setup_test.c
Muhammad Omair Javaid [Wed, 25 Jan 2023 01:12:40 +0000 (06:12 +0500)]
[compiler-rt] Remove XFAIL decorator trampoline_setup_test.c

This patch remove xfail decorator from
builtins/Unit/trampoline_setup_test.c as it is passing on Windows/AArch64
nowz. It is being skipped in code with __clang__ not defined.

https://lab.llvm.org/buildbot/#/builders/120/builds/3873

17 months ago[RISCV] Combine extract_vector_elt followed by VFMV_S_F_VL.
Craig Topper [Tue, 24 Jan 2023 23:26:42 +0000 (15:26 -0800)]
[RISCV] Combine extract_vector_elt followed by VFMV_S_F_VL.

If we're extracting an element and inserting into a undef vector
with the same number of elements, we can use the original vector.

This pattern occurs around reductions that have been cascaded
together.

This can be generalized to wider/narrow vectors by using
insert_subvector/extract_subvector, but we don't have lit tests
for that case currently.

We can also support non-undef before by using a slide or vmv.v.v

Reviewed By: reames

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

17 months ago[NFC][libc++] Remove __unexpected namespace
yronglin [Wed, 25 Jan 2023 01:10:01 +0000 (09:10 +0800)]
[NFC][libc++] Remove __unexpected namespace

Remove __unexpected namespace.

Reviewed By: philnik, #libc, ldionne

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

17 months ago[lld-macho] Have all load commands aligned to the word size
Jez Ng [Wed, 11 Jan 2023 07:23:15 +0000 (02:23 -0500)]
[lld-macho] Have all load commands aligned to the word size

This is what ld64 does, and also what we already do for most of the
other load commands. I'm not aware of a good way to test this, but I
don't think it really matters.

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

17 months ago[ADT] Use fold expressions to compare tuples. NFCI
Benjamin Kramer [Wed, 25 Jan 2023 00:38:28 +0000 (01:38 +0100)]
[ADT] Use fold expressions to compare tuples. NFCI

17 months ago[HWASAN] Copy some ASAN independent unit tests from ASAN to LSAN
Kirill Stoimenov [Tue, 24 Jan 2023 23:46:04 +0000 (23:46 +0000)]
[HWASAN] Copy some ASAN independent unit tests from ASAN to LSAN

Reviewed By: vitalybuka

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

17 months ago[CodeGen] bugfix: add REQUIRES target triple in test
usama hameed [Tue, 24 Jan 2023 23:59:19 +0000 (15:59 -0800)]
[CodeGen] bugfix: add REQUIRES target triple in test