platform/upstream/llvm.git
16 months ago[mlir][transform] Use separate ops instead of PatternRegistry
Matthias Springer [Tue, 6 Jun 2023 09:19:59 +0000 (11:19 +0200)]
[mlir][transform] Use separate ops instead of PatternRegistry

* Remove `transform::PatternRegistry`.
* Add a new op for each currently registered pattern set.
* Change names of vector dialect pattern selector ops, so that they are consistent with the remaining code base.
* Remove redundant `transform.vector.extract_address_computations` op.

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

16 months ago[clang][analyzer] Add report of NULL stream to StreamChecker.
Balázs Kéri [Tue, 6 Jun 2023 09:12:20 +0000 (11:12 +0200)]
[clang][analyzer] Add report of NULL stream to StreamChecker.

The report of NULL stream was removed in commit 570bf97.
The old reason is not actual any more because the checker dependencies are changed.
It is not good to eliminate a failure state (where the stream is NULL) without
generating a bug report because other checkers are not able to find it later.
The checker did this with the NULL stream pointer, and because this checker
runs now before other checkers that can detect NULL pointers, the null pointer
bug was not found at all.

Reviewed By: steakhal

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

16 months ago[RISCV] Handle "o" inline asm memory constraint
wangpc [Tue, 6 Jun 2023 09:49:58 +0000 (17:49 +0800)]
[RISCV] Handle "o" inline asm memory constraint

This is the same as D100412.

We just found the same crash when we tried to compile some packages
like mariadb, php, etc.

For constraint "o", it means "A memory operand is allowed, but
only if the address is offsettable". So I think it can be handled
just like constraint "m" for RISCV target.

And we print verbose information when unsupported constraints occur.

Reviewed By: asb

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

16 months agoRevert "[VPlan] Mark recurrence recipes as not having side-effects."
Florian Hahn [Tue, 6 Jun 2023 09:35:25 +0000 (11:35 +0200)]
Revert "[VPlan] Mark recurrence recipes as not having side-effects."

This reverts commit 02369b75fdd7b5fc5d9b47f1b60587c225918511.

At the moment, live-outs used *only* for the resume values in the scalar
loop are not modeled in VPlan yet. This means first-order recurrence
recipes could be removed, when a scalar epilogue is required and the
only use of a FOR is outside the loop.

Keep treating recurrence recipes as having side-effects for now, to
avoid them being removed.

Fixes #62954.

16 months ago[mlir][transform] generate transform module on-the-fly
Alex Zinenko [Mon, 5 Jun 2023 18:42:15 +0000 (18:42 +0000)]
[mlir][transform] generate transform module on-the-fly

Add a TransformInterpreterPassBase capability to generate the (shared)
module containing the transform script during the pass initialization.
This is helpful to programmatically generate the script as opposed to
parsing it from the textual module.

Reviewed By: springerm

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

16 months ago[LV] Use force-vector-width for X86 recurrence test.
Florian Hahn [Tue, 6 Jun 2023 09:26:55 +0000 (11:26 +0200)]
[LV] Use force-vector-width for X86 recurrence test.

This makes sure that all tests that can be vectorized in the file are
vectorized.

16 months ago[LV] Add test for #62954.
Florian Hahn [Tue, 6 Jun 2023 09:20:21 +0000 (11:20 +0200)]
[LV] Add test for #62954.

16 months ago[clang][ThreadSafety][NFC] Make isReference() const
Timm Bäder [Tue, 6 Jun 2023 08:33:00 +0000 (10:33 +0200)]
[clang][ThreadSafety][NFC] Make isReference() const

16 months ago[AMDGPU] WQM: Ensure exact mode placement before branches
Carl Ritson [Tue, 6 Jun 2023 08:25:22 +0000 (17:25 +0900)]
[AMDGPU] WQM: Ensure exact mode placement before branches

Fix for D151797 where the change accidentally allowed exit to
exact mode between branch instructions.

Reviewed By: dstuttard

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

16 months ago[AArch64] Make .arch without extra features actually take effect
Martin Storsjö [Fri, 2 Jun 2023 09:25:52 +0000 (12:25 +0300)]
[AArch64] Make .arch without extra features actually take effect

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

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

16 months ago[AArch64] Complete the list of extensions supported by .arch and .arch_extension
Martin Storsjö [Fri, 2 Jun 2023 08:36:40 +0000 (11:36 +0300)]
[AArch64] Complete the list of extensions supported by .arch and .arch_extension

This brings the list of extensions supported here up to date
with what is supported by current git versions of binutils.

Also add a comment to AArch64TargetParser to remind people to
consider adding new ones to the list supported in assembly.

In the case of the "rdma" extension, there's a slight surprise:
LLVM knows of the extension under the name "rdm", while binutils
has it named "rdma". However, binutils appears to accept any
abbreviated prefix of an arch extension, so it does accept the
form "rdm" too even if it formally considers it called "rdma".

Support both spellings for the extensions here, for simplicity.

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

16 months agoUse symbolic name for previous MLIR Bytecode versions
Mehdi Amini [Mon, 5 Jun 2023 19:35:30 +0000 (12:35 -0700)]
Use symbolic name for previous MLIR Bytecode versions

Reviewed By: jpienaar, burmako

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

