platform/upstream/llvm.git
23 months ago[WebAssembly] Use `localexec` as default TLS model for non-Emscripten targets
Andrew Brown [Mon, 25 Jul 2022 20:16:07 +0000 (13:16 -0700)]
[WebAssembly] Use `localexec` as default TLS model for non-Emscripten targets

Only Emscripten supports dynamic linking with threads. To use
thread-local storage for other targets, this change defaults to the
`localexec` model.

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

23 months ago[libc] Add dirent.h functions opendir, readdir, closedir and dirfd.
Siva Chandra Reddy [Sat, 23 Jul 2022 07:35:46 +0000 (07:35 +0000)]
[libc] Add dirent.h functions opendir, readdir, closedir and dirfd.

Reviewed By: lntue

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

23 months agoRegAllocGreedy: Add a command line flag for reverseLocalAssignment
Matt Arsenault [Sat, 23 Jul 2022 13:33:21 +0000 (09:33 -0400)]
RegAllocGreedy: Add a command line flag for reverseLocalAssignment

Introduce a flag like for some of the other target heuristic controls
to help with experimentation.

23 months agoAMDGPU: Adjust register allocation priority values down
Matt Arsenault [Sat, 23 Jul 2022 14:22:41 +0000 (10:22 -0400)]
AMDGPU: Adjust register allocation priority values down

Set the priorities consistently to number of registers in the tuple -
1. Previously we started at 1, and also tried to give SGPR higher
values than VGPRs. There's no point in assigning SGPRs higher values
now that those are allocated in a separate regalloc run.

This avoids overflowing the 5 bits used for the class priority in the
allocation heuristic for 32 element tuples. This avoids some cases
where smaller registers unexpectedly get prioritized over larger.

23 months ago[OpenMP] Remove noinline attributes in the device runtime
Joseph Huber [Mon, 25 Jul 2022 19:27:41 +0000 (15:27 -0400)]
[OpenMP] Remove noinline attributes in the device runtime

We previously used the `noinline` attributes to specify some defintions
which should be kept alive in the runtime. These were then stripped
immediately in the OpenMPOpt module pass. However, Since the changes in
D130298, we not explicitly state which functions will have external
visiblity in the bitcode library. Additionally the OpenMPOpt module pass
should run before the inliner pass, so this shouldn't make a difference
in whether or not the functions will be alive for the initial pass of
OpenMPOpt. This should simplify the interface, and additionally save
time spend on scanning funciton names for noinline.

Reviewed By: jdoerfert

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

23 months ago[Passes] add a tail-call-elim pass near the end of the opt pipeline
Sanjay Patel [Mon, 25 Jul 2022 14:09:09 +0000 (10:09 -0400)]
[Passes] add a tail-call-elim pass near the end of the opt pipeline

We call tail-call-elim near the beginning of the pipeline,
but that is too early to annotate calls that get added later.

In the motivating case from issue #47852, the missing 'tail'
on memset leads to sub-optimal codegen.

I experimented with removing the early instance of
tail-call-elim instead of just adding another pass, but that
appears to be slightly worse for compile-time:
+0.15% vs. +0.08% time.
"tailcall" shows adding the pass; "tailcall2" shows moving
the pass to later, then adding the original early pass back
(so 1596886802 is functionally equivalent to 180b0439dc ):
https://llvm-compile-time-tracker.com/index.php?config=NewPM-O3&stat=instructions&remote=rotateright

Note that there was an effort to split the tail call functionality
into 2 passes - that could help reduce compile-time if we find
that this change costs more in compile-time than expected based
on the preliminary testing:
D60031

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

23 months ago[flang] Allow restricted specific intrinsic functions as implicitly-interfaced proced...
Peter Klausler [Fri, 22 Jul 2022 18:48:07 +0000 (11:48 -0700)]
[flang] Allow restricted specific intrinsic functions as implicitly-interfaced procedure pointer targets

The predicate "CanBeCalledViaImplicitInterface()" was returning false for
restricted specific intrinsic functions (e.g., SIN) because their procedure
characteristics have the elemental attribute; this leads to a bogus semantic
error when one attempts to use them as proc-targets in procedure pointer
assignment statements when the left-hand side of the assignment is a procedure
pointer with an implicit interface.  However, these restricted specific intrinsic
functions have always been allowed as special cases for such usage -- it is
as if they are elemental when it is necessary for them to be so, but not
when it's a problem.

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

23 months ago[flang][runtime] Reset unit frame buffer when re-opening
Peter Klausler [Fri, 22 Jul 2022 21:32:03 +0000 (14:32 -0700)]
[flang][runtime] Reset unit frame buffer when re-opening

An OPEN statement that implies closing a connection must invalidate
the unit's frame buffer so as to prevent stale data from the old
connection from being read into the newly-connected unit.

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

23 months agoRevert "[lld-macho] Implement -load_hidden"
Daniel Bertalan [Mon, 25 Jul 2022 19:11:19 +0000 (21:11 +0200)]
Revert "[lld-macho] Implement -load_hidden"

This reverts commit 4c79e1a3f4eb790f40239833ae237e828ce07386.

Broke this bot: https://lab.llvm.org/buildbot/#builders/57/builds/20319

23 months ago[lld-macho] Implement -load_hidden
Daniel Bertalan [Mon, 25 Jul 2022 09:45:55 +0000 (11:45 +0200)]
[lld-macho] Implement -load_hidden

This flag was introduced in ld64-609. It instructs the linker to link to
a static library while treating its symbols as if they had hidden
visibility. This is useful when building a dylib that links to static
libraries but we don't want the symbols from those to be exported.

Closes #51505

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

23 months ago[RISCV] Add more test cases for select with (setge X, C) condition.
Craig Topper [Mon, 25 Jul 2022 18:48:52 +0000 (11:48 -0700)]
[RISCV] Add more test cases for select with (setge X, C) condition.

InstCombine and SelectionDAG will tend to canonicalize these conditions
to (setgt X, C-1). C-1 might be more costly to materialize than C would
have been.

23 months ago[Flang][OpenMP] Initial support for integer reduction in worksharing-loop
Kiran Chandramohan [Mon, 25 Jul 2022 18:21:17 +0000 (18:21 +0000)]
[Flang][OpenMP] Initial support for integer reduction in worksharing-loop

Lower the Flang parse-tree containing OpenMP reductions to the OpenMP
dialect. The OpenMP dialect models reductions with,
1) A reduction declaration operation that specifies how to initialize, combine,
and atomically combine private reduction variables.
2) The OpenMP operation (like wsloop) that supports reductions has an array of
reduction accumulator variables (operands) and an array attribute of the same
size that points to the reduction declaration to be used for the reduction
accumulation.
3) The OpenMP reduction operation that takes a value and an accumulator.
This operation replaces the original reduction operation in the source.

