platform/upstream/llvm.git
17 months ago[mlir][openacc] Use new reduction design in acc.loop
Valentin Clement [Wed, 24 May 2023 17:44:40 +0000 (10:44 -0700)]
[mlir][openacc] Use new reduction design in acc.loop

Use the new reduction design in acc.loop operation.

Depends on D151146

Reviewed By: razvanlupusoru, jeanPerier

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

17 months ago[msan] Implement __sanitizer_get_current_allocated_bytes
Vitaly Buka [Wed, 24 May 2023 17:35:34 +0000 (10:35 -0700)]
[msan] Implement __sanitizer_get_current_allocated_bytes

__sanitizer_get_current_allocated_bytes had as body, but allocator
caches were not registered to collect stats. It's done by
SizeClassAllocator64LocalCache::Init().

Reviewed By: kstoimenov

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

17 months ago[RISCV] Use vfslide1down for build_vectors of non-constant floats
Philip Reames [Wed, 24 May 2023 17:40:06 +0000 (10:40 -0700)]
[RISCV] Use vfslide1down for build_vectors of non-constant floats

This adds the vfslide1down (and vfslide1up for consistency) nodes. These mostly parallel the existing vslide1down/up nodes. (See note below on instruction semantics.) We then use the vfslide1down in build_vector lowering instead of going through the stack.

The specification is more than a bit vague on the meaning of these instructions. All we're given is "The vfslide1down instruction is defined analogously, but sources its scalar argument from an f register."

We have to combine this with a general note at the beginning of section 10. Vector Arithmetic Instruction Formats which reads: "For floating-point operations, the scalar can be taken from a scalar f register. If FLEN > SEW, the value in the f registers is checked for a valid NaN-boxed value, in which case the least-signicant SEW bits of the f register are used, else the canonical NaN value is used. Vector instructions where any floating-point vector operand’s EEW is not a supported floating-point type width (which includes when FLEN < SEW) are reserved.".

Note that floats are NaN-boxed when D is implemented.

Combining that all together, we're fine as long as the element type matches the vector type - which is does by construction.  We shouldn't have legal vectors which hit the reserved encoding case.  An assert is included, just to be careful.

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

17 months ago[mlir][openacc] Add check for the private list in acc.serial
Valentin Clement [Wed, 24 May 2023 17:39:00 +0000 (10:39 -0700)]
[mlir][openacc] Add check for the private list in acc.serial

Add the missing check on private list information. The
check is the same than the one done for acc.parallel.

Depends on D151146

Reviewed By: razvanlupusoru, jeanPerier

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

17 months ago[mlir][openacc] Add check for the private list in acc.serial
Valentin Clement [Wed, 24 May 2023 17:39:00 +0000 (10:39 -0700)]
[mlir][openacc] Add check for the private list in acc.serial

Add the missing check on private list information. The
check is the same than the one done for acc.parallel.

Depends on D151146

Reviewed By: razvanlupusoru, jeanPerier

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

17 months agoPublicly document the C & C++ Language WG meetings
Aaron Ballman [Wed, 24 May 2023 17:38:27 +0000 (13:38 -0400)]
Publicly document the C & C++ Language WG meetings

We've been hosting these meetings regularly for a while now, so this
begins advertising the meetings more widely.

17 months ago[mlir][openacc] Use new reduction design in acc.parallel
Valentin Clement [Wed, 24 May 2023 17:38:01 +0000 (10:38 -0700)]
[mlir][openacc] Use new reduction design in acc.parallel

After D150818 the reduction clause is represented
with a acc.reduction.recipe operation and an operand.
This patch updates the acc.parallel op for the new design.

Reviewed By: razvanlupusoru, jeanPerier

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

17 months ago[RISCV][InsertVSETVLI] Support constant VLs larger than immediate encoding
Philip Reames [Wed, 24 May 2023 17:31:54 +0000 (10:31 -0700)]
[RISCV][InsertVSETVLI] Support constant VLs larger than immediate encoding

The immediate field on the vsetivli is fairly limited. For larger vectors, we end up having to materialize a constant in a register. We hadn't plumbed the infrastructure to treat such materialized constants as constants for purpose of vsetvli elimination.

I only bothered to handle LI. We could extend this to LUI sequences, but well, 2048 elements is probably enough for all practical fixed length vector codegen. :)

The test delta does point out a related problem. At LMUL8, we see increased register allocation pressure, and we should probably either a) address register allocation remat, or b) be less aggressive about eliminating vsetvlis at high lmul. Note that high LMUL code is not generated much by default.

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