16 months ago[ARM][Driver] Warn if -mhard-float is incompatible
Michael Platings [Mon, 22 May 2023 13:48:00 +0000 (14:48 +0100)]
[ARM][Driver] Warn if -mhard-float is incompatible

Mixing -mfloat-abi=hard with a CPU that doesn't have floating point
registers is an error in GCC:
  cc1: error: '-mfloat-abi=hard': selected processor lacks an FPU

Since there is code in the wild (including in clang tests) that relies
on Clang's current behaviour, emit a warning instead of an error.

Unlike the GCC error, the new warning refers to floating point
registers instead of an FPU. This is because -mfloat-abi=hard and
-march=armv8.1-m.main+mve+nofp are compatible - in that case floating
point registers are required, but an FPU is not required.

My initial thought was to use the floating point ABI calculated by
arm::getARMFloatABI() but in invalid cases which error for other
reasons the ABI is miscalculated and the warning would cause confusion.
Therefore only warn if the user specifies the float ABI explicitly.

Fixes part of https://github.com/llvm/llvm-project/issues/55755

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

16 months ago[FPEnv] Get rid of extra moves in fpenv calls
Serge Pavlov [Tue, 6 Jun 2023 07:54:52 +0000 (14:54 +0700)]
[FPEnv] Get rid of extra moves in fpenv calls

If intrinsic `get_fpenv` or `set_fpenv` is lowered to the form where FP
environment is represented as a region in memory, extra moves can
appear. For example the code:

  define void @func_01(ptr %ptr) {
    %env = call i256 @llvm.get.fpenv.i256()
    store i256 %env, ptr %ptr
    ret void
  }

produces DAG:

  ch = get_fpenv_mem ch, memory_region
  val: i256, ch = load ch, memory_region
  ch = store ch, ptr, val

In this case the extra moves can be avoided if `get_fpenv_mem` got
pointer to the memory where the FP environment should be finally placed.

This change implement such optimization for this use case.

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

16 months ago[mlir][vector] Use transform.apply_patterns in vector tests
Matthias Springer [Tue, 6 Jun 2023 07:18:10 +0000 (09:18 +0200)]
[mlir][vector] Use transform.apply_patterns in vector tests

All vector transform ops are now `PatternDescriptorOpInterface` ops that merely select the patterns. The patterns are applied by the `apply_patterns` op. This is to ensure that ops are properly tracked. (TrackingListener is used in the implementation of `apply_patterns`.) Furthermore, handles are no longer invalidated when applying patterns in the vector tests.

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

16 months agollvm-extract: Replace IFuncs with declarations
Christian Ulmann [Tue, 6 Jun 2023 06:54:03 +0000 (06:54 +0000)]
llvm-extract: Replace IFuncs with declarations

This commit ensures that llvm-extract does not copy all IFuncs into the
resulting modules. Before this change, ifuncs were not modified which
could cause the emission unexpected IR files.

Reviewed By: darthscsi

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

16 months ago[mlir][transform] Add region to ApplyPatternsOp
Matthias Springer [Tue, 6 Jun 2023 07:07:22 +0000 (09:07 +0200)]
[mlir][transform] Add region to ApplyPatternsOp

Patterns should be selected by adding ops that implement `PatternDescriptorOpInterface` to the region of `apply_pattern` ops. Such ops can have operands, allowing for pattern parameterization. The existing way of selecting patterns from the PatternRegistry is deprecated.

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

16 months ago[AMDGPU] Pre-commit test for D152228 (NFC)
Carl Ritson [Tue, 6 Jun 2023 06:40:51 +0000 (15:40 +0900)]
[AMDGPU] Pre-commit test for D152228 (NFC)

16 months ago[X86] Pre-commit test case for D152227.
Luo, Yuanke [Tue, 6 Jun 2023 06:56:45 +0000 (14:56 +0800)]
[X86] Pre-commit test case for D152227.

16 months ago[X86] Add test cases for D152227.
Luo, Yuanke [Tue, 6 Jun 2023 06:23:49 +0000 (14:23 +0800)]
[X86] Add test cases for D152227.

16 months agoRevert "[RISCV] Minor readability improvement to RISCVMatInt. NFC"
Craig Topper [Tue, 6 Jun 2023 06:21:51 +0000 (23:21 -0700)]
Revert "[RISCV] Minor readability improvement to RISCVMatInt. NFC"

This reverts commit 1ebe06017df607d4fc140f6b166e35cd32fc5f16.

I've been informed the old way was documented in the psABI.

16 months ago[libc++] Removes CMake work-arounds.
Mark de Wever [Sun, 4 Jun 2023 15:38:59 +0000 (17:38 +0200)]
[libc++] Removes CMake work-arounds.

CMake older than 3.20.0 is no longer supported.
This removes work-arounds for no longer supported versions.

Reviewed By: #libc, jloser, philnik

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

16 months ago[RISCV] Minor readability improvement to RISCVMatInt. NFC
Craig Topper [Tue, 6 Jun 2023 06:04:21 +0000 (23:04 -0700)]
[RISCV] Minor readability improvement to RISCVMatInt. NFC

When splitting a simm32 into LUI+ADDI(W). Subtract Lo12 from Val
to calculate Hi20. This replaces the old method of adding 0x800 to
Val. This change makes the math the reverse of how the LUI+ADDI(W)
create the immediate.