(1) is implemented by the `createReductionDecl` in OpenMP.cpp,
(2) is implemented while creating the OpenMP operation,
(3) is implemented by the `genOpenMPReduction` function in OpenMP.cpp, and
called from Bridge.cpp. The implementation of (3) is not very robust.

NOTE 1: The patch currently supports only reductions for integer type addition.
NOTE 2: Only supports reduction in the worksharing loop.
NOTE 3: Does not generate atomic combination region.
NOTE 4: Other options for creating the reduction operation include
a) having the reduction operation as a construct containing an assignment
and then handling it appropriately in the Bridge.
b) we can modify `genAssignment` or `genFIR(AssignmentStmt)` in the Bridge to
handle OpenMP reduction but so far we have tried not to mix OpenMP
and non-OpenMP code and this will break that.
I will try (b) in a separate patch.
NOTE 5: OpenMP dialect gained support for reduction with the patches:
D105358, D107343. See https://discourse.llvm.org/t/rfc-openmp-reduction-support/3367
for more details.

Reviewed By: awarzynski

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

Co-authored-by: Peixin-Qiao <qiaopeixin@huawei.com>
23 months ago[clang][dataflow] Rename iterators from IT to It
Dmitri Gribenko [Mon, 25 Jul 2022 18:23:23 +0000 (20:23 +0200)]
[clang][dataflow] Rename iterators from IT to It

The latter way to abbreviate is a lot more common in the LLVM codebase.

Reviewed By: sgatev, xazax.hun

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

23 months ago[libc] Add a simple StringStream class.
Siva Chandra Reddy [Fri, 22 Jul 2022 06:54:54 +0000 (06:54 +0000)]
[libc] Add a simple StringStream class.

This class will be used in future changes to construct simple strings.

Reviewed By: michaelrj

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

23 months ago[clang][dataflow] Fix MapLattice::insert() to not drop return value
Eric Li [Mon, 25 Jul 2022 16:18:53 +0000 (12:18 -0400)]
[clang][dataflow] Fix MapLattice::insert() to not drop return value

Fix `MapLattice` API to return `std::pair<iterator, bool>`,
allowing users to detect when an element has been inserted without
performing a redundant map lookup.

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

23 months ago[Kaleidoscope] Fix DWARF function creation example
Justin Brooks [Mon, 25 Jul 2022 18:18:53 +0000 (18:18 +0000)]
[Kaleidoscope] Fix DWARF function creation example

The full code listing was fixed in fdaeb0c647eb66763721a7fe74e0a36b007dcd75

Reviewed By: dblaikie

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

23 months ago[flang] Dial some errors down to warnings for ASSOCIATED()
Peter Klausler [Mon, 18 Jul 2022 20:31:17 +0000 (13:31 -0700)]
[flang] Dial some errors down to warnings for ASSOCIATED()

When a procedure pointer is associated with a procedure target, f18
will emit hard error messages if the pointer is incompatible with the
target in a way that would cause the program to not work if the
procedure pointer were actually called.  However, in the context of
the ASSOCIATED() intrinsic, the compiler should not consider a query
to be a compilation-time error if the pointer and the target are
incompatible.  The standard gives us sufficient wiggle room here
to treat these cases as warnings.

Attempts to use ASSOCIATED to test whether a procedure pointer is
associated with a data object, or vice versa, remain errors.

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

23 months agoRevert "[mlir][Arithmetic] Add `arith.delinearize_index` operation"
Christopher Bate [Mon, 25 Jul 2022 16:28:23 +0000 (10:28 -0600)]
Revert "[mlir][Arithmetic] Add `arith.delinearize_index` operation"

This reverts commit 535b507ba58e8b5f604d53ffc961be1456d229a7.

23 months ago[Clang] Status of the C++23 papers approved by WG21 at the July plenary
Corentin Jabot [Sat, 23 Jul 2022 07:53:40 +0000 (09:53 +0200)]
[Clang] Status of the C++23 papers approved by WG21 at the July plenary

23 months ago[flang] Runs FIR SimplifyRegionLitePass pass after calling the inliner
Jean Perier [Mon, 25 Jul 2022 17:38:08 +0000 (19:38 +0200)]
[flang] Runs FIR SimplifyRegionLitePass pass after calling the inliner

In flang pipeline, the inliner calls createCanonicalizerPass with the region
simplification disabled. The inliner pass does canonicalization even if
no inlining happens. After canonicalization, FIR lite region simplification
must be called to get rid of unreachable regions.
This code exposes the need to run SimplifyRegionLitePass after the inliner is
called with FIR pipeline.

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

23 months ago[mlir] Update Python CMake version requirement.
Mike Urbach [Wed, 20 Jul 2022 14:21:36 +0000 (08:21 -0600)]
[mlir] Update Python CMake version requirement.

The minimum required version is now 3.19 due to the usage of some
more recent features. Update the version check and error message
accordingly. Also remove some logic that behaved differently before
3.18, since we can assume we are now on version 3.19+.

Reviewed By: stella.stamenova

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

23 months ago[Reassociate][NFC] Use an appropriate dyn_cast for BinaryOperator
Warren Ristow [Mon, 25 Jul 2022 17:24:43 +0000 (10:24 -0700)]
[Reassociate][NFC] Use an appropriate dyn_cast for BinaryOperator

In D129523, it was noted that there is are some questionable naked casts
from Instruction to BinaryOperator, which could be addressed by doing a
dyn_cast directly to BinaryOperator, avoiding the need for the later cast.
This cleans up that casting.

Reviewed By: nikic, spatel, RKSimon

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

23 months ago[GlobalISel][DebugInfo] Remove debug info with zero line from constants inserted...
Vladislav Dzhidzhoev [Mon, 25 Jul 2022 17:10:48 +0000 (17:10 +0000)]
[GlobalISel][DebugInfo] Remove debug info with zero line from constants inserted at entry block

Emission of constants having DebugLoc with line 0 causes significant increase of debug_line section size for some source files.

To illustrate, we can compare section sizes of several files from llvm test-suite, built with SelectionDAG vs GlobalISel, on Aarch64 (macOS), using -O0 optimization level:

| Source path                                                    | SDAG text sz | GISel text sz | SDAG debug_line sz |  GISel debug_line sz
| -------------------------------------------------------------- | ------------ | ------------- | ------------------ | --------------------
| `SingleSource/Regression/C/gcc-c-torture/execute/strlen-2.c`   | 15320        | 660           | 14872              | 6340
| `SingleSource/Regression/C/gcc-c-torture/execute/20040629-1.c` | 33640        | 26300         | 2812               | 6693
| `SingleSource/Benchmarks/Misc/flops-4.c`                       | 1428         | 1196          | 594                | 1008
| `MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c`        | 2716         | 964           | 809                | 903
| `MultiSource/Benchmarks/Prolangs-C/gnugo/showinst.c`           | 2534         | 2502          | 189                | 573