17 months ago[mlir] Fix a warning
Kazu Hirata [Wed, 24 May 2023 17:36:38 +0000 (10:36 -0700)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/GPU/IR/GPUDialect.cpp:175:2: error: extra ';'
  outside of a function is incompatible with C++98
  [-Werror,-Wc++98-compat-extra-semi]

17 months agoFix shared library build from 1c9a800.
Amy Kwan [Wed, 24 May 2023 17:09:19 +0000 (12:09 -0500)]
Fix shared library build from 1c9a800.

Fix the shared library build failure on clang-ppc64le-rhel from 1c9a800 as seen
in: https://lab.llvm.org/buildbot/#/builders/57/builds/27080/steps/6/logs/stdio

17 months ago[PowerPC] Remove asserts from the disassembler.
Stefan Pintilie [Wed, 24 May 2023 16:33:54 +0000 (12:33 -0400)]
[PowerPC] Remove asserts from the disassembler.

My previous patch had added a couple of asserts to the disassembler.
The problem with this is that the disassembler is not just used for the
text section it is also used to disassemble the data section of an
object where the bytes do not necessarily represent instructions. If the
data in the data section happens to look like an illegal instruction
then llvm-objdump will assert on data because it is finding an illegal
instruction that is not actually an instruction at all.

Reviewed By: nemanjai, #powerpc

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

17 months ago[tsan] Implement __sanitizer_purge_allocator
Vitaly Buka [Wed, 24 May 2023 17:21:03 +0000 (10:21 -0700)]
[tsan] Implement __sanitizer_purge_allocator

17 months ago[DebugInfo] Follow-up to D151001
Alex Langford [Tue, 23 May 2023 17:20:35 +0000 (10:20 -0700)]
[DebugInfo] Follow-up to D151001

I landed D151001 before it had gotten sign-off from all the reviewers.
This is a follow-up to address the additional feedback.

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

17 months ago[mlir] [gpu] [sparse] refined SparseHandle type
Kun Wu [Wed, 24 May 2023 16:43:38 +0000 (09:43 -0700)]
[mlir] [gpu] [sparse] refined SparseHandle type

Reviewed By: aartbik

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

17 months ago[flang] Support for PowerPC vector type
Kelvin Li [Tue, 23 May 2023 23:02:49 +0000 (19:02 -0400)]
[flang] Support for PowerPC vector type

The following PowerPC vector type syntax is added:

  VECTOR ( element-type-spec )

where element-type-sec is integer-type-spec, real-type-sec or unsigned-type-spec.

Two opaque types (__VECTOR_PAIR and __VECTOR_QUAD) are also added.

A finite set of functionalities are implemented in order to support the new types:
1. declare objects
2. declare function result
3. declare type dummy arguments
4. intrinsic assignment between the new type objects (e.g. v1=v2)
5. reference functions that return the new types

Submit on behalf of @tislam @danielcchen

Authors: @tislam @danielcchen

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

17 months agoRevert "[PowerPC] Simplify fp-to-int store optimization"
Vitaly Buka [Wed, 24 May 2023 16:58:32 +0000 (09:58 -0700)]
Revert "[PowerPC] Simplify fp-to-int store optimization"

Breaks https://lab.llvm.org/buildbot/#/builders/18/builds/9118

This reverts commit 8064caf83fb166b709bfe0e7641c5181341cb064.

17 months agoFix bazel build for https://reviews.llvm.org/D144552
Sterling Augustine [Wed, 24 May 2023 16:35:53 +0000 (09:35 -0700)]
Fix bazel build for https://reviews.llvm.org/D144552

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

17 months ago[MachineVerifier] Try harder to verify LiveIntervals
Jay Foad [Wed, 24 May 2023 11:00:01 +0000 (12:00 +0100)]
[MachineVerifier] Try harder to verify LiveIntervals

Verify the LiveIntervals analysis after a pass that claims to preserve
it, even if there are no further passes (apart from the verifier itself)
that would use the analysis.

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

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

17 months ago[clang] Don't define predefined macros multiple times
John Brawn [Wed, 17 May 2023 15:52:26 +0000 (16:52 +0100)]
[clang] Don't define predefined macros multiple times

Fix several instances of macros being defined multiple times
in several targets. Most of these are just simple duplication in a
TargetInfo or OSTargetInfo of things already defined in
InitializePredefinedMacros or InitializeStandardPredefinedMacros,
but there are a few that aren't:
 * AArch64 defines a couple of feature macros for armv8.1a that are
   handled generically by getTargetDefines.
 * CSKY needs to take care when CPUName and ArchName are the same.
 * Many os/target combinations result in __ELF__ being defined twice.
   Instead define __ELF__ just once in InitPreprocessor based on
   the Triple, which already knows what the object format is based
   on os and target.

These changes shouldn't change the final result of which macros are
defined, with the exception of the changes to __ELF__ where if you
explicitly specify the object type in the triple then this affects
if __ELF__ is defined, e.g. --target=i686-windows-elf results in it
being defined where it wasn't before, but this is more accurate as an
ELF file is in fact generated.

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

17 months agoFix "[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*"
Marco Elver [Wed, 24 May 2023 16:24:55 +0000 (18:24 +0200)]
Fix "[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*"

Fix typo introduced in 2f1e2a6b1ca2.

Reported-by: RamNalamothu
17 months agoRevert "[flang] use greedy mlir driver for stack arrays pass"
Tom Eccles [Wed, 24 May 2023 16:05:25 +0000 (16:05 +0000)]
Revert "[flang] use greedy mlir driver for stack arrays pass"

This reverts commit 74c2ec50f393bad8b31d0dd0bd8b2ff44d361198.

This caused a regression building spec2017 with -Ofast.

17 months agoBump coalescing limit
Matthias Braun [Fri, 19 May 2023 19:47:37 +0000 (12:47 -0700)]
Bump coalescing limit

This bumps the "large-interval-freq-threshold" limit in the register
coalescer to 256. The limit was introduced in
https://reviews.llvm.org/D59143 without much justify for the particular
value "100", so I hope bumping it is ok.

This change is motivated by bad codegen for the popular crc32c
algorithm; the code is often based/copied from this implementation:
https://github.com/htot/crc32c/blob/master/crc32c/crc32intelc.cc which
uses a duffs-device pattern with 128 switch-cases. There are examples in
RocksDB (https://github.com/facebook/rocksdb/blob/main/util/crc32c.cc)
and Folly
(https://github.com/facebook/folly/blob/main/folly/hash/detail/Crc32cDetail.cpp)
which are important use cases for us.

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

17 months ago[PowerPC] Do not attempt to combine fptoui without FPCVT
Nemanja Ivanovic [Wed, 24 May 2023 16:12:19 +0000 (11:12 -0500)]
[PowerPC] Do not attempt to combine fptoui without FPCVT

Commit 8064caf83fb166b709bfe0e7641c5181341cb064 added a call
to a function that performs this combine without checking whether
the target supports FPCVT. This caused asserts to trip on BE bots
as the default target does not have this feature.

17 months ago[libc++] Fixes clang-tidy plugin for clang-tidy 17.
Mark de Wever [Tue, 23 May 2023 15:22:12 +0000 (17:22 +0200)]
[libc++] Fixes clang-tidy plugin for clang-tidy 17.

When using with clang-tidy 17 Node.getAttrName() sometimes returns a
nullptr. This caused segfaults in the CI.

Reviewed By: philnik, #libc

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

17 months ago[ARM] Remove unused functions isExpImmValue, isExpImm, and isInvertedExpImm
Kazu Hirata [Wed, 24 May 2023 16:05:50 +0000 (09:05 -0700)]
[ARM] Remove unused functions isExpImmValue, isExpImm, and isInvertedExpImm

The last uses were removed by:

  commit 772e4931932270a82f38c83d4344c800b2f54eff
  Author: Simon Tatham <simon.tatham@arm.com>
  Date:   Thu Jan 23 11:53:27 2020 +0000

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

17 months agoAMDGPU: Add some new tests for class undef/poison handling
Matt Arsenault [Wed, 24 May 2023 14:59:42 +0000 (15:59 +0100)]
AMDGPU: Add some new tests for class undef/poison handling

17 months agoRevert "[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes...
Nikolas Klauser [Wed, 24 May 2023 15:46:13 +0000 (08:46 -0700)]
Revert "[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we have instantiated externally"

This reverts commit b3c9150062dc4264afb4a3d2790f071c1ebe0743.

There were unexpected breakages downstream. @EricWF is investigating.

17 months ago[mlir] Add support for multiple uses in transform.structured.fuse_into_containing_op
Harsh Menon [Wed, 24 May 2023 01:03:59 +0000 (18:03 -0700)]
[mlir] Add support for multiple uses in transform.structured.fuse_into_containing_op

In the tile and fuse of the first extract use, we add support
for scenarios where the results of the tiled op have uses
that are dominated by the scf.for_all. Specifically, we replace
the scf.for_all with a new scf.for_all that has an additional
shared_out and add the appropriate parallel insert slice op.

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

17 months ago[sanitizer] Add allocator_interface test
Vitaly Buka [Wed, 24 May 2023 07:31:15 +0000 (00:31 -0700)]
[sanitizer] Add allocator_interface test

Hooks are in malloc_hook.cpp.

17 months ago[libc++][format] Removes the experimental status.
Mark de Wever [Wed, 17 May 2023 17:17:52 +0000 (19:17 +0200)]
[libc++][format] Removes the experimental status.

The code has been quite ready for a while now and there are no more ABI
breaking papers. So this is a good time to mark the feature as stable.

Reviewed By: #libc, ldionne

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

17 months ago[libc] simplify test for getrandom
Guillaume Chatelet [Wed, 24 May 2023 14:43:00 +0000 (14:43 +0000)]
[libc] simplify test for getrandom

`getrandom` is implemented as a syscall.
We don't want to test linux implementation of the syscall. We just want to verify that it reacts as expected to sensible values.

Runtime before
```
[ RUN      ] LlvmLibcGetRandomTest.InvalidFlag
[       OK ] LlvmLibcGetRandomTest.InvalidFlag (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.InvalidBuffer
[       OK ] LlvmLibcGetRandomTest.InvalidBuffer (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.ReturnsSize
[       OK ] LlvmLibcGetRandomTest.ReturnsSize (took 83 ms)
[ RUN      ] LlvmLibcGetRandomTest.PiEstimation
[       OK ] LlvmLibcGetRandomTest.PiEstimation (took 9882 ms)
```

Runtime after
```
[ RUN      ] LlvmLibcGetRandomTest.InvalidFlag
[       OK ] LlvmLibcGetRandomTest.InvalidFlag (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.InvalidBuffer
[       OK ] LlvmLibcGetRandomTest.InvalidBuffer (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.ReturnsSize
[       OK ] LlvmLibcGetRandomTest.ReturnsSize (took 0 ms)
[ RUN      ] LlvmLibcGetRandomTest.CheckValue
[       OK ] LlvmLibcGetRandomTest.CheckValue (took 0 ms)
```

Reviewed By: lntue

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

17 months ago[flang] Fix SPACING() of very small values
Peter Klausler [Tue, 23 May 2023 20:55:23 +0000 (13:55 -0700)]
[flang] Fix SPACING() of very small values

SPACING() must return TINY() for zero arguments (which we do)
and also for subnormal values smaller than TINY() in absolute value,
which we get wrong.  Fix folding and the runtime.

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

17 months ago[mlir][LLVM] Fix aliasing in intrinsic base class
Christian Ulmann [Wed, 24 May 2023 14:52:54 +0000 (14:52 +0000)]
[mlir][LLVM] Fix aliasing in intrinsic base class

This commit fixes a bug in the intrinsic base class that caused the
declaration of alias analysis attributes under a wrong condition.

17 months ago[mlir][openacc] destroy region on firstprivate.recipe is optional
Valentin Clement [Wed, 24 May 2023 14:57:38 +0000 (07:57 -0700)]
[mlir][openacc] destroy region on firstprivate.recipe is optional

The destroy region is optional but the verifier was enforcing it.
Update the verifier and make it clear in the definition.

Reviewed By: razvanlupusoru

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

17 months ago[RISCV] Scalarize constant stores of fixed vectors if small enough
Luke Lau [Mon, 22 May 2023 16:51:32 +0000 (17:51 +0100)]
[RISCV] Scalarize constant stores of fixed vectors if small enough

For stores of small fixed-length vector constants, we can store them
with a sequence of lui/addi/sh/sw to avoid the cost of building the
vector and the vsetivli toggle, provided the constant materialization
cost isn't too high.

This subsumes the optimisation for stores of zeroes in
4dc9a2c5b93682c12d7a80bbe790b14ddb301877

(This is a reapply of 0ca13f9d2701e23af2d000a5d8f48b33fe0878b7)

Reviewed By: reames

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

17 months agoRevert "[RISCV] Scalarize constant stores of fixed vectors up to 32 bits"
Luke Lau [Wed, 24 May 2023 14:52:19 +0000 (15:52 +0100)]
Revert "[RISCV] Scalarize constant stores of fixed vectors up to 32 bits"

This reverts commit 0ca13f9d2701e23af2d000a5d8f48b33fe0878b7.

17 months ago[RISCV] Add test coverage for buildvector of FP values
Philip Reames [Wed, 24 May 2023 14:43:52 +0000 (07:43 -0700)]
[RISCV] Add test coverage for buildvector of FP values

17 months agoInline: Convert test to generated checks
Matt Arsenault [Wed, 24 May 2023 07:52:22 +0000 (08:52 +0100)]
Inline: Convert test to generated checks

17 months agoIR: Avoid include in FMF header
Matt Arsenault [Wed, 24 May 2023 13:24:49 +0000 (14:24 +0100)]
IR: Avoid include in FMF header

17 months ago[mlir][Transforms] Fix mlir-config flag check
Matthias Springer [Wed, 24 May 2023 14:30:57 +0000 (16:30 +0200)]
[mlir][Transforms] Fix mlir-config flag check

Boolean compiler flags (such as `DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS`) show up in `mlir-config.h` as preprocessor defines that are either 0 or 1. Use `#if` instead of `#ifdef`.

This should have been part of D144552.

17 months ago[RISCV] Scalarize constant stores of fixed vectors up to 32 bits
Luke Lau [Mon, 22 May 2023 16:51:32 +0000 (17:51 +0100)]
[RISCV] Scalarize constant stores of fixed vectors up to 32 bits

For stores of small fixed-length vector constants, we can store them
with a sequence of lui/addi/sh/sw to avoid the cost of building the
vector and the vsetivli toggle.

Note that this only handles vectors that are 32 bits or smaller, but
could be expanded to 64 bits if we know that the constant
materialization cost isn't too high.

Reviewed By: reames

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

17 months ago[RISCV] Add test cases for storing small constant vectors
Luke Lau [Mon, 22 May 2023 16:49:45 +0000 (17:49 +0100)]
[RISCV] Add test cases for storing small constant vectors

Reviewed By: craig.topper

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

17 months agoEnable up to 64 arguments for outlined regions in OpenMP device code.
Doru Bercea [Wed, 24 May 2023 14:14:43 +0000 (10:14 -0400)]
Enable up to 64 arguments for outlined regions in OpenMP device code.

Co-Author: Fabio Luporini <fabio@devitocodes.com>

Review: https://reviews.llvm.org/D150134

17 months ago[MergeICmps] Fix -Wsign-compare and typos (NFC)
Jie Fu [Wed, 24 May 2023 14:21:56 +0000 (22:21 +0800)]
[MergeICmps] Fix -Wsign-compare and typos (NFC)

/data/llvm-project/llvm/lib/Transforms/Scalar/MergeICmps.cpp:623:21: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigne
d long') [-Werror,-Wsign-compare]
  for (int i = 0; i < Comparisons.size(); i++) {
                  ~ ^ ~~~~~~~~~~~~~~~~~~
1 error generated.

17 months ago[mlir][Transforms] GreedyPatternRewriteDriver debugging: Detect faulty patterns
Matthias Springer [Wed, 24 May 2023 14:14:47 +0000 (16:14 +0200)]
[mlir][Transforms] GreedyPatternRewriteDriver debugging: Detect faulty patterns

Compute operation finger prints to detect incorrect API usage in RewritePatterns. Does not work for dialect conversion patterns.

Detect patterns that:
* Returned `failure` but changed the IR.
* Returned `success` but did not change the IR.
* Inserted/removed/modified ops, bypassing the rewriter. Not all cases are detected.

These new checks are quite expensive, so they are only enabled with `-DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON`. Failures manifest as fatal errors (`llvm::report_fatal_error`) or crashes (accessing deallocated memory). To get better debugging information, run `mlir-opt -debug` (to see which pattern is broken) with ASAN (to see where memory was deallocated).

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

17 months ago[RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg
Jay Foad [Wed, 24 May 2023 11:00:01 +0000 (12:00 +0100)]
[RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg

Live intervals for physical registers are calculated lazily on demand.
In a case like this:

  16B    %0:gpr32 = IMPLICIT_DEF
  32B    $wzr = COPY %0

if the live interval for $wzr did not already exist then the update code
in joinReservedPhysReg would create it with a definition at 32B, which
would remain even after the COPY was deleted.

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

17 months ago[MachineVerifier] Verify liveins for live-through segments
Jay Foad [Fri, 5 May 2023 09:51:28 +0000 (10:51 +0100)]
[MachineVerifier] Verify liveins for live-through segments

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

17 months agoReland [MergeICmps] Adapt to non-eq comparisons, bugfix
Zhongyunde [Wed, 24 May 2023 13:16:41 +0000 (21:16 +0800)]
Reland [MergeICmps] Adapt to non-eq comparisons, bugfix

1.Fix the last runtime issue as some sequent comparisons need be spilted.
For the origin equal comparisons chain, the new spilted Icmp chain will
still be end with equal, while for the new not-equal comparisons chain,
the new spilted Icmp chain will still be end with equal, so should address
this carefully, see detail wih case partial_sequent_ne

2. Fix the mismatch of last link comparison

Thanks for @aeubanks, @glandium and @ayzhao report the runtime issue
and carefully examine.
Fix https://github.com/llvm/llvm-project/issues/59740.

Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141188

17 months ago[mlir][Transforms][NFC] GreedyPatternRewriteDriver: Reformat debug logic
Matthias Springer [Wed, 24 May 2023 13:59:29 +0000 (15:59 +0200)]
[mlir][Transforms][NFC] GreedyPatternRewriteDriver: Reformat debug logic

Do not duplicate code that is performing actual work, put debug code around it.

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

17 months ago[AMDGPU] Switch to backwards scavenging in non-spill cases
Jay Foad [Wed, 24 May 2023 12:28:07 +0000 (13:28 +0100)]
[AMDGPU] Switch to backwards scavenging in non-spill cases

When the scavenger is not allowed to spill, the only difference between
forward and backward should be the heuristics used to pick an available
register. Forwards scavenging tries to pick a register that can be used
again later in the BB; backwards scavenging tries to pick one that can
be used earlier.

Backwards scavenging is preferred because it does not rely on accurate
kill flags.

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

17 months ago[clang][NFC] Add a blank line in ReleaseNotes.rst
Sheng [Wed, 24 May 2023 14:02:41 +0000 (22:02 +0800)]
[clang][NFC] Add a blank line in ReleaseNotes.rst

A buildbot has failed on the absence of the blank line at the end of the bullet list.

17 months ago[clang][Sema] Fix a crash when instantiating a non-type template argument in a depend...
Sheng [Wed, 24 May 2023 13:45:03 +0000 (21:45 +0800)]
[clang][Sema] Fix a crash when instantiating a non-type template argument in a dependent scope.

The type alias template is not diagnosed when instantiating an expected non-type template argument in a dependent scope, causing ICE.

Besides that, the diagnostic message has been updated to account for the fact that the function template  is not the only non-type template.

Fixes #62533

Reviewed By: #clang-language-wg, erichkeane

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

17 months ago[OpenMP][libomp] Implement KMP_DLSYM_NEXT on Windows
Hansang Bae [Thu, 4 May 2023 16:06:12 +0000 (11:06 -0500)]
[OpenMP][libomp] Implement KMP_DLSYM_NEXT on Windows

The interop API routines try to invoke external entries, but we did
not have support for KMP_DLSYM_NEXT on Windows. Also added proper
guards for STUB build.

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

17 months ago[clang-tidy] Really fix rG9182c679dde7
Clement Courbet [Wed, 24 May 2023 13:21:50 +0000 (15:21 +0200)]
[clang-tidy] Really fix  rG9182c679dde7

Correct link is clang-tidy/checks/performance/no-automatic-move

17 months ago[clang-tidy]Fix rG9182c679dde7cb6480e66b9231a53d43ad03908b
Clement Courbet [Wed, 24 May 2023 13:18:11 +0000 (15:18 +0200)]
[clang-tidy]Fix rG9182c679dde7cb6480e66b9231a53d43ad03908b

Fix bad link to documentation.

17 months ago[mlir][transform] Expose transform op from TrackingListener
Matthias Springer [Wed, 24 May 2023 13:02:56 +0000 (15:02 +0200)]
[mlir][transform] Expose transform op from TrackingListener

This allows subclasses (such as the ErrorCheckingTrackingListener in IREE) to produce better error messages.

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

17 months ago[Hexagon] Add more debugging options and dumps to HVC
Krzysztof Parzyszek [Tue, 23 May 2023 20:08:34 +0000 (13:08 -0700)]
[Hexagon] Add more debugging options and dumps to HVC

17 months ago[Hexagon] Remap all instructions generated for aligned address/value in HVC
Krzysztof Parzyszek [Tue, 23 May 2023 20:01:24 +0000 (13:01 -0700)]
[Hexagon] Remap all instructions generated for aligned address/value in HVC

Only the last instruction was remapped before.

17 months ago[clang-tidy]performance-no-automatic-move: fix false negative on `const T&&` ctors.
Clement Courbet [Mon, 22 May 2023 13:05:06 +0000 (15:05 +0200)]
[clang-tidy]performance-no-automatic-move: fix false negative on `const T&&` ctors.

We were only handling `const T&`/`T&&` ctor pairs, and we were missing uref-based ctors.

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

17 months ago[mlir][IR] Hash nesting structure in OperationFingerPrint
Matthias Springer [Wed, 24 May 2023 12:55:09 +0000 (14:55 +0200)]
[mlir][IR] Hash nesting structure in OperationFingerPrint

The following ops currently have the same finger print, even though they are different:
```
func.func @test() {
  "test.foo"() ({
    "test.bar"() : () -> ()
  }) : () -> ()
}
```
And:
```
func.func @test() {
  "test.bar"() : () -> ()
  "test.foo"() ({ }) : () -> ()
}
```

The SHA1 hash used in OperationFingerPrint is order-sensitive, but the ops are hashed in the same order (post-order traversal), so the hash is the same. Switching to pre-order traversal does not solve the issue; a similar example, where IR differs just in its nesting structure, can be constructed.

The problem is solved by hashing the parent op pointer. (Alternatively, a traversal over the IR that hashes scope markers (`{}`) could be used.)

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

17 months ago[libc] Reduce the sizes of some math tests that take longest time.
Tue Ly [Tue, 23 May 2023 20:47:38 +0000 (16:47 -0400)]
[libc] Reduce the sizes of some math tests that take longest time.

Reviewed By: gchatelet

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

17 months ago[clang][Sema] `-Wshadow` warns about shadowings by static local variables
Takuya Shimizu [Wed, 24 May 2023 12:11:56 +0000 (21:11 +0900)]
[clang][Sema] `-Wshadow` warns about shadowings by static local variables

This patch makes `-Wshadow` warn about the shadowings by static local variables.

Fixes https://github.com/llvm/llvm-project/issues/62850
Differential Revision: https://reviews.llvm.org/D151214

17 months agoReland: [clang][AST] Print name instead of type when diagnosing uninitialized subobje...
Takuya Shimizu [Wed, 24 May 2023 12:21:23 +0000 (21:21 +0900)]
Reland: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

This patch improves the diagnostic on uninitialized subobjects in constexpr variables by modifying the diagnostic message to display the subobject's name instead of its type.

Fixes https://github.com/llvm/llvm-project/issues/58601
Differential Revision: https://reviews.llvm.org/D146358

17 months ago[mlir] move PDL-related transform ops into an extension
Alex Zinenko [Mon, 22 May 2023 14:36:58 +0000 (14:36 +0000)]
[mlir] move PDL-related transform ops into an extension

The initial bring-up of the Transform dialect relied on PDL to provide
the default handle type (`!pdl.operation`) and the matching capability.
Both are now provided natively by the Transform dialect removing the
reason to have a hard dependency on the PDL dialect and its interpreter.
Move PDL-related transform operations into a separate extension.

This requires us to introduce a dialect state extension mechanism into
the Transform dialect so it no longer needs to know about PDL constraint
functions that may be injected by extensions similarly to operations and
types. This mechanism will be reused to connect pattern application
drivers and the Transform dialect.

This completes the restructuring of the Transform dialect to remove
overrilance on PDL.

Note to downstreams: flow that are using `!pdl.operation` with Transform
dialect operations will now require `transform::PDLExtension` to be
applied to the transform dialect in order to provide the transform
handle type interface for `!pdl.operation`.

Reviewed By: springerm

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

17 months ago[AMDGPU] Add attribute to AMDGPU ctor / dtor to indicate single threadedness
Joseph Huber [Mon, 22 May 2023 20:50:55 +0000 (15:50 -0500)]
[AMDGPU] Add attribute to AMDGPU ctor / dtor to indicate single threadedness

We only expect these ctor / dtor functions to be called with a single
thread. Add the appropriate attributes to indicate this to the backend.

Reviewed By: arsenm

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

17 months ago[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter
Michael Buch [Tue, 23 May 2023 23:01:47 +0000 (00:01 +0100)]
[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter

This mimicks the implementation of the libstdcpp std::unique_ptr
formatter.

This has been attempted several years ago in
`0789722d85cf1f1fdbe2ffb2245ea0ba034a9f94` but was reverted in
`e7dd3972094c2f2fb42dc9d4d5344e54a431e2ce`.

The difference to the original patch is that we now maintain
a `$$dereference$$` member and we only store weak pointers
to the other children inside the synthetic frontend. This is
what the libc++ formatters do to prevent the recursion mentioned
in the revert commit.

17 months ago[libc][bazel] Add log, log2, log10, log1p to bazel layout.
Tue Ly [Tue, 23 May 2023 20:20:47 +0000 (16:20 -0400)]
[libc][bazel] Add log, log2, log10, log1p to bazel layout.

Add log, log2, log10, log1p and their unit tests to bazel layout.

Reviewed By: gchatelet

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

17 months ago[gn build] Port ced90d1ff64a
LLVM GN Syncbot [Wed, 24 May 2023 10:54:20 +0000 (10:54 +0000)]
[gn build] Port ced90d1ff64a

17 months ago[FuncSpec] Improve the accuracy of the cost model.
Alexandros Lamprineas [Thu, 11 May 2023 23:07:49 +0000 (00:07 +0100)]
[FuncSpec] Improve the accuracy of the cost model.

Instead of blindly traversing the use-def chain of constant arguments,
compute known constants along the way. Stop as soon as a user cannot
be replaced by a constant. Keep it light-weight by handling some basic
instruction types.

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

17 months agoAdd OpenMPToLLVM conversion pattern for taskgroup
Kiran Chandramohan [Wed, 24 May 2023 08:34:47 +0000 (09:34 +0100)]
Add OpenMPToLLVM conversion pattern for taskgroup

Fixes part of the issue in https://github.com/llvm/llvm-project/issues/62013

Reviewed By: psoni2628

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

17 months ago[mlir] [scf] Add RegionBranchOpInterface to scf.forall and scf.parallel op
donald chen [Wed, 24 May 2023 10:05:34 +0000 (12:05 +0200)]
[mlir] [scf] Add RegionBranchOpInterface to scf.forall and scf.parallel op

Add RegionBranchOpIntefface to scf.forall and scf.parallel op to make analysis trace through subregions.

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

17 months ago[TOSA] Fold consecutive concats on same axis
Dominik Montada [Mon, 15 May 2023 09:51:30 +0000 (09:51 +0000)]
[TOSA] Fold consecutive concats on same axis

Consecutive concats that happen on the same axis can be folded into a
single, bigger concat. This patch implements this folding by
implementing the tosa::ConcatOp::fold method.

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

17 months ago[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)
Sergei Barannikov [Wed, 24 May 2023 09:57:07 +0000 (12:57 +0300)]
[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
The only place where the assertion is currently triggering is in
CriticalAntiDepBreaker::ScanInstruction. Other places are changed
in case new assertions are added and should be harmless otherwise.

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

17 months ago[compiler-rt] Always use INTERCEPTOR()+ALIAS()+WRAP() to create interceptor alias
Marco Elver [Wed, 24 May 2023 09:32:33 +0000 (11:32 +0200)]
[compiler-rt] Always use INTERCEPTOR()+ALIAS()+WRAP() to create interceptor alias

Do not open code creation of an interceptor alias to another
interceptor. Instead, use INTERCEPTOR() + ALIAS() + WRAP.

Reviewed By: dvyukov

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

17 months ago[TSan] Remove unused setjmp definitions
Marco Elver [Wed, 24 May 2023 09:32:28 +0000 (11:32 +0200)]
[TSan] Remove unused setjmp definitions

The __interceptor_*setjmp() definitions appear to have been defined for
the purpose of TSAN_INTERCEPT(), but on non-Mac systems, it seems
TSAN_INTERCEPT() isn't even being used anymore for setjmp.

Remove them. Nothing should call them anyway (due to CHECK-fail), so
having the linker fail is better than failing at runtime.

Reviewed By: dvyukov

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

17 months ago[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*
Marco Elver [Wed, 24 May 2023 09:32:21 +0000 (11:32 +0200)]
[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*

Use ASM_WRAPPER_NAME to produce the name of the __interceptor_*
functions.

NFC.

Reviewed By: dvyukov

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

17 months ago[compiler-rt] Simplify ALIAS() attribute macro
Marco Elver [Wed, 24 May 2023 09:31:40 +0000 (11:31 +0200)]
[compiler-rt] Simplify ALIAS() attribute macro

Most uses of ALIAS() are in conjunction with WRAPPER_NAME().

Simplify the code and just make ALIAS() turn its argument into a string
(similar to Linux kernel's __alias macro). This in turn allows removing
WRAPPER_NAME().

NFC.

Reviewed By: dvyukov

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

17 months ago[mlir][transform] Fix merge_handle asm format
Christian Ulmann [Wed, 24 May 2023 09:05:21 +0000 (09:05 +0000)]
[mlir][transform] Fix merge_handle asm format

This commit ensures that the merge_handles operation prints its
`deduplicate` attribute as an optional keyword instead of "unit".

Reviewed By: ftynse

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

17 months ago[AggressiveInstCombine] Handle the nested GEP/BitCast scenario in Load Merge.
bipmis [Wed, 24 May 2023 09:36:11 +0000 (10:36 +0100)]
[AggressiveInstCombine] Handle the nested GEP/BitCast scenario in Load Merge.

This seems to be an issue currently where there are nested/chained GEP/BitCast Pointers.
The patch generates a new GEP for the wider load to avoid dominance problems.

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

17 months ago[RISCV] Scalarize small fixed vector copies < XLEN
Luke Lau [Mon, 22 May 2023 14:34:51 +0000 (15:34 +0100)]
[RISCV] Scalarize small fixed vector copies < XLEN

For small fixed-length vector copies like
vsetivli   zero, 2, e16, m1, ta, ma
vle16.v    v8, (a0)
vse16.v    v8, (a1)

We can scalarize them if the total vector size < XLEN:
lw a0, 0(a0)
sw a0, 0(a1)

This patch adds a DAG combine to do so, reusing much of the existing
logic in https://reviews.llvm.org/D150717

Reviewed By: reames

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

17 months ago[RISCV] Add test for small vector copies
Luke Lau [Mon, 22 May 2023 14:32:24 +0000 (15:32 +0100)]
[RISCV] Add test for small vector copies

Reviewed By: reames

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

17 months ago[KnownBits] Reduce number of overflow checks for uadd/sub_sat (NFCI)
Nikita Popov [Wed, 24 May 2023 09:14:26 +0000 (11:14 +0200)]
[KnownBits] Reduce number of overflow checks for uadd/sub_sat (NFCI)

Only check for overflow on the min/max values, don't also check
for predicates in addition to that.

17 months ago[bazel] Fix build after 0bf120a82040f7ffaba0f0ab72a983f1cd9343ab
Benjamin Kramer [Wed, 24 May 2023 09:14:18 +0000 (11:14 +0200)]
[bazel] Fix build after 0bf120a82040f7ffaba0f0ab72a983f1cd9343ab

17 months ago[KnownBits] Use early return for unknown LHS for shifts (NFC)
Nikita Popov [Wed, 24 May 2023 09:02:16 +0000 (11:02 +0200)]
[KnownBits] Use early return for unknown LHS for shifts (NFC)

Make it clear that the leading/trailing zeros handling is only
relevant for the unknown LHS case, which is a fast path to avoid
the full shift amount loop in cases where it would not produce
better results.

17 months ago[ValueTracking] Check for known bits conflict for shl nsw (PR62908)
Nikita Popov [Wed, 24 May 2023 08:52:18 +0000 (10:52 +0200)]
[ValueTracking] Check for known bits conflict for shl nsw (PR62908)

I removed the conflict check from computeKnownBitsFromShiftOperator()
in D150648 assuming that this is now handled on the KnownBits side.
However, the nsw handling is still inside ValueTracking, so we
still need to handle conflicts there. Restore the check closer to
where it is relevant.

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

17 months ago[InstCombine] Directly iterate over users (NFC)
Nikita Popov [Wed, 24 May 2023 08:39:32 +0000 (10:39 +0200)]
[InstCombine] Directly iterate over users (NFC)

After 3a223f1eafe331508d171b519df8a4984791ab48, it's no longer
necessary to put the users into a vector. We can directly iterate
them instead.

17 months ago[KnownBits] Check for conflict-freedom in exhaustive tests
Nikita Popov [Wed, 24 May 2023 08:32:20 +0000 (10:32 +0200)]
[KnownBits] Check for conflict-freedom in exhaustive tests

And make sure udiv() Exact does not produce conflicts.

17 months ago[gn build] Port 1c9a8004ed88
Nico Weber [Wed, 24 May 2023 08:25:56 +0000 (04:25 -0400)]
[gn build] Port 1c9a8004ed88

17 months ago[Clang][C++20] Error out if parameter types of a defaulted comparion operator are...
Jens Massberg [Tue, 23 May 2023 11:12:01 +0000 (13:12 +0200)]
[Clang][C++20] Error out if parameter types of a defaulted comparion operator are not all the same.

This fixes #62880

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

17 months ago[LVI] Don't compute range on not guaranteed not to be undef condition in SelectInst
luxufan [Wed, 24 May 2023 07:46:44 +0000 (15:46 +0800)]
[LVI] Don't compute range on not guaranteed not to be undef condition in SelectInst

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

Reviewed By: nikic

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

17 months ago[LoopUnroll] Peel iterations based on select conditions
Joshua Cao [Sun, 21 May 2023 20:30:26 +0000 (13:30 -0700)]
[LoopUnroll] Peel iterations based on select conditions

This also allows us to peel loops with a `select`:
```
for (int i = 0; i <= N; ++i);
  f3(i == 0 ? a : b); // select instruction
```
into:
```
f3(a); // peel one iteration
for (int i = 1; i <= N; ++i)
  f3(b);
```

Reviewed By: nikic

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

17 months ago[LoopUnroll] Add tests for peeling iterations based on select, and, or
Joshua Cao [Sat, 20 May 2023 20:07:19 +0000 (20:07 +0000)]
[LoopUnroll] Add tests for peeling iterations based on select, and, or
conditions

17 months ago[clangd] Fix add-using tweak on declrefs with template arguments
Kadir Cetinkaya [Wed, 24 May 2023 07:46:08 +0000 (09:46 +0200)]
[clangd] Fix add-using tweak on declrefs with template arguments

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

17 months ago[InstCombine] Fix crash due to early extractvalue removal
Nikita Popov [Wed, 24 May 2023 07:52:43 +0000 (09:52 +0200)]
[InstCombine] Fix crash due to early extractvalue removal

Fixes the issue reported at https://github.com/llvm/llvm-project/commit/4b8320868c9e32d1448c81ca76dba2a6b9f374cd#commitcomment-114671248.

The extractvalue instructions may still be used by the calling code
in some cases. Rather than trying to figure out which extracts are
safe to remove and which aren't, add them to the worklist so they
will get DCEd by the main loop.

17 months agoValueTracking: Handle constrained_sqrt in computeKnownFPClass
Matt Arsenault [Thu, 13 Apr 2023 14:25:18 +0000 (10:25 -0400)]
ValueTracking: Handle constrained_sqrt in computeKnownFPClass

With this, the body of CannotBeNegativeZero can be dropped.

17 months agoAMDGPU: Drop FP_ROUND second value check
Matt Arsenault [Tue, 23 May 2023 10:04:39 +0000 (11:04 +0100)]
AMDGPU: Drop FP_ROUND second value check

This doesn't mean what I thought it meant and is an optimization
hint flag.

17 months agoInline: Convert test to generated checks
Matt Arsenault [Tue, 23 May 2023 14:48:38 +0000 (15:48 +0100)]
Inline: Convert test to generated checks

17 months agoConvert unit test to opaque pointers
Matt Arsenault [Tue, 23 May 2023 09:36:07 +0000 (10:36 +0100)]
Convert unit test to opaque pointers

17 months agoRecommit [C++20] [Modules] Serialize the evaluated constant values for VarDecl
Chuanqi Xu [Wed, 24 May 2023 02:13:31 +0000 (10:13 +0800)]
Recommit [C++20] [Modules] Serialize the evaluated constant values for VarDecl

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

Previously, we didn't serialize the evaluated result for VarDecl. This
caused the compilation of template metaprogramming become slower than
expect. This patch fixes the issue.

This is a recommit tested with asan built clang.

17 months ago[mlir] [sroa] Add support for MemRef.
Théo Degioanni [Wed, 24 May 2023 07:25:02 +0000 (07:25 +0000)]
[mlir] [sroa] Add support for MemRef.

This patch implements SROA interfaces for MemRef, up to a given fixed
size.

Reviewed By: gysit, Dinistro

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