16 months ago[WebAssembly] Add tests ensuring rotates persist
Paulo Matos [Mon, 5 Jun 2023 08:09:09 +0000 (10:09 +0200)]
[WebAssembly] Add tests ensuring rotates persist

Due to the nature of WebAssembly, it's always better to keep
rotates instead of trying to optimize it. Commit 9485d983
disabled the generation of fsh for rotates, however these
tests ensure that future changes don't change the behaviour for
the Wasm backend that tends to have different optimization
requirements than other architectures. Also see:
https://github.com/llvm/llvm-project/issues/62703

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

16 months ago[libc++][spaceship] Implement `operator<=>` for `queue`
Hristo Hristov [Tue, 14 Mar 2023 16:32:15 +0000 (18:32 +0200)]
[libc++][spaceship] Implement `operator<=>` for `queue`

Implements parts of P1614R2 `operator<=>` for `queue`

Reviewed By: #libc, Mordante

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

16 months ago[gn build] Port c336c983bcd9
LLVM GN Syncbot [Tue, 6 Jun 2023 05:06:30 +0000 (05:06 +0000)]
[gn build] Port c336c983bcd9

16 months ago[C++20] [Modules] [Serialization] Don't write comments to BMI for C++20 Named Modules
Chuanqi Xu [Tue, 6 Jun 2023 05:01:53 +0000 (13:01 +0800)]
[C++20] [Modules] [Serialization] Don't write comments to BMI for C++20 Named Modules

This patch forbids to write comment to BMIs for C++20 Named Modules.
Originally I thought this was helpful for language services like clangd.
But I found clangd don't want the BMI to contain comments actually. So
it is meaningless for C++20 Named Modules to keep such comments in
their BMI.

It is simple to enable this when someday we found we want this actually.

16 months ago[RISCV] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
Fangrui Song [Tue, 6 Jun 2023 04:40:32 +0000 (21:40 -0700)]
[RISCV] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC

Similar to AArch64,AVR,PowerPC: 9e2d100e5322c52e29280c96bbb5609ca5af1539.

16 months ago[AArch64,AVR,PowerPC] Migrate to new encodeInstruction that uses SmallVectorImpl...
Fangrui Song [Tue, 6 Jun 2023 04:33:10 +0000 (21:33 -0700)]
[AArch64,AVR,PowerPC] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC

Similar to 49488490d195591bfc90daef111cd7293f8c80aa.

16 months ago[InstCombine] add overflow checking on Add ~X + C --> (C-1) - X
khei4 [Sun, 4 Jun 2023 04:07:02 +0000 (13:07 +0900)]
[InstCombine] add overflow checking on Add ~X + C --> (C-1) - X
Differential Revision: https://reviews.llvm.org/D152088

16 months ago[InstCombine] precommit test for D152088(NFC)
khei4 [Sun, 4 Jun 2023 04:06:06 +0000 (13:06 +0900)]
[InstCombine] precommit test for D152088(NFC)
Differential Revision: https://reviews.llvm.org/D152089

16 months ago[AVR][NFC][test] Supplement more tests of 8-bit rotation
Ben Shi [Mon, 5 Jun 2023 08:23:38 +0000 (16:23 +0800)]
[AVR][NFC][test] Supplement more tests of 8-bit rotation

Reviewed By: Patryk27, jacquesguan

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

16 months agoReland "[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle"
Phoebe Wang [Tue, 6 Jun 2023 02:46:37 +0000 (10:46 +0800)]
Reland "[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle"

16 months agoRevert "[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle"
Phoebe Wang [Tue, 6 Jun 2023 02:41:26 +0000 (10:41 +0800)]
Revert "[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle"

This reverts commit 50a2341fe92f8a5ff934bd279450581e9cbcf103.

This results in buildbot fail.

16 months ago[flang] Fix crash in shape analysis of PACK()
Peter Klausler [Fri, 2 Jun 2023 23:30:43 +0000 (16:30 -0700)]
[flang] Fix crash in shape analysis of PACK()

A CHECK() was firing when a call to the PACK intrinsic does not have a
VECTOR= argument and at least one dimension of the shape of the ARRAY=
argument could not be determined.  The CHECK was inappropriate, since
this can of course happen, such as when that argument is the result
of the SPREAD() intrinsic with non-constant DIM= or NCOPIES= arguments.
Replace with an if() statement.

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