For instance, here is a fragment of `flops-4.c.o` debug line section dump

```
Address            Line   Column File   ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000000    174      0      1   0             0  is_stmt
0x0000000000000010      0      0      1   0             0
0x0000000000000018    185      4      1   0             0  is_stmt prologue_end
0x000000000000001c      0      0      1   0             0
0x0000000000000024    186      4      1   0             0  is_stmt
0x000000000000002c    189     10      1   0             0  is_stmt
0x0000000000000030      0      0      1   0             0
0x0000000000000038    207     11      1   0             0  is_stmt
0x0000000000000044    208     11      1   0             0  is_stmt
0x0000000000000048      0      0      1   0             0
0x0000000000000058    210     10      1   0             0  is_stmt
0x000000000000005c      0      0      1   0             0
0x0000000000000060    211     10      1   0             0  is_stmt
0x0000000000000064      0      0      1   0             0
0x000000000000006c    212     10      1   0             0  is_stmt
0x0000000000000070      0      0      1   0             0
0x000000000000007c    213     10      1   0             0  is_stmt
0x0000000000000080      0      0      1   0             0
0x0000000000000088    214     10      1   0             0  is_stmt
0x000000000000008c      0      0      1   0             0
0x0000000000000094    215     10      1   0             0  is_stmt
```

Lot of zero lines are produced by constants (global values) having DebugLoc with line 0.
It seems that they're not significant for debugging experience.

With the commit applied, total size of debug_line sections of llvm shared libraries has reduced by 2.5%.
Change of debug line section size of files listed above:

| Source path                                                    | GISel debug_line sz | Patch debug_line sz
| -------------------------------------------------------------- | ------------------- | --------------------
| `SingleSource/Regression/C/gcc-c-torture/execute/strlen-2.c`   | 6340                | 1465
| `SingleSource/Regression/C/gcc-c-torture/execute/20040629-1.c` | 6693                | 3782
| `SingleSource/Benchmarks/Misc/flops-4.c`                       | 1008                | 609
| `MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c`        | 903                 | 841
| `MultiSource/Benchmarks/Prolangs-C/gnugo/showinst.c`           | 573                 | 190

Reviewed By: dblaikie

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

23 months ago[flang] Better error message for NULL() actual argument for dummy allocatable
Peter Klausler [Mon, 18 Jul 2022 17:27:05 +0000 (10:27 -0700)]
[flang] Better error message for NULL() actual argument for dummy allocatable

f18 intentionally does not support the spottily-implemented language extension
in which one can pass NULL() for an allocatable dummy argument.  This is perhaps
a sanctioned side effect in other compilers of the fact that they pass distinct
"base address" and "descriptor address" physical arguments.

Make the error message in this case more specific to the circumstances, and
add a note to Extensions.md to clarify that this behavior is intended.

(We could, with some effort in lowering, support passing NULL for an INTENT(IN)
allocatable dummy, but let's see whether such nonconforming usage appears
in a real application before spending any more time on it.)

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

23 months agoFix assertion in SmallDenseMap constructor with reserve from non-power-of-2 buckets...
Vladislav Dzhidzhoev [Mon, 25 Jul 2022 16:39:46 +0000 (16:39 +0000)]
Fix assertion in SmallDenseMap constructor with reserve from non-power-of-2 buckets count

`SmallDenseMap` constructor with reserve gets an arbitrary `NumInitBuckets` value and passes it below to `init` method.

If `NumInitBuckets` is greater then `InlineBuckets`, then `SmallDenseMap` initializes to large representation passing `NumInitBuckets` below to `DenseMap` initialization. `DenseMap::initEmpty` method asserts that initial buckets count must be a power of 2.

Proposed solution is to update `NumInitBuckets` value in `SmallDenseMap` constructor till the next power of 2. It should satisfy both `DenseMap` preconditions and required minimum buckets count for reservation.

Reviewed By: atrick

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

23 months agoUse `<stdatomic.h>` with MSVC and C++
Igor Zhukov [Mon, 25 Jul 2022 16:54:32 +0000 (18:54 +0200)]
Use `<stdatomic.h>` with MSVC and C++

and use fallback only for C.

It fixes the isssue with clang-cl:

```
#include <stdatomic.h>
#include <stdbool.h>
#ifdef __cplusplus
#include <atomic>
using namespace std;
#endif

int main() {
    atomic_bool b = true;
}
```

```
$ clang-cl /TC main.cpp
# works
```
```
$ clang-cl /TP /std:c++20 main.cpp

stdatomic.h(70,6): error: conflicting types for 'atomic_thread_fence'
void atomic_thread_fence(memory_order);
     ^
atomic(166,24): note: previous definition is here
extern "C" inline void atomic_thread_fence(const memory_order _Order) noexcept {

...

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
```
Many errors but
`<stdatomic.h>` has many macros to built-in functions.
```
#define atomic_thread_fence(order) __c11_atomic_thread_fence(order)
```
and MSVC `<atomic>` has real functions.
and the built-in functions are redefined.

Reviewed By: #libc, aaron.ballman, Mordante

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

23 months ago[lldb] [gdb-remote] Refactor killing process and move it to client
Michał Górny [Wed, 20 Jul 2022 14:27:21 +0000 (16:27 +0200)]
[lldb] [gdb-remote] Refactor killing process and move it to client

Refactor the code responsible for sending the "k" packet and move it
into GDBRemoteCommunicationClient::KillProcess() method.  This is part
of refactoring to enable multiprocess support in the client,
and to support using the vKill packet instead.

As part of the refactoring, the following functional changes apply:

- Some redundant logging has been removed, as any failures are returned
  via exit_string anyway.

- SetLastStopPacket() is no longer called.  It is used only to populate
  the thread list, and since the process has just exited and we're
  terminating the process instance, there's really no reason to set it.

- On successful kill, exit_string is set to "killed", to clearly
  indicate that the process has terminated on our request rather than
  on its own.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D130340

23 months ago[lld-macho] Demangle location name in undefined symbol diagnostics
Daniel Bertalan [Mon, 25 Jul 2022 15:18:47 +0000 (17:18 +0200)]
[lld-macho] Demangle location name in undefined symbol diagnostics

If the `-demangle` flag is passed to lld, symbol names will now be
demangled in the "referenced by:" message in addition to the referenced
symbol's name, which was already demangled before this change.

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

23 months ago[RISCV] Teach RISCVCodeGenPrepare to optimize (zext (abs(i32 X, i1 1))).
Craig Topper [Mon, 25 Jul 2022 16:13:21 +0000 (09:13 -0700)]
[RISCV] Teach RISCVCodeGenPrepare to optimize (zext (abs(i32 X, i1 1))).

(abs(i32 X, i1 1) always produces a positive result. The 'i1 1'
means INT_MIN input produces poison. If the result is sign extended,
InstCombine will convert it to zext. This does not produce ideal
code for RISCV.

This patch reverses the zext back to sext which can be folded
into a subw or negw. Ideally we'd do this in SelectionDAG, but
we lose the INT_MIN poison flag when llvm.abs becomes ISD::ABS.

Reviewed By: reames

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

23 months agoRevert "Revert "Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image...
Saiyedul Islam [Mon, 25 Jul 2022 16:35:09 +0000 (11:35 -0500)]
Revert "Revert "Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info"""

This reverts commit 281eb9223cf2e9366b5356fafab275abf0ea1d2b.

23 months ago[libc++] Fix algorithms which use reverse_iterator
Nikolas Klauser [Sun, 24 Jul 2022 13:28:15 +0000 (15:28 +0200)]
[libc++] Fix algorithms which use reverse_iterator

This adds a C++20-version of `reverse_iterator` which doesn't SFINAE away the operators for use inside the classic STL algorithms. Pre-C++20 `_AlgRevIter` is just an alias for `reverse_iterator`.

Reviewed By: var-const, #libc

Spies: huixie90, libcxx-commits

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

23 months ago[flang] Support intrinsic `selected_int_kind` for variables
Peixin Qiao [Mon, 25 Jul 2022 16:33:27 +0000 (00:33 +0800)]
[flang] Support intrinsic `selected_int_kind` for variables

As Fortran 2018 16.9.169, the argument of selected_int_kind is integer
scalar, and result is default integer scalar. The constant expression in
this intrinsic has been supported by folding the constant expression.
This supports lowering and runtime for variables in this intrinsic.

Reviewed By: Jean Perier

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

23 months ago[flang][nfc] Add missing `REQUIRES: asserts` in a test
Andrzej Warzynski [Mon, 25 Jul 2022 16:21:25 +0000 (16:21 +0000)]
[flang][nfc] Add missing `REQUIRES: asserts` in a test

This change is required for release builds - see
https://reviews.llvm.org/D130185 for more context.

I'm sending this without a review as this is rather straightforward and
identical to the changes from https://reviews.llvm.org/D130185 (the test
updated in this patch wasn't yet in-tree when D130185 landed).

23 months ago[lldb] Make compiler-rt an optional LLDB test dependency
Jonas Devlieghere [Mon, 25 Jul 2022 16:26:09 +0000 (09:26 -0700)]
[lldb] Make compiler-rt an optional LLDB test dependency

Make compiler-rt an LLDB test dependency if the corresponding target
exists. Similarly we already have `asan` and `tsan` as optional test
dependencies, but we need the `compiler-rt` target when enabling
compiler-rt trough LLVM_ENABLE_RUNTIMES.

23 months ago[X86] Custom type legalize v2i32 smulo/umulo to use a single pmuldq/pmuludq.
Craig Topper [Mon, 25 Jul 2022 15:55:37 +0000 (08:55 -0700)]
[X86] Custom type legalize v2i32 smulo/umulo to use a single pmuldq/pmuludq.

With SSE4.1 and above we were using 3 multiply instructions. This
was due to type legalization widening to v4i32 and the low half
being done with pmulld while the high half used two pmuldq/pmuludq.

Instead of that, we can use a single pmuludq/pmuldq to calculate
the full product at once, extract the high and low bits and compare
to check for overflow.

I've restricted SMULO to sse4.1 to get pmuldq. We can probably
do a fixup to pmuludq on earlier targets, but that's for another day.

I was going through my git stash and found an early version of this patch
from a year or two ago so I went ahead and finished it.

Reviewed By: RKSimon

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

23 months ago[llvm][cmake] Shore up `llvm_check_linker_flags`.
John Ericson [Sat, 29 Jan 2022 18:42:12 +0000 (18:42 +0000)]
[llvm][cmake] Shore up `llvm_check_linker_flags`.

Ensure `CMAKE_EXE_LINKER_FLAGS` effects the underlying `try_compile` by setting
this policy to use the new, non-deprecated behavior, without effecting the
caller.

Normally this shouldn't be necessary, as CMake uses
`cmake_minimum_required(VERSION 3.13.4)` consistently, but I suppose
this could rear its head in a downstream project?

Reviewed By: sebastian-ne

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

23 months agoGeneralize the vector transfer flattening patterns (dyn shapes).
Benoit Jacob [Mon, 25 Jul 2022 15:21:33 +0000 (15:21 +0000)]
Generalize the vector transfer flattening patterns (dyn shapes).

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

23 months ago[AArch64][SVE] Fold target specific ext/trunc nodes into loads/stores
Bradley Smith [Thu, 16 Jun 2022 10:33:37 +0000 (10:33 +0000)]
[AArch64][SVE] Fold target specific ext/trunc nodes into loads/stores

Due to the way fixed length SVE lowering works, we sometimes introduce
ext/trunc nodes very late, these nodes then immediately get converted
into target specific nodes (UUNPKLO/UZP1) before they get a chance to be
folded into a load/store.

This patch introduces target specific dag combines for these nodes so that
we can still create extending loads/truncating stores out of them.

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

23 months ago[lldb][AArch64] Use macro for unused var without asserts enabled
David Spickett [Mon, 25 Jul 2022 15:14:03 +0000 (15:14 +0000)]
[lldb][AArch64] Use macro for unused var without asserts enabled

82d4f39f342165a92eaa1fe74488158942cf27b4 marked an unused
var of mine (thanks Dmitri Gribenko!). Which reminded me lldb has
a macro just for that purpose.

23 months ago[lldb][AArch64] Fix an unused variable warning in release builds. NFC
Dmitri Gribenko [Mon, 25 Jul 2022 14:58:03 +0000 (16:58 +0200)]
[lldb][AArch64] Fix an unused variable warning in release builds. NFC

23 months ago[lldb][AArch64] Add UnpackTagsFromCoreFileSegment to MemoryTagManager
David Spickett [Mon, 11 Jul 2022 12:26:36 +0000 (13:26 +0100)]
[lldb][AArch64] Add UnpackTagsFromCoreFileSegment to MemoryTagManager

This is the first part of support for reading MTE tags from Linux
core files. The format is documented here:
https://www.kernel.org/doc/html/latest/arm64/memory-tagging-extension.html#core-dump-support

This patch adds a method to unpack from the format the core
file uses, which is different to the one chosen for GDB packets.

MemoryTagManagerAArch64MTE is not tied one OS so another OS
might choose a different format in future. However, infrastructure
to handle that would go untested until then so I've chosen not to
attempt to handle that.

Reviewed By: omjavaid

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

23 months ago[JITLink][COFF][x86_64] Reimplement ADDR32NB/REL32.
Sunho Kim [Mon, 25 Jul 2022 14:41:53 +0000 (23:41 +0900)]
[JITLink][COFF][x86_64] Reimplement ADDR32NB/REL32.

Reimplements ADDR32NB/REL32 relocations properly, out-of-reach targets will be dealt in the separate patch that will generate the stub for dllimport symbols.

Reviewed By: sgraenitz

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

23 months ago[ORC][COFF] Properly set weak flag to COMDAT symbols.
Sunho Kim [Mon, 25 Jul 2022 14:24:25 +0000 (23:24 +0900)]
[ORC][COFF] Properly set weak flag to COMDAT symbols.

Properly set weak flag to COMDAT symbols so that no duplicate definition error will be generated. There is an inaccuracy in setting plain weak for largest selection type, which will be dealt with soon when largest type is properly implemented.

Reviewed By: lhames

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

23 months ago[JITLink][COFF] Implement IMAGE_SYM_CLASS_LABEL.
Sunho Kim [Mon, 25 Jul 2022 14:21:17 +0000 (23:21 +0900)]
[JITLink][COFF] Implement IMAGE_SYM_CLASS_LABEL.
AcceptedPublic
Implements IMAGE_SYM_CLASS_LABEL. It's simply a section + offset. This is not used a lot by llvm mc but very commonly used by MSVC compiler.

Reviewed By: sgraenitz

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

23 months ago[libc] Raise FE_INVALID for sinf with +- inf inputs.
Tue Ly [Mon, 25 Jul 2022 14:20:32 +0000 (10:20 -0400)]
[libc] Raise FE_INVALID for sinf with +- inf inputs.

23 months ago[mlir][linalg] Expand test case for tile-and-fuse with transform dialect
Matthias Springer [Mon, 25 Jul 2022 14:13:01 +0000 (16:13 +0200)]
[mlir][linalg] Expand test case for tile-and-fuse with transform dialect

Reverse the order of the payload ops. fuse_into_containing_op should still work.

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

23 months ago[JITLink][COFF] Handle out-of-order COMDAT second symbol.
Sunho Kim [Mon, 25 Jul 2022 14:02:31 +0000 (23:02 +0900)]
[JITLink][COFF] Handle out-of-order COMDAT second symbol.

Handle out-of-order COMDAT second symbols. In llvm codegen, the second symbol of COMDAT sequence always follows the first symbol in the global symbol list. But, when the object file came from MSVC compiler, these can come in out of order.

Reviewed By: lhames

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

23 months ago[JITLink][COFF] Don't dead strip COMDAT associative symbol.
Sunho Kim [Mon, 25 Jul 2022 13:59:19 +0000 (22:59 +0900)]
[JITLink][COFF] Don't dead strip COMDAT associative symbol.

This prevents the dead strip of associative comdat section when parent section is alive.

Reviewed By: sgraenitz

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

23 months agoReapply "[NFC] Add some additional features to MultiLevelTemplateArgumentList""
Erich Keane [Mon, 25 Jul 2022 13:21:54 +0000 (06:21 -0700)]
Reapply "[NFC] Add some additional features to MultiLevelTemplateArgumentList""

This reverts commit 6a1ccf61cdf80c793f9c699ada33af5d85263b30.

A typo in an assert escaped my local testing thanks to being a release
build :/

23 months ago[llvm-objdump,ARM] Fix .byte directives dumping the wrong byte.
Simon Tatham [Mon, 25 Jul 2022 13:55:31 +0000 (14:55 +0100)]
[llvm-objdump,ARM] Fix .byte directives dumping the wrong byte.

The clause in `dumpARMELFData` that dumps a single byte as a `.byte`
directive was printing the operand of that directive as `Bytes[0]`,
not `Bytes[Index]`. In particular, this led to the `dumpBytes` output
to its left not matching it!

Reviewed By: DavidSpickett

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

23 months ago[mlir] move _mlir_alloc and friends to CRunnerUtils
Alex Zinenko [Mon, 18 Jul 2022 16:28:04 +0000 (18:28 +0200)]
[mlir] move _mlir_alloc and friends to CRunnerUtils

These functions don't depend on the C++ runtime and therefore belong to
CRunnerUtils. Clean up the macros on the way as `_MSC_VER` indicates the
compiler, not the platform, which is indicated by `_WIN32` and will be
present when, e.g., compiling with minGW.

Reviewed By: rdzhabarov

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

23 months ago[MLIR] Generic 'malloc', 'aligned_alloc' and 'free' functions
Michele Scuttari [Mon, 25 Jul 2022 13:42:36 +0000 (15:42 +0200)]
[MLIR] Generic 'malloc', 'aligned_alloc' and 'free' functions

When converted to the LLVM dialect, the memref.alloc and memref.free operations were generating calls to hardcoded 'malloc' and 'free' functions. This didn't leave any freedom to users to provide their custom implementation. Those operations now convert into calls to '_mlir_alloc' and '_mlir_free' functions, which have also been implemented into the runtime support library as wrappers to 'malloc' and 'free'. The same has been done for the 'aligned_alloc' function.

Reviewed By: ftynse

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

23 months agoRevert "Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info""
Saiyedul Islam [Mon, 25 Jul 2022 13:32:26 +0000 (08:32 -0500)]
Revert "Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info""

This reverts commit 8cbf4a386b6740180fe48aaebbd1ca9f8ee14367.

23 months ago[C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]
Iain Sandoe [Wed, 6 Jul 2022 06:40:01 +0000 (07:40 +0100)]
[C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]

This includes the revised provisions of [basic.lookup.argdep] p4

1. ADL is amended to handle p 4.3 where functions in trasitively imported modules may
become visible when they are exported in the same namespace as a visible type.

2. If a function is in a different modular TU, and has internal-linkage, we invalidate
its entry in an overload set.

[basic.lookup.argdep] p5 ex 2 now passes.

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

23 months ago[Sema] Merge C++20 concept definitions from different modules in same TU
Ilya Biryukov [Mon, 25 Jul 2022 10:42:42 +0000 (12:42 +0200)]
[Sema] Merge C++20 concept definitions from different modules in same TU

Currently the C++20 concepts are only merged in `ASTReader`, i.e. when
coming from different TU. This can causes ambiguious reference errors when
trying to access the same concept that should otherwise be merged.

Please see the added test for an example.

Note that we currently use `ASTContext::isSameEntity` to check for ODR
violations. However, it will not check that concept requirements match.
The same issue holds for mering concepts from different TUs, I added a
FIXME and filed a GH issue to track this:
https://github.com/llvm/llvm-project/issues/56310

Reviewed By: ChuanqiXu

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

23 months ago[LoongArch] Parse LoongArch base ABI in ObjectYAML and llvm-readobj
Weining Lu [Mon, 25 Jul 2022 09:24:25 +0000 (17:24 +0800)]
[LoongArch] Parse LoongArch base ABI in ObjectYAML and llvm-readobj

LoongArch e_flags definition:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version

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

23 months ago[lldb][ARM/AArch64] Use sys/uio.h instead of socket.h in native register context
David Spickett [Mon, 25 Jul 2022 10:55:45 +0000 (10:55 +0000)]
[lldb][ARM/AArch64] Use sys/uio.h instead of socket.h in native register context

We only want iovec and uio.h is just that without a lot
of other stuff. Saves me wondering why this code might
want to open sockets.

https://pubs.opengroup.org/onlinepubs/007904975/basedefs/sys/uio.h.html

23 months ago[AArch64] Combine setcc (iN (bitcast (vNi1 X))) with vecreduce_or
Cullen Rhodes [Mon, 25 Jul 2022 11:57:27 +0000 (11:57 +0000)]
[AArch64] Combine setcc (iN (bitcast (vNi1 X))) with vecreduce_or

Reviewed By: paulwalker-arm

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

23 months ago[AArch64][NFC] Add test case for setcc (iN bitcast (vNi1 X)), (iN 0), (eq|ne)
Cullen Rhodes [Mon, 25 Jul 2022 11:54:15 +0000 (11:54 +0000)]
[AArch64][NFC] Add test case for setcc (iN bitcast (vNi1 X)), (iN 0), (eq|ne)

To be combined to 'setcc (iN (zext (i1 (vecreduce_or (vNi1 X))))), 0, (eq|ne)'
in follow on patch.

Reviewed By: peterwaller-arm

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

23 months ago[SystemZ][z/OS] Open YAML text files as text
Abhina Sreeskantharajan [Mon, 25 Jul 2022 12:06:16 +0000 (08:06 -0400)]
[SystemZ][z/OS] Open YAML text files as text

This patch sets the YAML file as text instead of binary.

Reviewed By: MaskRay

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

23 months ago[flang] Support lowering intrinsic `selected_real_kind` for variables
Peixin Qiao [Mon, 25 Jul 2022 11:36:14 +0000 (19:36 +0800)]
[flang] Support lowering intrinsic `selected_real_kind` for variables

As Fortran 2018 16.9.170, the argument of `selected_real_kind` is integer
scalar, and result is default integer scalar. The constant expression in
this intrinsic has been supported by folding the constant expression.
This supports lowering this intrinsic for variables using runtime.

Reviewed By: Jean Perier

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

23 months ago[ValueTracking] Fix unused variable warning in release builds. NFC
Benjamin Kramer [Mon, 25 Jul 2022 11:28:32 +0000 (13:28 +0200)]
[ValueTracking] Fix unused variable warning in release builds. NFC

23 months agoRewording "static_assert" diagnostics
Muhammad Usman Shahid [Mon, 25 Jul 2022 11:22:54 +0000 (07:22 -0400)]
Rewording "static_assert" diagnostics

This patch rewords the static assert diagnostic output. Failing a
_Static_assert in C should not report that static_assert failed. This
changes the wording to be more like GCC and uses "static assertion"
when possible instead of hard coding the name. This also changes some
instances of 'static_assert' to instead be based on the token in the
source code.

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

23 months agoSwitch from XFAIL to UNSUPPORTED; NFC
Aaron Ballman [Mon, 25 Jul 2022 11:18:48 +0000 (07:18 -0400)]
Switch from XFAIL to UNSUPPORTED; NFC

This test is currently marked as XFAIL for Windows, but running the
test with a debug build of clang-repl.exe crashes with a modal system
dialog. This switches the test to UNSUPPORTED instead. This makes the
test behavior less onerous for those of us doing Debug builds, at the
expense of a minor bit of coverage if the test were ever to start
passing unexpectedly on Windows (which seems like an unlikely event).

23 months ago[C++20][Modules] Add a testcase for [basic.link] p10 [NFC].
Iain Sandoe [Mon, 25 Jul 2022 09:50:16 +0000 (10:50 +0100)]
[C++20][Modules] Add a testcase for [basic.link] p10 [NFC].

This adds a testcase based on example 2 from the basic.link section of the
standard.

23 months ago[pseudo] Eliminate multiple-specified-types ambiguities using guards
Sam McCall [Fri, 22 Jul 2022 09:28:51 +0000 (11:28 +0200)]
[pseudo] Eliminate multiple-specified-types ambiguities using guards

Motivating case: `foo bar;` is not a declaration of nothing with `foo` and `bar`
both types.

This is a common and critical ambiguity, clangd/AST.cpp has 20% fewer
ambiguous nodes (1674->1332) after this change.

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

23 months ago[mlir][tensor][bufferize][NFC] Remove duplicate code
Matthias Springer [Mon, 25 Jul 2022 10:29:01 +0000 (12:29 +0200)]
[mlir][tensor][bufferize][NFC] Remove duplicate code

InsertSliceOp and ParallelInsertSliceOp are very similar and can share some of the bufferization analysis code.

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

23 months agoRevert "[Libomptarget] Add checks for AMDGPU TargetID using new image info"
Saiyedul Islam [Mon, 25 Jul 2022 10:32:59 +0000 (05:32 -0500)]
Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info"

This reverts commit 471f2abc62d96b3ef97e13f4f7be2d386fc9f75f.

23 months ago[mlir][tensor][bufferize] Fix deallocation of GenerateOp/FromElementsOp
Matthias Springer [Mon, 25 Jul 2022 10:24:24 +0000 (12:24 +0200)]
[mlir][tensor][bufferize] Fix deallocation of GenerateOp/FromElementsOp

Both ops allocate a buffer. There were cases in which the buffer was not deallocated.

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

23 months ago[mlir] Transform dialect: separate dependent and generated dialects
Alex Zinenko [Thu, 21 Jul 2022 17:16:13 +0000 (17:16 +0000)]
[mlir] Transform dialect: separate dependent and generated dialects

In the Transform dialect extensions, provide the separate mechanism to
declare dependent dialects (the dialects the transform IR depends on)
and the generated dialects (the dialects the payload IR may be
transformed into). This allows the Transform dialect clients that are
only constructing the transform IR to avoid loading the dialects
relevant for the payload IR along with the Transform dialect itself,
thus decreasing the build/link time.

Reviewed By: springerm

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

23 months ago[C++20] [Modules] Make the linkage consistent for class template and its
Chuanqi Xu [Mon, 25 Jul 2022 09:43:52 +0000 (17:43 +0800)]
[C++20] [Modules] Make the linkage consistent for class template and its
specialization

Previously in D120397, we've handled the linkage for function template
and its specialization. But we forgot to handle it for class templates
and their specialization. So we make it in the patch with the similar
approach.

23 months agoAMDGPU: Turn off force init 16 input SGPRS for pal
David Stuttard [Tue, 12 Jul 2022 15:12:51 +0000 (16:12 +0100)]
AMDGPU: Turn off force init 16 input SGPRS for pal

Pal uses a different mechanism for user sgprs.

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

23 months ago[Libomptarget] Add checks for AMDGPU TargetID using new image info
Saiyedul Islam [Fri, 22 Jul 2022 14:43:15 +0000 (09:43 -0500)]
[Libomptarget] Add checks for AMDGPU TargetID using new image info

This patch extends the is_valid_binary routine to also check if the
binary's target ID matches the one parsed from the system's runtime
environment.
This should allow us to only use the binary whose compute capability
matches, allowing us to support basic multi-architecture binaries for
AMDGPU.
It also handles compatibility testing of target IDs of the image and
the enviornment.

Depends on D127432

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

23 months ago[mlir][tensor][bufferize] Load dependent dialects
Matthias Springer [Mon, 25 Jul 2022 09:30:22 +0000 (11:30 +0200)]
[mlir][tensor][bufferize] Load dependent dialects

Load dialects that will be generated by the extension. (Except for BufferizationDialect and MemrefDialect which are loaded already.)

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

23 months ago[RISCV] Scalarize binop followed by extractelement.
jacquesguan [Tue, 12 Jul 2022 06:12:23 +0000 (14:12 +0800)]
[RISCV] Scalarize binop followed by extractelement.

This patch adds shouldScalarizeBinop to RISCV target in order to convert an extract element of a vector binary operation into an extract element followed by a scalar binary operation.

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

23 months ago[DebugInfo] Avoid ptrtoint expression in generic test
Nikita Popov [Mon, 25 Jul 2022 09:18:01 +0000 (11:18 +0200)]
[DebugInfo] Avoid ptrtoint expression in generic test

After D130366 the ptrtoint expression this used results in an
error on 32-bit targets (the IR was already invalid previously,
but only produced the error with -filetype=obj).

Tweak the IR so it is correct for both 32-bit and 64-bit targets,
and can thus continue working as a generic test.

23 months ago[mlir][sparse][nfc] Fix memory leak in sparse sampled matmul integration test
Rajas Vanjape [Sat, 23 Jul 2022 16:55:17 +0000 (16:55 +0000)]
[mlir][sparse][nfc] Fix memory leak in sparse sampled matmul integration test

https://reviews.llvm.org/D130023 added a memory leak in sparse_sampled_matmul.mlir
This diff fixes the memory leak.

Testing: Ran integration tests after building with -DLLVM_USE_SANITIZER=Address flag.

Reviewed By: springerm

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

23 months ago[mlir] Apply ClangTidyPerformance findings (NFC)
Adrian Kuegel [Mon, 25 Jul 2022 08:49:14 +0000 (10:49 +0200)]
[mlir] Apply ClangTidyPerformance findings (NFC)

23 months ago[CMake] Copy folder without permissions
Sebastian Neubauer [Fri, 22 Jul 2022 09:31:20 +0000 (11:31 +0200)]
[CMake] Copy folder without permissions

Copying the folder keeps the original permissions by default. This
creates problems when the source folder is read-only, e.g. in a
packaging environment.
Then, the copied folder in the build directory is read-only as well.
Later on, other files are copied into that directory (in the build
tree), failing when the directory is read-only.

Fix that problem by copying the folder without keeping the original
permissions.

Follow-up to D130254.

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

23 months agotsan: prevent pathological slowdown for spurious races
Dmitry Vyukov [Thu, 21 Jul 2022 13:48:19 +0000 (15:48 +0200)]
tsan: prevent pathological slowdown for spurious races

Prevent the following pathological behavior:
Since memory access handling is not synchronized with DoReset,
a thread running concurrently with DoReset can leave a bogus shadow value
that will be later falsely detected as a race. For such false races
RestoreStack will return false and we will not report it.
However, consider that a thread leaves a whole lot of such bogus values
and these values are later read by a whole lot of threads.
This will cause massive amounts of ReportRace calls and lots of
serialization. In very pathological cases the resulting slowdown
can be >100x. This is very unlikely, but it was presumably observed
in practice: https://github.com/google/sanitizers/issues/1552
If this happens, previous access sid+epoch will be the same for all of
these false races b/c if the thread will try to increment epoch, it will
notice that DoReset has happened and will stop producing bogus shadow
values. So, last_spurious_race is used to remember the last sid+epoch
for which RestoreStack returned false. Then it is used to filter out
races with the same sid+epoch very early and quickly.
It is of course possible that multiple threads left multiple bogus shadow
values and all of them are read by lots of threads at the same time.
In such case last_spurious_race will only be able to deduplicate a few
races from one thread, then few from another and so on. An alternative
would be to hold an array of such sid+epoch, but we consider such scenario
as even less likely.
Note: this can lead to some rare false negatives as well:
1. When a legit access with the same sid+epoch participates in a race
as the "previous" memory access, it will be wrongly filtered out.
2. When RestoreStack returns false for a legit memory access because it
was already evicted from the thread trace, we will still remember it in
last_spurious_race. Then if there is another racing memory access from
the same thread that happened in the same epoch, but was stored in the
next thread trace part (which is still preserved in the thread trace),
we will also wrongly filter it out while RestoreStack would actually
succeed for that second memory access.

Reviewed By: melver

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

23 months agotsan: remove tracking of racy addresses
Dmitry Vyukov [Thu, 21 Jul 2022 09:52:17 +0000 (11:52 +0200)]
tsan: remove tracking of racy addresses

We used to deduplicate based on the race address to prevent lots
of repeated reports about the same race.

But now we clear the shadow for the racy address in DoReportRace:

  // This prevents trapping on this address in future.
  for (uptr i = 0; i < kShadowCnt; i++)
    StoreShadow(&shadow_mem[i], i == 0 ? Shadow::kRodata : Shadow::kEmpty);

It should have the same effect of not reporting duplicates
(and actually better because it's automatically reset when the memory is reallocated).

So drop the address deduplication code. Both simpler and faster.

Reviewed By: melver

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

23 months ago[clang][ASTImporter] Improved handling of functions with auto return type.
Balázs Kéri [Mon, 25 Jul 2022 07:30:37 +0000 (09:30 +0200)]
[clang][ASTImporter] Improved handling of functions with auto return type.

Avoid a crash if a function is imported that has auto return type that
references to a template with an expression-type of argument that
references into the function's body.
Fixes issue #56047

Reviewed By: martong

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

23 months ago[mlir][Math] Add constant folder for ExpOp.
jacquesguan [Fri, 22 Jul 2022 00:46:05 +0000 (08:46 +0800)]
[mlir][Math] Add constant folder for ExpOp.

This patch adds constant folder for ExpOp which only supports single and double precision floating-point.

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

23 months ago[ELF] --reproduce: support --export-dynamic-symbol-list
Fangrui Song [Mon, 25 Jul 2022 08:20:32 +0000 (01:20 -0700)]
[ELF] --reproduce: support --export-dynamic-symbol-list

23 months ago[llvm][FileCheck] Fix unit tests failures with EXPENSIVE_CHECKS
David Spickett [Thu, 21 Jul 2022 15:36:52 +0000 (15:36 +0000)]
[llvm][FileCheck] Fix unit tests failures with EXPENSIVE_CHECKS

EXPENSIVE_CHECKS enables _GLIBCXX_DEBUG, which makes std::sort
check that the compare function is implemented correctly.

To do this it calls it with the first item as both sides.
Which trips the assert here because we think they're
2 capture ranges that overlap, when it's just the same range twice.

Check up front for the two sides being the same item
(same address, not just ==).

Reviewed By: kazu

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

23 months ago[AsmPrinter] Reject ptrtoint to larger size in lowerConstant()
Nikita Popov [Fri, 22 Jul 2022 14:10:37 +0000 (16:10 +0200)]
[AsmPrinter] Reject ptrtoint to larger size in lowerConstant()

When using a ptrtoint to a size larger than the pointer width in a
global initializer, we currently create a ptr & low_bit_mask style
MCExpr, which will later result in a relocation error during object
file emission.

This patch rejects the constant expression already during
lowerConstant(), which results in a much clearer error message
that references the constant expression at fault.

This fixes https://github.com/llvm/llvm-project/issues/56400,
for certain definitions of "fix".

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

23 months ago[ELF] Simplify --build-id/--color-diagnostics with AliasArgs. NFC
Fangrui Song [Mon, 25 Jul 2022 08:14:53 +0000 (01:14 -0700)]
[ELF] Simplify --build-id/--color-diagnostics with AliasArgs. NFC

23 months ago[AArch64] Add f16 fpimm patterns
Rosie Sumpter [Wed, 20 Jul 2022 12:53:59 +0000 (13:53 +0100)]
[AArch64] Add f16 fpimm patterns

This patch recognizes f16 immediates as legal and adds the necessary
patterns. This allows the fadda folding introduced in 05d424d16563
to be applied to the f16 cases.

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

23 months ago[pseudo] Fix minor errors in module grammar
Sam McCall [Mon, 25 Jul 2022 08:00:05 +0000 (10:00 +0200)]
[pseudo] Fix minor errors in module grammar

23 months ago[NFC][GVN] Put phi-translation of 'add' behind a switch
Peter Waller [Thu, 21 Jul 2022 19:33:24 +0000 (20:33 +0100)]
[NFC][GVN] Put phi-translation of 'add' behind a switch

The code in this `#if 0` block appears to be a net benefit. Put it
behind a switch defaulting to off to support experimentation and as a
request for comment.

The codegen impact of enabling this that I'm currently persuing is that
it allows PRE to take place more frequently, particularly in loops with
second order recurrences.

Preliminary experimental data:

Across LNT on AArch64, 54 benchmarks are sped up by >1%, and 42 are
regressed by >1%, the geomean (exec_time_enabled / exec_time_disabled)
of these 96 "1% or greater significance" benchmarks is 0.991. For the
full set of 770 benchmarks it's 0.998.

There are two benchmarks which experience a >30% speedup, and the worst
slowdown is ~12%, and for every benchmark with a slowdown there is a
benckmark which is sped up by a greater factor.

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

23 months ago[flang] Use X->foo() instead of X.getValue().foo() (NFC)
Kazu Hirata [Mon, 25 Jul 2022 07:55:06 +0000 (00:55 -0700)]
[flang] Use X->foo() instead of X.getValue().foo() (NFC)

Flang C++ Style Guide tells us to use *X when the reference is
protected by a presense test.  However, (*X).foo() is a little harder
to read, especially when X is a complicated expression.

This patch slightly deviates from the guide (but retains the spirit)
by using X->foo() instead.

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

23 months ago[flang] Use value instead of getValue (NFC)
Kazu Hirata [Mon, 25 Jul 2022 07:55:05 +0000 (00:55 -0700)]
[flang] Use value instead of getValue (NFC)

Flang C++ Style Guide tells us to use x.value() when no presence test
is obviously protecting the reference.  Since a failure in EXPECT_TRUE
doesn't terminate a given test, I don't count it as "protection" here.

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

23 months ago[Docs] Update GEP docs for opaque pointers
Nikita Popov [Fri, 22 Jul 2022 12:36:27 +0000 (14:36 +0200)]
[Docs] Update GEP docs for opaque pointers

Update the GEP FAQ to use opaque pointers. This requires more than
a syntactic change in some place, because some of the concerns just
don't make sense anymore (trying to index past a ptr member in a
struct for example).

This also fixes uses of incorrect syntax to declare or reference
globals.

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

23 months ago[LangRef] Update for opaque pointers (NFC)
Nikita Popov [Fri, 22 Jul 2022 12:58:07 +0000 (14:58 +0200)]
[LangRef] Update for opaque pointers (NFC)

Update LangRef examples to use opaque pointers in most places.
I've retained typed pointers in a few cases where opaque pointers
don't make much sense, e.g. pointer to pointer bitcasts.

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

23 months ago[llvm-objcopy] Simplify --compress-debug-sections handling with AliasArgs. NFC
Fangrui Song [Mon, 25 Jul 2022 07:31:00 +0000 (00:31 -0700)]
[llvm-objcopy] Simplify --compress-debug-sections handling with AliasArgs. NFC

23 months ago[clang][analyzer] Added partial wide character support to CStringChecker
Balázs Kéri [Mon, 25 Jul 2022 06:30:00 +0000 (08:30 +0200)]
[clang][analyzer] Added partial wide character support to CStringChecker

Support for functions wmemcpy, wcslen, wcsnlen is added to the checker.
Documentation and tests are updated and extended with the new functions.

Reviewed By: martong

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

23 months ago[AArch64][SVE] Add patterns to select masked add/sub instructions
Cullen Rhodes [Mon, 25 Jul 2022 06:37:57 +0000 (06:37 +0000)]
[AArch64][SVE] Add patterns to select masked add/sub instructions

When lowering add(a, select(mask, b, splat(0))) the sel instruction can
be removed by using predicated add/sub instructions.

Reviewed By: paulwalker-arm

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

23 months ago[AArch64][SVE] NFC: Add tests for masked add/sub patterns (D129751)
Cullen Rhodes [Mon, 25 Jul 2022 07:13:13 +0000 (07:13 +0000)]
[AArch64][SVE] NFC: Add tests for masked add/sub patterns (D129751)

23 months ago[llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC
Fangrui Song [Mon, 25 Jul 2022 07:06:36 +0000 (00:06 -0700)]
[llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC

23 months ago[SCEV][NFC][CT] Cheaper handling of guards in isBasicBlockEntryGuardedByCond
Max Kazantsev [Mon, 25 Jul 2022 04:56:01 +0000 (11:56 +0700)]
[SCEV][NFC][CT] Cheaper handling of guards in isBasicBlockEntryGuardedByCond

Handle guards uniformly with assumes, rather than iterating through all
block instructions in attempt to find them.

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