16 months ago[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle
Phoebe Wang [Tue, 6 Jun 2023 02:24:37 +0000 (10:24 +0800)]
[X86][NFC] Refactor: there's only v16bf16 in 256-bit shuffle

16 months ago[RISCV] Improve selection for vector fpclass.
Jianjian GUAN [Fri, 2 Jun 2023 04:01:10 +0000 (12:01 +0800)]
[RISCV] Improve selection for vector fpclass.

Since vfclass intruction will only set one single bit in the result, so if we only want to check 1 fp class, we could use vmseq to do it.

Reviewed By: craig.topper

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

16 months ago[libc++][ranges] Implement the changes to container adaptors from P1206 (`ranges...
varconst [Sat, 3 Jun 2023 02:23:29 +0000 (19:23 -0700)]
[libc++][ranges] Implement the changes to container adaptors from P1206 (`ranges::to`):

- add the `from_range_t` constructors and the related deduction guides;
- add the `push_range` member function.

(Note: this patch is split from https://reviews.llvm.org/D142335)

Reviewed By: #libc, ldionne

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

16 months ago[CMake] Quote variables where "TARGET" may be a value
Sam James [Tue, 6 Jun 2023 01:08:01 +0000 (02:08 +0100)]
[CMake] Quote variables where "TARGET" may be a value

In CMake, "TARGET" is a special keyword. But it's also an LLVM component, which
means downstreams may request "target" or "TARGET" from CMake. Quote such input
so "TARGET" is interpreted as a string rather than a keyword.

This is a followup to 75a0502fe0053c72b57b61143a55600814d931fd (D150884).

Fixes Meson's test suite and an issue which manifested identically to #61436
but appears to have been a slightly different problem.

Bug: https://github.com/mesonbuild/meson/issues/11642
Bug: https://github.com/llvm/llvm-project/issues/61436

Reviewed By: tstellar

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

16 months agoAMDGPU: Fix broken test
Matt Arsenault [Tue, 6 Jun 2023 00:44:38 +0000 (20:44 -0400)]
AMDGPU: Fix broken test

16 months agoAutoUpgrade: Fix crash when tbaa has an empty argument
Matt Arsenault [Mon, 5 Jun 2023 13:03:54 +0000 (09:03 -0400)]
AutoUpgrade: Fix crash when tbaa has an empty argument

Produce a verifier error instead.

16 months ago[CMake][libc] Don't put archive in build/lib/<target triple> by default
Aiden Grossman [Mon, 5 Jun 2023 19:57:13 +0000 (19:57 +0000)]
[CMake][libc] Don't put archive in build/lib/<target triple> by default

ea8f4b98419750c8cc7c60ea43b570adf47b3f78 broke some build configurations
because it was enabled by default and some people are using a just built
libc/clang/LLVM to work on other projects where having a just built LLVM
libc in one of Clang's default include directories can make things
unusable.

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

16 months ago[libc] Replace the `PRINT_TO_STDERR` opcode for RPC printing.
Joseph Huber [Mon, 5 Jun 2023 23:56:26 +0000 (18:56 -0500)]
[libc] Replace the `PRINT_TO_STDERR` opcode for RPC printing.

A previous patch added general support for printing via the RPC
interface. we should consolidate this functionality and get rid of the
old opcode that was used for simple testing.

Reviewed By: lntue

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

16 months agobazel build fix
Aart Bik [Tue, 6 Jun 2023 00:16:18 +0000 (17:16 -0700)]
bazel build fix

Reviewed By: Peiming, manishucsd

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

16 months ago[Attributor] Identify and remove no-op fences
Johannes Doerfert [Thu, 18 May 2023 23:46:11 +0000 (16:46 -0700)]
[Attributor] Identify and remove no-op fences

The logic and implementation follows the removal of no-op barriers. If
the fence is not making updates visible, either to the world or the
current thread, it is not needed. Said differently, the fences we remove
do not establish synchronization (happens-before) edges.
This allows us to eliminate some of the regression caused by:
  https://reviews.llvm.org/D145290

16 months agotest/AMDGPU: REQUIRES asserts (D148184)
NAKAMURA Takumi [Mon, 5 Jun 2023 23:29:08 +0000 (08:29 +0900)]
test/AMDGPU: REQUIRES asserts (D148184)

16 months agoRISCVISelLowering.cpp: Suppress a warning. (D150824)
NAKAMURA Takumi [Mon, 5 Jun 2023 23:34:01 +0000 (08:34 +0900)]
RISCVISelLowering.cpp: Suppress a warning. (D150824)

16 months ago[Attributor] Merge ranges by expansion, avoid unknown ranges
Johannes Doerfert [Sat, 3 Jun 2023 02:30:17 +0000 (19:30 -0700)]
[Attributor] Merge ranges by expansion, avoid unknown ranges

Different offsets can be handled by expansion rather than defaulting to
an unknown offset. Thus, [4,4] & [8,8] will result in [4, 12] rather
than [unknown, unknown].

16 months ago[Attributor][NFC] Precommit vector write range tests
Johannes Doerfert [Sat, 3 Jun 2023 04:46:43 +0000 (21:46 -0700)]
[Attributor][NFC] Precommit vector write range tests

16 months ago[libc][obvious] Fix conditional when CUDA is not found
Joseph Huber [Mon, 5 Jun 2023 23:49:35 +0000 (18:49 -0500)]
[libc][obvious] Fix conditional when CUDA is not found

If CUDA is not found this string will expand into nothing. We need to
surround it with a string otherwise it will cause build failures.

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

16 months ago[mlir][sparse] fix crashes when using custom reduce with unary operation.
Peiming Liu [Mon, 5 Jun 2023 22:26:30 +0000 (22:26 +0000)]
[mlir][sparse] fix crashes when using custom reduce with unary operation.

The tests case is directly copied from https://reviews.llvm.org/D152179 authored by @aartbik

Reviewed By: aartbik

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

16 months ago[OpenMP] Improve default block count selection fow low block counts
Johannes Doerfert [Thu, 18 May 2023 21:49:40 +0000 (14:49 -0700)]
[OpenMP] Improve default block count selection fow low block counts

If a combined loop has insufficient parallelism (= low trip count), we
might end up with too few teams/blocks. To counter that we can reduce
the number of threads per team we use. This patch implements a heuristic
and exposes a new environment variable to control the minimum of threads
to be employed in this case.

Issue reported by:
Felipe Cabarcas Jaramillo <cabarcas@udel.edu> (@fel-cab).

Reviewed By: tianshilei1992

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

16 months ago[OpenMP] Use "kernel" attribute consistently
Johannes Doerfert [Sat, 3 Jun 2023 01:35:53 +0000 (18:35 -0700)]
[OpenMP] Use "kernel" attribute consistently

16 months ago[OpenMP] Mark kernels as mustprogress
Johannes Doerfert [Thu, 18 May 2023 20:39:57 +0000 (13:39 -0700)]
[OpenMP] Mark kernels as mustprogress

16 months ago[Attributor] Create `AAMustProgress` for the `mustprogress` attribute
Johannes Doerfert [Mon, 15 May 2023 22:53:44 +0000 (15:53 -0700)]
[Attributor] Create `AAMustProgress` for the `mustprogress` attribute

Derive the mustprogress attribute based on the willreturn attribute
or the fact that all callers are mustprogress.

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

16 months ago[Sanitizers][Darwin] In DlAddrSymbolizer, return only the module file name instead...
usama hameed [Fri, 2 Jun 2023 20:46:10 +0000 (13:46 -0700)]
[Sanitizers][Darwin] In DlAddrSymbolizer, return only the module file name instead of the comlpete module path during symbolication.

rdar://108858834

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

16 months ago[mlir][Vector] Adds a pattern to fold `arith.extf` into `vector.contract`
Manish Gupta [Thu, 1 Jun 2023 02:00:56 +0000 (02:00 +0000)]
[mlir][Vector] Adds a pattern to fold `arith.extf` into `vector.contract`

Consider mixed precision data type, i.e., F16 input lhs, F16 input rhs, F32 accumulation, and F32 output. This is typically written as F32 <= F16*F16 + F32.

During vectorization from linalg to vector for mixed precision data type (F32 <= F16*F16 + F32), linalg.matmul introduces arith.extf on input lhs and rhs operands.

"linalg.matmul"(%lhs, %rhs, %acc) ({
      ^bb0(%arg1: f16, %arg2: f16, %arg3: f32):
        %lhs_f32 = "arith.extf"(%arg1) : (f16) -> f32
        %rhs_f32 = "arith.extf"(%arg2) : (f16) -> f32
       %mul = "arith.mulf"(%lhs_f32, %rhs_f32) : (f32, f32) -> f32
        %acc = "arith.addf"(%arg3, %mul) : (f32, f32) -> f32
      "linalg.yield"(%acc) : (f32) -> ()
    })
There are backend that natively supports mixed-precision data type and does not need the arith.extf. For example, NVIDIA A100 GPU has mma.sync.aligned.*.f32.f16.f16.f32 that can support mixed-precision data type. However, the presence of arith.extf in the IR, introduces the unnecessary casting targeting F32 Tensor Cores instead of F16 Tensor Cores for NVIDIA backend. This patch adds a folding pattern to fold arith.extf into vector.contract

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

16 months agoissue#62488: Correct some syntax errors. Leave location and custom-operation-format...
Stevengre [Mon, 5 Jun 2023 23:06:33 +0000 (16:06 -0700)]
issue#62488: Correct some syntax errors. Leave location and custom-operation-format unchanged, because I'm not sure.

Reviewed By: Mogball

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

16 months ago[libc] Add initial support for 'puts' and 'fputs' to the GPU
Joseph Huber [Wed, 24 May 2023 03:35:21 +0000 (22:35 -0500)]
[libc] Add initial support for 'puts' and 'fputs' to the GPU

This patch adds the initial support required to support basic priting in
`stdio.h` via `puts` and `fputs`. This is done using the existing LLVM C
library `File` API. In this sense we can think of the RPC interface as
our system call to dump the character string to the file. We carry a
`uintptr_t` reference as our native "file descriptor" as it will be used
as an opaque reference to the host's version once functions like
`fopen` are supported.

For some unknown reason the declaration of the `StdIn` variable causes
both the AMDGPU and NVPTX backends to crash if I use the `READ` flag.
This is not used currently as we only support output now, but it needs
to be fixed

Reviewed By: sivachandra, lntue

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

16 months ago[libc] Implement basic `malloc` and `free` support on the GPU
Joseph Huber [Tue, 30 May 2023 17:08:44 +0000 (12:08 -0500)]
[libc] Implement basic `malloc` and `free` support on the GPU

This patch adds support for the `malloc` and `free` functions. These
currently aren't implemented in-tree so we first add the interface
filies.

This patch provides the most basic support for a true `malloc` and
`free` by using the RPC interface. This is functional, but in the future
we will want to implement a more intelligent system and primarily use
the RPC interface more as a `brk()` or `sbrk()` interface only called
when absolutely necessary. We will need to design an intelligent
allocator in the future.

The semantics of these memory allocations will need to be checked. I am
somewhat iffy on the details. I've heard that HSA can allocate
asynchronously which seems to work with my tests at least. CUDA uses an
implicit synchronization scheme so we need to use an explicitly separate
stream from the one launching the kernel or the default stream. I will
need to test the NVPTX case.

I would appreciate if anyone more experienced with the implementation details
here could chime in for the HSA and CUDA cases.

Reviewed By: sivachandra

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

16 months agoAMDGPU: Add baseline test for undoing mul add 1 reassociation
Matt Arsenault [Mon, 5 Jun 2023 19:13:01 +0000 (15:13 -0400)]
AMDGPU: Add baseline test for undoing mul add 1 reassociation

Add some tests for combines to undo regressions caused by
0cfc6510323fbb5a56a5de23cbc65f7cc30fd34c.

16 months agoDAG: Reorder conditions
Matt Arsenault [Mon, 5 Jun 2023 12:46:33 +0000 (08:46 -0400)]
DAG: Reorder conditions

16 months ago[OpenMP][libomp] Allow white spaces in OMP_TARGET_OFFLOAD value
Hansang Bae [Thu, 4 May 2023 14:35:38 +0000 (09:35 -0500)]
[OpenMP][libomp] Allow white spaces in OMP_TARGET_OFFLOAD value

Remove heading/trailing white spaces when matching OMP_TARGET_OFFLOAD
value.

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

16 months agoAMDGPU: Fold zext into result of v_mad_u16 on high zeroing targets
Matt Arsenault [Mon, 5 Jun 2023 17:04:37 +0000 (13:04 -0400)]
AMDGPU: Fold zext into result of v_mad_u16 on high zeroing targets

Avoids regressions in future patch.

16 months agoAMDGPU: Add baseline 16-bit mad matching tests
Matt Arsenault [Mon, 5 Jun 2023 17:52:12 +0000 (13:52 -0400)]
AMDGPU: Add baseline 16-bit mad matching tests

16 months agoAMDGPU: Convert test to generated checks
Matt Arsenault [Mon, 5 Jun 2023 17:51:03 +0000 (13:51 -0400)]
AMDGPU: Convert test to generated checks

16 months ago[flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)
Peter Klausler [Mon, 5 Jun 2023 21:58:20 +0000 (14:58 -0700)]
[flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)

Correct the code that implements the production of spaces to bring the
furthestPositionInRecord up to a positionInRecord that was tabbed forward
by a T or TR control edit descriptor.

Fixes bug https://github.com/llvm/llvm-project/issues/63111.

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

16 months agofix build issue on bazel
Aart Bik [Mon, 5 Jun 2023 22:13:32 +0000 (15:13 -0700)]
fix build issue on bazel

Needed to fix:
https://github.com/llvm/llvm-project/commit/53a5c3ab4dbe434753e0e4e3505efa2e5692e752
https://github.com/llvm/llvm-project/commit/db7cc0348c9a0aa44b23948949afef488d5083dd

Reviewed By: Peiming, anlunx

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

16 months ago[hwasan] Properly restore SP tag on exceptions
Florian Mayer [Mon, 5 Jun 2023 21:14:27 +0000 (14:14 -0700)]
[hwasan] Properly restore SP tag on exceptions

Reviewed By: vitalybuka

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

16 months ago[bazel][libc] Add targets for integer abs and div functions.
Siva Chandra Reddy [Sat, 3 Jun 2023 23:04:20 +0000 (23:04 +0000)]
[bazel][libc] Add targets for integer abs and div functions.

Reviewed By: lntue

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

16 months ago[libc++][NFC] Add __element_count and use it in the constexpr C functions
Nikolas Klauser [Mon, 5 Jun 2023 22:07:42 +0000 (15:07 -0700)]
[libc++][NFC] Add __element_count and use it in the constexpr C functions

This makes it less ambiguous what the parameter is meant to get.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

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

16 months ago[RISCV] Lower experimental_get_vector_length intrinsic to vsetvli for some cases.
Craig Topper [Mon, 5 Jun 2023 22:02:11 +0000 (15:02 -0700)]
[RISCV] Lower experimental_get_vector_length intrinsic to vsetvli for some cases.

This patch lowers to vsetvli when the AVL is i32 or XLenVT and
the VF is a power of 2 in the range [1, 64]. VLEN=32 is not supported
as we don't have a valid type mapping for that. VF=1 is not supported
with Zve32* only.

The element width is used to set the SEW for the vsetvli if possible.
Otherwise we use SEW=8.

Reviewed By: reames

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

16 months ago[Demangle] refactor DLangDemangle to use std::string_view
Nick Desaulniers [Mon, 5 Jun 2023 21:31:55 +0000 (14:31 -0700)]
[Demangle] refactor DLangDemangle to use std::string_view

Many existing methods of the D Language Demangler take a C style string
and return an adjusted pointer to the same object as the input string is
consumed.

Make it more obvious by changing the signatures to accept
std::string_view& when the input is modified vs a copy of a
std::string_view when the input is not.

Reviewed By: efriedma

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

16 months ago[lld] StringRef::{starts,ends}with => {starts,ends}_with. NFC
Fangrui Song [Mon, 5 Jun 2023 21:36:19 +0000 (14:36 -0700)]
[lld] StringRef::{starts,ends}with => {starts,ends}_with. NFC

The latter form is now preferred to be similar to C++20 starts_with.
This replacement also removes one function call when startswith is not inlined.

16 months agoReland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD
Arthur Eubanks [Thu, 23 Feb 2023 19:21:33 +0000 (11:21 -0800)]
Reland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD

LLVM_TOOL_LLD_BUILD is a relic of the pre-monorepo times. This causes us to never set COMPILER_RT_HAS_LLD.

Instead, set it from the runtimes build if lld is being built and lld is used as the compiler-rt linker.

Mark a test that requires libstdc++ as requiring Android, as other platforms may not have a libstdc++ lying around.

Reviewed By: MaskRay

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

16 months ago[RISCV] Add RISCVISD nodes for vfwadd/vfwsub.
Craig Topper [Mon, 5 Jun 2023 20:47:28 +0000 (13:47 -0700)]
[RISCV] Add RISCVISD nodes for vfwadd/vfwsub.

Add a DAG combine to form these from FADD_VL/FSUB_VL and FP_EXTEND_VL.

This makes it similar to other widening ops and allows us to handle
using the same FP_EXTEND_VL for both operands.

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

16 months ago[RISCV] Rename SDT_RISCVVWBinOpW_VL->SDT_RISCVVWIntBinOpW_VL. NFC
Craig Topper [Mon, 5 Jun 2023 20:47:22 +0000 (13:47 -0700)]
[RISCV] Rename SDT_RISCVVWBinOpW_VL->SDT_RISCVVWIntBinOpW_VL. NFC

Preparation for D151969 which adds an FP version.

16 months ago[lldb][NFCI] Change the way Process stores StructuredData plugins
Alex Langford [Fri, 2 Jun 2023 01:26:33 +0000 (18:26 -0700)]
[lldb][NFCI] Change the way Process stores StructuredData plugins

Instead of having a map from ConstString to StructuredDataPluginSP, we
can use an llvm::StringMap. The keys themselves don't need to be
ConstStrings, so an llvm::StringMap feels most natural.

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

16 months ago[Driver] Allow -fsanitize=kcfi with -fsanitize-minimal-runtime
Sami Tolvanen [Mon, 5 Jun 2023 16:37:12 +0000 (16:37 +0000)]
[Driver] Allow -fsanitize=kcfi with -fsanitize-minimal-runtime

Having both UBSan with the minimal runtime and KCFI enabled can be
useful in low-level software. As there are no conflicts between the
flags, add KCFI to the list of compatible sanitizers.

16 months ago[RISCV][test] Fix a couple of whitespace issues
Jessica Clarke [Mon, 5 Jun 2023 20:25:04 +0000 (21:25 +0100)]
[RISCV][test] Fix a couple of whitespace issues

16 months ago[ADT] Deprecate StringRef::{starts,ends}with_insensitive
Kazu Hirata [Mon, 5 Jun 2023 20:18:07 +0000 (13:18 -0700)]
[ADT] Deprecate StringRef::{starts,ends}with_insensitive

This patch deprecates StringRef::{starts,ends}with_insensitive as
their uses have migrated to {starts,ends}_with_insensitive,
respectively.

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

16 months ago[Support] Remove {Bits,Float,Double}To{Bits,Float,Double}
Kazu Hirata [Mon, 5 Jun 2023 20:18:05 +0000 (13:18 -0700)]
[Support] Remove {Bits,Float,Double}To{Bits,Float,Double}

These functions have been deprecated since:

  commit 0f52c1f86c62dadf69a7b732779abf59edea3d5c
  Author: Kazu Hirata <kazu@google.com>
  Date:   Tue Feb 14 09:52:36 2023 -0800

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

16 months ago[Support] Remove PowerOf2Floor and ByteSwap_{16,32,64}
Kazu Hirata [Mon, 5 Jun 2023 20:18:03 +0000 (13:18 -0700)]
[Support] Remove PowerOf2Floor and ByteSwap_{16,32,64}

These functions have been deprecated since:

  commit b49b429fde3a282664289d7a2155d994085eb232
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sun Feb 12 21:42:07 2023 -0800

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

16 months ago[lldb][NFCI] ConstString methods should take StringRefs by value
Alex Langford [Fri, 2 Jun 2023 17:19:57 +0000 (10:19 -0700)]
[lldb][NFCI] ConstString methods should take StringRefs by value

StringRef was made to be passed by value efficiently.

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

16 months ago[BOLT][NFC] Drop MMap events for deleted files
Amir Ayupov [Mon, 5 Jun 2023 20:02:59 +0000 (13:02 -0700)]
[BOLT][NFC] Drop MMap events for deleted files

Don't parse/handle mmap events with "(deleted)" filename.

Reviewed By: #bolt, rafauler

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

16 months ago[Demangle] convert microsoftDemangle to take a std::string_view
Nick Desaulniers [Mon, 5 Jun 2023 19:53:38 +0000 (12:53 -0700)]
[Demangle] convert microsoftDemangle to take a std::string_view

This should be last of the "bottom-up conversions" of various demanglers
to accept std::string_view.  After this, D149104 may be revisited.

Reviewed By: MaskRay

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

16 months ago[Sema] Fix a warning
Kazu Hirata [Mon, 5 Jun 2023 19:59:58 +0000 (12:59 -0700)]
[Sema] Fix a warning

This patch fixes:

  clang/lib/Sema/SemaExprCXX.cpp:5591:3: error: default label in
  switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

16 months agollvm-dwarfdump --verify: Add support for .debug_str_offsets[.dwo]
David Blaikie [Mon, 5 Jun 2023 19:57:11 +0000 (19:57 +0000)]
llvm-dwarfdump --verify: Add support for .debug_str_offsets[.dwo]

Had a couple of issues lately causing corrupted strings due to
problematic str_offsets (overflow due to >4GB .debug_str.dwo section in
a dwp and the dwp tool silently overflowing the 32 bit offsets updated
in the .debug_str_offsets.dwo section, and then more recently two CUs in
a dwo caused the dwp tool to reapply the offset adjustment twice
corrupting str_offsets.dwo as well) - so let's check that the offsets
are valid.

This assumes no suffix merging - if anyone implements that, then this
checking should just be removed for the most part (we could still check
the offsets are within the bounds of .debug_str[.dwo], but nothing more
- any offset in the range would be valid, the offsets wouldn't have to
land at the start of a string)

16 months ago[lldb][NFCI] Use size_t in OptionValueProperties
Alex Langford [Thu, 1 Jun 2023 23:23:25 +0000 (16:23 -0700)]
[lldb][NFCI] Use size_t in OptionValueProperties

In many places we're using uint32_t where we should be using size_t.
We should be consistent.

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

16 months agoTest case improvement (Do not optimize debug locations across section boundaries...
Pierre Calixte [Mon, 5 Jun 2023 19:51:26 +0000 (12:51 -0700)]
Test case improvement (Do not optimize debug locations across section boundaries/D149294)

Ensure that the expected location directives are from different sections.

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

16 months ago[lldb][NFCI] Change return type of REPL::GetSourceFileBasename
Alex Langford [Fri, 2 Jun 2023 01:37:37 +0000 (18:37 -0700)]
[lldb][NFCI] Change return type of REPL::GetSourceFileBasename

These don't really need to be in the ConstString StringPool. I've
changed the return type to StringRef because on llvm.org and downstream
in the swift fork, this returns a constant value. We could change it to
return a std::string or something else if it needs to be able to change
between calls.

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

16 months ago[NVPTX] fixed vector-compare test.
Artem Belevich [Mon, 5 Jun 2023 19:44:05 +0000 (12:44 -0700)]
[NVPTX] fixed vector-compare test.

Apparently this test didn't actually test anything other that the IR compiles.

16 months ago[flang] Fix crash from bug#63099 (gfortran/regression/oldstyle_3.f90)
Peter Klausler [Mon, 5 Jun 2023 18:31:53 +0000 (11:31 -0700)]
[flang] Fix crash from bug#63099 (gfortran/regression/oldstyle_3.f90)

In InitElement() in flang/lib/Semantics/data-to-inits.cpp, don't
assume that values_.Location() can be called until after it has been
verified that values_.IsAtEnd() is not true.

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

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

16 months agoCoalesce 16-bit FP types to use integer register classes.
Artem Belevich [Sat, 27 May 2023 00:11:23 +0000 (17:11 -0700)]
Coalesce 16-bit FP types to use integer register classes.

i16/f16/bf16 will use the same .b16 registers and
i32/v2f16 and v2bf16 will share .b32 registers.

The changes are mostly mechanical, intended to remove unnecessary register
classes which tend to produce redundant register moves.

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

v2f16 regtype conversion to i32

16 months ago[Clang] Add release note for 877210faa447
Nathan Chancellor [Mon, 5 Jun 2023 19:12:21 +0000 (12:12 -0700)]
[Clang] Add release note for 877210faa447

Reviewed By: erichkeane, nickdesaulniers

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

16 months agoFix MLIR build with Shared lib enabled
Mehdi Amini [Mon, 5 Jun 2023 19:10:24 +0000 (12:10 -0700)]
Fix MLIR build with Shared lib enabled

db7cc0348c9a0 added OpenMP support to the execution engine but didn't
add the explicit CMake dependency.

16 months agoActivate OpenMP translation in MLIR execution engine CAPI.
Rafael Ubal Tena [Mon, 5 Jun 2023 18:56:44 +0000 (11:56 -0700)]
Activate OpenMP translation in MLIR execution engine CAPI.

We've observed that the MLIR Jit Engine fails when the `omp` dialect is used due to a failure to register OpenMP-related translations. This small patch addresses this issue.

Reviewed By: mehdi_amini

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

16 months ago[scudo] Change configuration for Trusty, use mmap()
Dmitriy Filchenko [Mon, 5 Jun 2023 18:28:09 +0000 (18:28 +0000)]
[scudo] Change configuration for Trusty, use mmap()

Trusty runs in memory constrained environments, with many apps
having only one page (4KB) of heap memory available. However, we
still want to mmap() multiples of PAGE_SIZE at a time.

Additionally, switch Scudo from using sbrk() to mmap().

Reviewed By: cferris

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

16 months agoFix LLVM sphinx build
Aaron Ballman [Mon, 5 Jun 2023 18:14:23 +0000 (14:14 -0400)]
Fix LLVM sphinx build

Addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/30/builds/35886

16 months agotree-sitter-mlir: add a more complete grammar
Ramkumar Ramachandra [Mon, 20 Feb 2023 14:57:51 +0000 (15:57 +0100)]
tree-sitter-mlir: add a more complete grammar

Contribute a grammar, along with associated tests, from the upstream
project maintained at https://github.com/artagnon/tree-sitter-mlir. The
new grammar includes several fixes, and successfully parses 60-80% of
MLIR tests in the Arith, Math, ControlFlow, SCF, Tensor, Affine, and
Linalg dialects.

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