platform/upstream/llvm.git
2 years ago[Objcopy][Wasm] Allow selecting known sections by name
Derek Schuff [Mon, 6 Jun 2022 20:40:43 +0000 (13:40 -0700)]
[Objcopy][Wasm] Allow selecting known sections by name

Currently, only custom sections can be selected by operations that use section
names, because only custom sections have explicit names (whereas known sections
have names defined by the spec and only use their indices in the binary format).
This CL makes objdopy use the spec-defined names for these sections, allowing
them to be used in operations such as dumping and removal.

This is a prerequisite for fixing
https://github.com/emscripten-core/emscripten/issues/13084

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

2 years ago[ARM] Use llvm::dbgs() to print debug info (NFC)
ksyx [Mon, 6 Jun 2022 20:39:28 +0000 (16:39 -0400)]
[ARM] Use llvm::dbgs() to print debug info (NFC)

For consistency with other parts of code.

Approved by efriedma in differential revision
https://reviews.llvm.org/D127055

2 years ago[gn build] Port b79b2b677256
LLVM GN Syncbot [Mon, 6 Jun 2022 20:32:38 +0000 (20:32 +0000)]
[gn build] Port b79b2b677256

2 years ago[mlir][vector] Allow unroll of contraction in arbitrary order
Christopher Bate [Fri, 3 Jun 2022 22:34:47 +0000 (16:34 -0600)]
[mlir][vector] Allow unroll of contraction in arbitrary order

Adds supprot for vector unroll transformations to unroll in different
orders. For example, the `vector.contract` can be unrolled into a
smaller set of contractions.  There is a choice of how to unroll the
decomposition  based on the traversal order of (dim0, dim1, dim2).
The choice of traversal order can now be specified by a callback which
given by the caller of the transform. For now, only the
`vector.contract`, `vector.transfer_read/transfer_write` operations
support the callback.

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

2 years ago[libc++] Implement ranges::find_first_of
Nikolas Klauser [Mon, 6 Jun 2022 11:57:34 +0000 (13:57 +0200)]
[libc++] Implement ranges::find_first_of

Reviewed By: Mordante, var-const, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[clang] [MinGW] Default to WinEH (SEH) exception handling instead of Dwarf
Martin Storsjö [Tue, 3 May 2022 14:45:36 +0000 (17:45 +0300)]
[clang] [MinGW] Default to WinEH (SEH) exception handling instead of Dwarf

The relevant runtime libraries have been updated to support this
now.

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

2 years ago[ARM] [MinGW] Default to WinEH exception handling instead of Dwarf
Martin Storsjö [Fri, 13 May 2022 08:45:52 +0000 (11:45 +0300)]
[ARM] [MinGW] Default to WinEH exception handling instead of Dwarf

Switching this target to WinEH also seems to affect the `-windows-itanium`
target.

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

2 years ago[libunwind] Don't store a predecremented PC when using SEH
Martin Storsjö [Wed, 11 May 2022 08:20:38 +0000 (11:20 +0300)]
[libunwind] Don't store a predecremented PC when using SEH

This fixes unwinding in boundary cases on ARM with SEH.

In the case of ARM/Thumb, disp->ControlPc points at the following
instruction, with the thumb bit set. Thus by decrementing 1,
it still points at the next instruction. To achieve the desired
effect of pointing at the previous instruction, one first has to strip
out the thumb bit, then do the decrement by 1 to reach the previous
instruction.

When libcxxabi looks for call site ranges, it already does
`_Unwind_GetIP(context) - 1` (in `scan_eh_tab` in
libcxxabi/src/cxa_personality.cpp), so we shouldn't do the
corresponding `- 1` multiple times.

In the case of libcxxabi on Thumb, `funcStart` (still in `scan_eh_tab`)
may have the thumb bit set. If the program counter address is
decremented both in libunwind (first removing the thumb bit, then
decremented), and then libcxxabi decrements it further, and compares
with a `funcStart` with the thumb bit set, it could point to one byte
before the start of the call site.

Thus: This modification makes libunwind with SEH work with libcxxabi
on Thumb, in settings where libunwind and libcxxabi worked fine with
Dwarf before.

For existing cases with libunwind with SEH (on x86_64 and aarch64),
this modification doesn't break any of my testcases.

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

2 years ago[libunwind] Remove unused ARM SEH placeholder code
Martin Storsjö [Tue, 10 May 2022 10:02:59 +0000 (13:02 +0300)]
[libunwind] Remove unused ARM SEH placeholder code

There's no such corresponding code for ARM64 (which has been working
in production for years). The SEH version of the Unwind functions
(e.g. `_Unwind_GetLanguageSpecificData`) doesn't use these fields.

The `_Unwind_ForcedUnwind` function would need these bits though,
but that's not used in normal C++ exception unwinding.

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

2 years ago[libunwind] Fix SEH unwinding on ARM
Martin Storsjö [Fri, 6 May 2022 21:26:45 +0000 (00:26 +0300)]
[libunwind] Fix SEH unwinding on ARM

Check `__SEH__` when checking if ARM EHABI should be implied,
similarly to 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 / D126866.

Fix a warning by using the right format specifier (PRIxPTR instead
of PRIx64), and add a double->float cast in a codepath that hasn't
been built so far.

This is enough to make SEH unwinding of itanium ABI exceptions on
ARM mostly work - one specific issue is fixed in a separate follow-up
patch.

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

2 years ago[builtins] Check __SEH__, when checking if ARM EHABI is implied
Martin Storsjö [Fri, 6 May 2022 21:19:05 +0000 (00:19 +0300)]
[builtins] Check __SEH__, when checking if ARM EHABI is implied

ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

This is the same change as 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 /
D126866, applied on the compiler-rt builtins gcc_personality_v0
function.

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

2 years ago[clang] [Headers] Check __SEH__, when checking if ARM EHABI is implied
Martin Storsjö [Fri, 6 May 2022 21:23:34 +0000 (00:23 +0300)]
[clang] [Headers] Check __SEH__, when checking if ARM EHABI is implied

ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

This is the same change as 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7 /
D126866, applied on the clang headers.

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

2 years ago[libcxxabi] Check __SEH__, when checking if ARM EHABI is implied
Martin Storsjö [Fri, 6 May 2022 21:37:40 +0000 (00:37 +0300)]
[libcxxabi] Check __SEH__, when checking if ARM EHABI is implied

ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

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

2 years ago[libcxx] Omit dllimport in public headers in MinGW mode
Martin Storsjö [Sat, 9 Apr 2022 21:32:03 +0000 (00:32 +0300)]
[libcxx] Omit dllimport in public headers in MinGW mode

In MinGW environments, thanks to slightly different code generation
and linker tricks, it's possible to link against a DLL C++ standard
library without dllimport attributes.

This allows using one single set of headers for linking against
either the DLL or a static library, leaving the decision entirely
up to the linking stage (where it can be switched with options like
-static-libstdc++).

This matches how libstdc++ headers work; there's no dllimport attributes
by default (unless the user has defined _GLIBCXX_DLL when including
headers).

This allows using one single set of headers while linking against
either a DLL or a static library, just like on Unix platforms.

This matches how libc++ has been used in MinGW configurations for
years (by first building the DLL, then configuring a static-only
build and installing on top, overwriting the libc++ config file
with one for static linking) by multiple MinGW toolchains, making
the dllimport-less use the de-facto tested configuration in the wild.

This also allows building all of libc++ in one single CMake
configuration, instead of having to do two separate builds on top of
each other.

(Linking against a DLL without dllimport can break if e.g. templates
use inconsistent visibility attributes - in cases where it still
works when using explicit dllimport; such a case was fixed in
948dd664c3ed30dd853df03cb931436f280bad4a / D99932. With this as the
default configuration, we can catch such issues in CI.)

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

2 years ago[libcxx] [test] Don't use header defines for detecting linking against a DLL
Martin Storsjö [Sun, 10 Apr 2022 21:32:11 +0000 (00:32 +0300)]
[libcxx] [test] Don't use header defines for detecting linking against a DLL

In clang-cl/MSVC environments, linking against a DLL C++ standard
library requires having dllimport attributes in the headers; this
has been used for detecting whether the tests link against a DLL,
by looking at the libc++ specific define
_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS.

In mingw environments, thanks to slightly different code generation
and a couple linker tricks, it's possible to link against a DLL C++
standard library without dllimport attributes. Therefore, don't
rely on the libc++ specific header define for the detection.

Replace the detection with a runtime test.

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

2 years ago[mlir] Add documentation for PDLL LSP features and setup
River Riddle [Sun, 15 May 2022 22:23:35 +0000 (15:23 -0700)]
[mlir] Add documentation for PDLL LSP features and setup

This commit beefs up the documentation for MLIR language servers by
adding proper documentations/examples/etc for the provided PDLL
language server capabilities. Given that this documentation is also used
for the vscode extension, this commit also updates the user facing vscode
extension documentation.

Not that the images referenced in the new documentation are hosted on
the website, and will be commited to mlir-www shortly after this commit
lands.

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

2 years ago[DirectX] Embed DXIL in LLVM Module
Chris Bieneman [Tue, 10 May 2022 19:58:01 +0000 (14:58 -0500)]
[DirectX] Embed DXIL in LLVM Module

At the end of the codegen pipeline for DXIL we will emit the DXIL into
a global variable in the Module annotated for the "DXIL" section.

This will be used by the MCDXContainerStreamer to emit the DXIL into a
DXContainer DXIL part.

Other parts of the DXContainer will be constructed similarly by
serializing their values into GlobalVariables.

This will allow DXIL to flow into DXContainers through the normal
MCStreamer flow used in the MC layer.

Depends on D122270

Reviewed By: kuhar

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

2 years ago[NFC] Change lit test for print-changed=dot-cfg to use regular expression
Jamie Schmeiser [Mon, 6 Jun 2022 19:51:48 +0000 (15:51 -0400)]
[NFC] Change lit test for print-changed=dot-cfg to use regular expression

Summary:

Issue 55761:
Change the lit test for print-changed=dot-cfg to have a regular expression
for the template arguments portion of the name for a pass manager pass.
This part of the name can change because it is based on the name provided
by the compiler, which is implementation-dependent. This mimics the
other change printer tests.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: mgorny (Michal Gorny)
Differential Revision: https://reviews.llvm.org/D126876

2 years ago[ModuloSchedule] Fix terminator update when peeling.
Hendrik Greving [Wed, 25 May 2022 15:18:55 +0000 (15:18 +0000)]
[ModuloSchedule] Fix terminator update when peeling.

Fixes a bug of us not correctly updating the terminator of the loop's
preheader, if multiple terminating branch instructions are present.

This is tested through existing tests. The bug itself is hard or not
possible to get exposed with the upstream Hexagon backend, because
the machine pipeliner checks for an existing preheader, which is
defined as a block with only 1 edge into the header.

The condition of this bug is a block into the loop with more than 1
edge, and not every downstream target checks for an existing preheader.

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

2 years ago[gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in
Akira Hatanaka [Tue, 17 May 2022 16:37:29 +0000 (09:37 -0700)]
[gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in
DebugTypeVisitor

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

2 years ago[RISCV] Autogen a test for ease of update
Philip Reames [Mon, 6 Jun 2022 19:44:05 +0000 (12:44 -0700)]
[RISCV] Autogen a test for ease of update

2 years ago[docs] Fix style and typo in HowToSetUpLLVMStyleRTTI.rst after D126943
Fangrui Song [Mon, 6 Jun 2022 19:41:21 +0000 (12:41 -0700)]
[docs] Fix style and typo in HowToSetUpLLVMStyleRTTI.rst after D126943

2 years ago[mlir][linalg] add conv_2d_nhwc_fhwc named op
Christopher Bate [Fri, 3 Jun 2022 02:06:24 +0000 (20:06 -0600)]
[mlir][linalg] add conv_2d_nhwc_fhwc named op

This operation should be supported as a named op because
when the operands are viewed as having canonical layouts
with decreasing strides, then the "reduction" dimensions
of the filter (h, w, and c) are contiguous relative to each
output channel. When lowered to a matrix multiplication,
this layout is the simplest to deal with, and thus future
transforms/vectorizations of `conv2d` may find using this
named op convenient.

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

2 years ago[lld-macho] Demangle symbol names in duplicate-symbol error when -demangle is specified
Vy Nguyen [Fri, 3 Jun 2022 20:30:06 +0000 (16:30 -0400)]
[lld-macho] Demangle symbol names in duplicate-symbol error when -demangle is specified

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

2 years ago[BPF] Add BTF 64bit enum value support
Yonghong Song [Wed, 20 Apr 2022 22:07:08 +0000 (15:07 -0700)]
[BPF] Add BTF 64bit enum value support

Current BTF only supports 32-bit value. For example,
  enum T { VAL = 0xffffFFFF00000008 };
the generated BTF looks like
        .long   16                              # BTF_KIND_ENUM(id = 4)
        .long   100663297                       # 0x6000001
        .long   8
        .long   18
        .long   8
The encoded value is 8 which equals to (uint32_t)0xffffFFFF00000008
and this is incorrect.

This patch introduced BTF_KIND_ENUM64 which permits to encode
64-bit value. The format for each enumerator looks like:
        .long   name_offset
        .long   (uint32_t)value # lower-32 bit value
        .long   value >> 32     # high-32 bit value

We use two 32-bit values to represent a 64-bit value as current
BTF type subsection has 4-byte alignment and gaps are not permitted
in the subsection.

This patch also added support for kflag (the bit 31 of CommonType.Info)
such that kflag = 1 implies the value is signed and kflag = 0
implies the value is unsigned. The kernel UAPI enumerator definition is
  struct btf_enum {
        __u32   name_off;
        __s32   val;
  };
so kflag = 0 with unsigned value provides backward compatability.

With this patch, for
  enum T { VAL = 0xffffFFFF00000008 };
the generated BTF looks like
        .long   16                              # BTF_KIND_ENUM64(id = 4)
        .long   3187671053                      # 0x13000001
        .long   8
        .long   18
        .long   8                               # 0x8
        .long   4294967295                      # 0xffffffff
and the enumerator value and signedness are encoded correctly.

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

2 years ago[gn build] Port 352c395fb685
LLVM GN Syncbot [Mon, 6 Jun 2022 18:25:14 +0000 (18:25 +0000)]
[gn build] Port 352c395fb685

2 years ago[ObjectYAML][DX] Add dxcontainer2yaml support
Chris Bieneman [Tue, 3 May 2022 18:17:15 +0000 (13:17 -0500)]
[ObjectYAML][DX] Add dxcontainer2yaml support

This change finishes fleshing out the ObjectYAML tools to support
converting DXContainer files into yaml representations.

Depends on D124944

Reviewed By: lhames

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

2 years ago[GISel] Add new combines for G_ADD
Michael Kitzan [Wed, 18 May 2022 21:41:48 +0000 (14:41 -0700)]
[GISel] Add new combines for G_ADD

Patch adds new GICombineRules for G_ADD:

G_ADD(x, G_SUB(y, x)) -> y
G_ADD(G_SUB(y, x), x) -> y

Patch additionally adds new combine tests for AArch64 target for
these new rules.

Reviewed by: paquette

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

2 years ago[mlir][linalg] fix crash when promoting rank-reducing memref.subviews
Christopher Bate [Mon, 6 Jun 2022 04:54:11 +0000 (22:54 -0600)]
[mlir][linalg] fix crash when promoting rank-reducing memref.subviews

This change adds support for promoting `linalg` operation operands that
are produced by rank-reducing `memref.subview` ops.

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

2 years ago[libc++][NFC] Move span tests under views.span
Louis Dionne [Mon, 6 Jun 2022 18:02:41 +0000 (14:02 -0400)]
[libc++][NFC] Move span tests under views.span

2 years ago[libc++][NFC] Fix outdated comment in span test
Louis Dionne [Mon, 6 Jun 2022 18:02:05 +0000 (14:02 -0400)]
[libc++][NFC] Fix outdated comment in span test

2 years ago[libc] Fix cmake compatibility issue with list(POP_FRONT).
Tue Ly [Mon, 6 Jun 2022 17:30:13 +0000 (13:30 -0400)]
[libc] Fix cmake compatibility issue with list(POP_FRONT).

list(POP_FRONT) is only added to cmake in 3.15, while our base line
version is 3.13

Reviewed By: sivachandra

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

2 years ago[RISCV] Reorganize getShuffleCost to make it more clear what's going on [nfc]
Philip Reames [Mon, 6 Jun 2022 17:11:23 +0000 (10:11 -0700)]
[RISCV] Reorganize getShuffleCost to make it more clear what's going on [nfc]

2 years ago[SLP][NFC] Precommit test for followup patch that fixes vector phi poison input.
Vasileios Porpodas [Fri, 3 Jun 2022 02:01:57 +0000 (19:01 -0700)]
[SLP][NFC] Precommit test for followup patch that fixes vector phi poison input.

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

2 years ago[SelectionDAG] Further improve computeKnownBits for (smax X, C) where C is non-negative.
Craig Topper [Mon, 6 Jun 2022 16:45:52 +0000 (09:45 -0700)]
[SelectionDAG] Further improve computeKnownBits for (smax X, C) where C is non-negative.

Move the code that was added for D126896 after the normal recursive calls
to computeKnownBits. This allows us to calculate trailing zeros.
Previously we would break out of the switch before the recursive calls.

2 years ago[libc++][NFC] Add missing includes
Louis Dionne [Mon, 6 Jun 2022 16:57:42 +0000 (12:57 -0400)]
[libc++][NFC] Add missing includes

2 years ago[libc++] Avoid creating temporaries in unary expressions involving valarray
Louis Dionne [Thu, 5 May 2022 16:24:43 +0000 (12:24 -0400)]
[libc++] Avoid creating temporaries in unary expressions involving valarray

Currently, unary expressions involving valarray will create a temporary.
This leads to dangling references in expressions like `-a * b`, because
`-a` is a temporary and the resulting expression will refer to it. This
patch fixes the problem by creating a lazy expression to perform the unary
operation instead of eagerly creating a temporary valarray. This is
permitted by the Standard, which does not specify the exact type of
most expressions involving valarrays.

This is technically an ABI break, however I believe the actual potential
for breakage is very low.

rdar://90152242

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

2 years agoSupport converting pointers from opaque to typed
Chris Bieneman [Tue, 24 May 2022 16:56:12 +0000 (11:56 -0500)]
Support converting pointers from opaque to typed

Using the pointer type analysis we can re-constitute typed pointers and
populate the correct types in the bitcasts throughout the IR.

This doesn't yet handle all cases, but this should be illustrative as
to the dirction and feasability of
the solution.

Reviewed By: pete

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

2 years agoFix overflow bug impacting 32-bit testing
Chris Bieneman [Mon, 6 Jun 2022 16:16:16 +0000 (11:16 -0500)]
Fix overflow bug impacting 32-bit testing

This test was failing on 32-bit arm builders due to an interger
overflow. This changes the math to avoid overflow and should resolve
the test failure.

2 years ago[AMDGPU][GFX9+] Support base+soffset+offset s_atc_probe's.
Ivan Kosarev [Mon, 6 Jun 2022 15:46:22 +0000 (16:46 +0100)]
[AMDGPU][GFX9+] Support base+soffset+offset s_atc_probe's.

Resolves part of
https://github.com/llvm/llvm-project/issues/38652

Reviewed By: dp

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

2 years ago[InstCombine] add/move tests for opposite direction shifts; NFC
Sanjay Patel [Mon, 6 Jun 2022 15:13:17 +0000 (11:13 -0400)]
[InstCombine] add/move tests for opposite direction shifts; NFC

2 years ago[AMDGPU][GFX9][GFX10] Support base+soffset+offset s_dcache_discard's.
Ivan Kosarev [Mon, 6 Jun 2022 15:32:16 +0000 (16:32 +0100)]
[AMDGPU][GFX9][GFX10] Support base+soffset+offset s_dcache_discard's.

Resolves part of
https://github.com/llvm/llvm-project/issues/38652

Reviewed By: dp

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

2 years ago[AMDGPU][GFX8][DOC][NFC] Update assembler syntax description
Dmitry Preobrazhensky [Mon, 6 Jun 2022 13:08:16 +0000 (16:08 +0300)]
[AMDGPU][GFX8][DOC][NFC] Update assembler syntax description

Summary of changes:
- Updated MUBUF lds syntax (see https://reviews.llvm.org/D124485).
- Enabled literals with src0 for v_madak*, v_madmk* (see https://reviews.llvm.org/D111067).
- Minor bug fixing.

2 years agoDon't warn when 'llvm' isn't found
Alex Brachet [Mon, 6 Jun 2022 14:29:14 +0000 (14:29 +0000)]
Don't warn when 'llvm' isn't found

2 years ago[AMDGPU] gfx11 VOP1+VOP2 Instruction MC support
Joe Nash [Mon, 23 May 2022 14:26:02 +0000 (10:26 -0400)]
[AMDGPU] gfx11 VOP1+VOP2 Instruction MC support

Includes dpp instructions and vop1/vop2 promoted to vop3

Patch 17/N for upstreaming of AMDGPU gfx11 architecture

Depends on D126483

Reviewed By: rampitec, #amdgpu

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

2 years ago[AMDGPU] gfx11 vop3dpp instructions
Joe Nash [Wed, 18 May 2022 19:01:20 +0000 (15:01 -0400)]
[AMDGPU] gfx11 vop3dpp instructions

gfx11 adds the ability to use dpp modifiers on vop3 instructions.
This patch adds machine code layer support for that. The MCCodeEmitter
is changed to use APInt instead of uint64_t to support these wider
instructions.

Patch 16/N for upstreaming of AMDGPU gfx11 architecture

Depends on D126475

Reviewed By: rampitec, #amdgpu

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

2 years ago[libc++] Remove a bunch of conditionals on _LIBCPP_DEBUG_LEVEL
Louis Dionne [Fri, 3 Jun 2022 19:17:03 +0000 (15:17 -0400)]
[libc++] Remove a bunch of conditionals on _LIBCPP_DEBUG_LEVEL

Instead of providing two different constructors for iterators that
support the debug mode, provide a single constructor but leave the
container parameter unused when the debug mode is not enabled.

This allows simplifying all the call sites to unconditionally pass
the container, which removes a bunch of duplication in the container's
implementation.

Note that this patch does add some complexity to std::span, however
that is only because std::span has the ability to use raw pointers
as iterators instead of __wrap_iter. In retrospect, I believe it was
a mistake to provide that capability, and so it will be removed in a
future patch, along with the complexity added by this patch.

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

2 years ago[IPSCCP] Switch away from Instruction::isSafeToRemove()
Kevin P. Neal [Fri, 3 Jun 2022 18:28:02 +0000 (14:28 -0400)]
[IPSCCP] Switch away from Instruction::isSafeToRemove()

In D115737 I found that I needed to teach Instruction::isSafeToRemove()
about strictfp/constrained intrinsics. It was pointed out that this is
probably the wrong function to use isInstructionTriviallyDead(). It doesn't
make sense to have a "second, worse implementation".

I also believe that the Instruction class is the wrong place for this
functionality. The information about whether or not an instruction can be
removed is in the transform passes and should stay there.

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

2 years ago[flang][driver] Remove references to the `flang` bash script
Andrzej Warzynski [Mon, 6 Jun 2022 10:03:21 +0000 (10:03 +0000)]
[flang][driver] Remove references to the `flang` bash script

This is a follow-up of https://reviews.llvm.org/D125832
(see also https://reviews.llvm.org/D125788 for more context). It simply
removes any remaining references to the `flang` bash script. Note that
that `flang-to-external-fc` remains intact.

This felt worthwhile mentioning in the release notes, which have not
been updated since LLVM 12 (we are approaching LLVM 15 now). I took the
liberty of removing all of the out-dated content and added a note about
the renaming.

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

2 years ago[AMDGPU][GFX7][DOC][NFC] Update assembler syntax description
Dmitry Preobrazhensky [Mon, 6 Jun 2022 12:50:10 +0000 (15:50 +0300)]
[AMDGPU][GFX7][DOC][NFC] Update assembler syntax description

Summary of changes:
- Updated MUBUF lds syntax (see https://reviews.llvm.org/D124485).
- Enabled literals with src0 of v_madak_f32, v_madmk_f32 (see https://reviews.llvm.org/D111067).
- Corrected LGKM_CNT description.
- Minor bug fixing.

2 years agoFix a -Wlogical-op-parentheses warning; NFC
Aaron Ballman [Mon, 6 Jun 2022 11:51:24 +0000 (07:51 -0400)]
Fix a -Wlogical-op-parentheses warning; NFC

This should address bot failures like:
https://lab.llvm.org/buildbot/#/builders/77/builds/18317

2 years ago[gn build] Port 8171586176ee
LLVM GN Syncbot [Mon, 6 Jun 2022 11:33:45 +0000 (11:33 +0000)]
[gn build] Port 8171586176ee

2 years ago[libc++][ranges] Implement ranges::binary_search and ranges::{lower, upper}_bound
Nikolas Klauser [Sun, 5 Jun 2022 19:15:16 +0000 (21:15 +0200)]
[libc++][ranges] Implement ranges::binary_search and ranges::{lower, upper}_bound

Reviewed By: Mordante, var-const, ldionne, #libc

Spies: sstefan1, libcxx-commits, mgorny

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

2 years agoAllow use of an elaborated type specifier in a _Generic association in C++
Aaron Ballman [Mon, 6 Jun 2022 11:17:35 +0000 (07:17 -0400)]
Allow use of an elaborated type specifier in a _Generic association in C++

Currently, Clang accepts this code in C mode (where the tag is required
to be used) but rejects it in C++ mode thinking that the association is
defining a new type.

void foo(void) {
  struct S { int a; };
  _Generic(something, struct S : 1);
}
Clang thinks this in C++ because it sees struct S : when parsing the
class specifier and decides that must be a type definition (because the
colon signifies the presence of a base class type). This patch adds a
new declarator context to represent a _Generic association so that we
can distinguish these situations properly.

Fixes #55562

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

2 years ago[AArch64] Generate ADDP from shuffled add
David Green [Mon, 6 Jun 2022 10:39:51 +0000 (11:39 +0100)]
[AArch64] Generate ADDP from shuffled add

This adds a fold of add(x, shuffle(x, <1,0,3,2,5,4,...>), into
shuffle(addp(x), <0,0,1,1,2,2,..>. The ADDP instruction takes two
vectors and returns one, adding adjacent pairs. So we match x in a
custom combine as it is lowered from a v8i32. The original code
would be 2 rev64 and 2 add, with the new code being a single addp
with a zip1;zip2 shuffle, producing smaller code.

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

2 years agoFix "not all control paths return a value" MSVC warning. NFC.
Simon Pilgrim [Mon, 6 Jun 2022 10:31:46 +0000 (11:31 +0100)]
Fix "not all control paths return a value" MSVC warning. NFC.

2 years ago[gn build] port f06abbb39380 a bit (create main() functions for GENERATE_DRIVER targets)
Nico Weber [Mon, 6 Jun 2022 10:18:13 +0000 (06:18 -0400)]
[gn build] port f06abbb39380 a bit (create main() functions for GENERATE_DRIVER targets)

2 years ago[gn build] set LLVM_TOOL_LLVM_DRIVER_BUILD to 0 for now
Nico Weber [Mon, 6 Jun 2022 09:52:37 +0000 (05:52 -0400)]
[gn build] set LLVM_TOOL_LLVM_DRIVER_BUILD to 0 for now

2 years ago[flang][OpenMP] Added parser support for in_reduction clause
Nimish Mishra [Mon, 6 Jun 2022 14:47:32 +0000 (20:17 +0530)]
[flang][OpenMP] Added parser support for in_reduction clause

OpenMP 5.0 adds a new clause `in_reduction` on OpenMP directives.
This patch adds parser support for the same.

Reviewed By: kiranchandramohan

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

2 years ago[PowerPC] Support huge frame size for PPC64
Kai Luo [Mon, 6 Jun 2022 09:08:02 +0000 (09:08 +0000)]
[PowerPC] Support huge frame size for PPC64

Support allocation of huge stack frame(>2g) on PPC64.

For ELFv2 ABI on Linux, quoted from the spec 2.2.3.1 General Stack Frame Requirements
> There is no maximum stack frame size defined.

On AIX, XL allows such huge frame.

Reviewed By: #powerpc, nemanjai

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

2 years ago[VPlan] Replace BranchOnCount with BranchOnCond if TC <= UF * VF.
Florian Hahn [Mon, 6 Jun 2022 08:38:53 +0000 (09:38 +0100)]
[VPlan] Replace BranchOnCount with BranchOnCond if TC <= UF * VF.

Try to simplify BranchOnCount to `BranchOnCond true` if TC <= UF * VF.

This is an alternative to D121899 which simplifies the VPlan directly
instead of doing so late in code-gen.

The potential benefit of doing this in VPlan is that this may help
cost-modeling in the future. The reason this is done in prepareToExecute
at the moment is that a single plan may be used for multiple VFs/UFs.

There are further simplifications that can be applied as follow ups:

1. Replace inductions with constants
2. Replace vector region with regular block.

Fixes #55354.

Depends on D126679.

Reviewed By: Ayal

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

2 years agoRevert "[libcxx] Temporarily skip Arm configs"
David Spickett [Mon, 6 Jun 2022 08:25:51 +0000 (08:25 +0000)]
Revert "[libcxx] Temporarily skip Arm configs"

This reverts commit d4220af52723e76973723d3089c6fe2527fd704d.

Linaro bots are back online.

2 years ago[RISCV] Use check-prefixes to reduce check lines
Shao-Ce SUN [Fri, 3 Jun 2022 17:27:15 +0000 (01:27 +0800)]
[RISCV] Use check-prefixes to reduce check lines

Reviewed By: frasercrmck

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

2 years ago[NFC][RISCV][format] Blank line between functions, remove unnecessary semicolon.
yanming [Mon, 6 Jun 2022 07:32:12 +0000 (15:32 +0800)]
[NFC][RISCV][format] Blank line between functions, remove unnecessary semicolon.

2 years ago[Scalar] Use llvm::make_early_inc_range (NFC)
Kazu Hirata [Mon, 6 Jun 2022 06:53:18 +0000 (23:53 -0700)]
[Scalar] Use llvm::make_early_inc_range (NFC)

2 years ago[RISCV] Define risc-v's own register class to model FP Register.
yanming [Thu, 2 Jun 2022 04:52:50 +0000 (12:52 +0800)]
[RISCV] Define risc-v's own register class to model FP Register.

The default RegisterClass is not enough to model RISCV Register.
We define risc-v's own register class to model FP Register.
This helps to better estimate the register pressure in the loop-vectorize.

Reviewed By: kito-cheng

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

2 years ago[AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl
Qingyuan Zheng [Mon, 6 Jun 2022 05:58:00 +0000 (01:58 -0400)]
[AST] Fix clang RecursiveASTVisitor for definition of XXXTemplateSpecializationDecl

Fixes https://github.com/clangd/clangd/issues/1132
where clangd's semantic highlighting is missing for symbols of a template
specialization definition. It turns out the visitor didn't traverse the
base classes of Class/Var##TemplateSpecializationDecl, i.e.
CXXRecordDecl/VarDecl. This patch adds them back as what is done in
DEF_TRAVERSE_TMPL_PART_SPEC_DECL.

Reviewed By: rsmith

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

2 years ago[PDB] Remove truncate* (NFC)
Kazu Hirata [Mon, 6 Jun 2022 06:33:50 +0000 (23:33 -0700)]
[PDB] Remove truncate* (NFC)

- truncateQuotedNameFront: The last use was removed on Jul 10, 2017 in
  commit a9d944fd6fd19ac377b5ebea9272676642b7ceaa.

- truncateQuotedNameBack: The last use was removed on Mar 26, 2018 in
  commit 7b84b678a993c8a8236868f65d1d4c2b3e29fb3d.

- truncateStringMiddle: The last use was removed on Mar 26, 2018 in
  commit 7b84b678a993c8a8236868f65d1d4c2b3e29fb3d.

- truncateStringBack: The last use is in truncateQuotedNameBack being
  removed above.

- truncateStringFront: The last use is in truncateQuotedNameFront
  being removed above.

2 years ago[NFC] [Coroutines] Add test for ambiguous allocation functions in
Chuanqi Xu [Mon, 6 Jun 2022 06:11:59 +0000 (14:11 +0800)]
[NFC] [Coroutines] Add test for ambiguous allocation functions in
promise_type

Address the post-commit comment in
https://reviews.llvm.org/D125517#inline-1217244

2 years agoLLVM Driver Multicall tool
Chris Bieneman [Mon, 6 Jun 2022 04:25:55 +0000 (04:25 +0000)]
LLVM Driver Multicall tool

This patch adds an llvm-driver multicall tool that can combine multiple
LLVM-based tools. The build infrastructure is enabled for a tool by
adding the GENERATE_DRIVER option to the add_llvm_executable CMake
call, and changing the tool's main function to a canonicalized
tool_name_main format (i.e. llvm_ar_main, clang_main, etc...).

As currently implemented llvm-driver contains dsymutil, llvm-ar,
llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the
build).

llvm-driver can be enabled from builds by setting
LLVM_TOOL_LLVM_DRIVER_BUILD=On.

There are several limitations in the current implementation, which can
be addressed in subsequent patches:

(1) the multicall binary cannot currently properly handle
multi-dispatch tools. This means symlinking llvm-ranlib to llvm-driver
will not properly result in llvm-ar's main being called.
(2) the multicall binary cannot be comprised of tools containing
conflicting cl::opt options as the global cl::opt option list cannot
contain duplicates.

These limitations can be addressed in subsequent patches.

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

2 years ago[BPF] Enable IAS in backend
Brad Smith [Mon, 6 Jun 2022 03:28:53 +0000 (23:28 -0400)]
[BPF] Enable IAS in backend

Reviewed By: MaskRay

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

2 years ago[CodeGen] Remove splitCanCauseEvictionChain and its helpers (NFC)
Kazu Hirata [Mon, 6 Jun 2022 03:22:47 +0000 (20:22 -0700)]
[CodeGen] Remove splitCanCauseEvictionChain and its helpers (NFC)

The last use was removed on Mar 7, 2022 in commit
294eca35a00f89dff474044ebd478a7f83ccc310.

2 years ago[mlir][NFC] Replace some llvm::find with llvm::is_contained.
jacquesguan [Mon, 6 Jun 2022 02:31:12 +0000 (02:31 +0000)]
[mlir][NFC] Replace some llvm::find with llvm::is_contained.

This patch replaces some llvm::find with llvm::is_contained, it should be more clear.

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

2 years ago[GlobalISel] Remove widenWithUnmerge (NFC)
Kazu Hirata [Mon, 6 Jun 2022 02:58:18 +0000 (19:58 -0700)]
[GlobalISel] Remove widenWithUnmerge (NFC)

The last use was removed on Dec 23, 2021 in commit
29f88b93fdbe3e20c35842ca3a6c2a3f1a81cfce.

2 years ago[GlobalISel] Remove valueIsSplit (NFC)
Kazu Hirata [Mon, 6 Jun 2022 02:51:02 +0000 (19:51 -0700)]
[GlobalISel] Remove valueIsSplit (NFC)

The last use was removed on Jun 27, 2019 in commit
8138996128cd17d78d9d3e6ef7b49987565cb310.

2 years ago[LegalizeTypes][VP] Add widen and split support for vp.fptrunc and vp.fpext
Lian Wang [Thu, 26 May 2022 02:50:42 +0000 (02:50 +0000)]
[LegalizeTypes][VP] Add widen and split support for vp.fptrunc and vp.fpext

Reviewed By: frasercrmck

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

2 years ago[InstCombine] Add more tests for shl+lshr transforms; NFC
chenglin.bi [Mon, 6 Jun 2022 02:15:48 +0000 (10:15 +0800)]
[InstCombine] Add more tests for shl+lshr transforms; NFC

2 years ago[InstCombine] Fix tests const value for shl+lshr transforms; NFC
chenglin.bi [Mon, 6 Jun 2022 02:08:56 +0000 (10:08 +0800)]
[InstCombine] Fix tests const value for shl+lshr transforms; NFC

2 years ago[InstCombine] Add more tests for shl+lshr transforms; NFC
chenglin.bi [Mon, 6 Jun 2022 01:59:41 +0000 (09:59 +0800)]
[InstCombine] Add more tests for shl+lshr transforms; NFC

2 years ago[Clang][FP16] Add 4 builtins for _Float16
Phoebe Wang [Mon, 6 Jun 2022 00:31:44 +0000 (08:31 +0800)]
[Clang][FP16] Add 4 builtins for _Float16

We are lacking builtins support for `_Float16`. In most cases, we can use other floating-type builtins and truncate them to `_Float16`.
But it's a problem to SNaN, e.g., https://gcc.godbolt.org/z/cqr5nG1jh
This patch adds `__builtin_nansf16` support as well as other 3 ones since they are usually used together.

Reviewed By: LuoYuanke

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

2 years ago[clang] Use llvm::is_contained (NFC)
Kazu Hirata [Mon, 6 Jun 2022 00:56:40 +0000 (17:56 -0700)]
[clang] Use llvm::is_contained (NFC)

2 years ago[InstCombine] fold mul with masked low bit operand to trunc+select
Sanjay Patel [Sun, 5 Jun 2022 21:55:09 +0000 (17:55 -0400)]
[InstCombine] fold mul with masked low bit operand to trunc+select

https://alive2.llvm.org/ce/z/o7rQ5q

This shows an extra instruction in some cases, but that is
caused by an existing canonicalization of trunc -> and+icmp.

Codegen should be better for any target where a multiply is
more costly than the most simple ALU op.

This ends up producing the requested x86 asm from issue #55618,
but it's not the same IR. We are missing a canonicalization
from the negate+mask pattern to the trunc+select created here.

2 years ago[ConstProp] add tests for APFloat truncate miscompile; NFC
Sanjay Patel [Fri, 3 Jun 2022 19:47:14 +0000 (15:47 -0400)]
[ConstProp] add tests for APFloat truncate miscompile; NFC

issue #55838

2 years ago[Driver][test] Remove unneeded -no-canonical-prefixes and -o %t.o
Fangrui Song [Sun, 5 Jun 2022 23:06:09 +0000 (16:06 -0700)]
[Driver][test] Remove unneeded -no-canonical-prefixes and -o %t.o

Similar to 980679981fbc311bc07f8cd23e3739fd56c22d2a

2 years ago[clang-format] Handle attributes for for/while loops
owenca [Sat, 4 Jun 2022 19:26:07 +0000 (12:26 -0700)]
[clang-format] Handle attributes for for/while loops

Fixes #55853.

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

2 years ago[MC] Change EndOfStatement "unexpected tokens in .xxx directive " to "expected newline"
Fangrui Song [Sun, 5 Jun 2022 22:11:01 +0000 (15:11 -0700)]
[MC] Change EndOfStatement "unexpected tokens in .xxx directive " to "expected newline"

2 years ago[ARM][MC] Change EndOfStatement "unexpected tokens in .xxx directive " to "expected...
Fangrui Song [Sun, 5 Jun 2022 21:53:59 +0000 (14:53 -0700)]
[ARM][MC] Change EndOfStatement "unexpected tokens in .xxx directive " to "expected newline"

The directive name is not useful because the next line replicates the error line
which includes the directive. The prevailing style uses "expected newline".

2 years ago[NFC] Make comment consistent with allow|ignore list renamings
Aditya Kumar [Sun, 5 Jun 2022 21:48:00 +0000 (14:48 -0700)]
[NFC] Make comment consistent with allow|ignore list renamings

Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D123640

2 years ago[AArch64][MC] Change "unexpected tokens in .xxx directive " to "expected newline"
Fangrui Song [Sun, 5 Jun 2022 21:32:31 +0000 (14:32 -0700)]
[AArch64][MC] Change "unexpected tokens in .xxx directive " to "expected newline"

The directive name is not useful because the next line replicates the error line
which includes the directive. The prevailing style uses "expected newline".

2 years agogn build: Fix build when not building the native target.
Peter Collingbourne [Sun, 5 Jun 2022 06:42:00 +0000 (23:42 -0700)]
gn build: Fix build when not building the native target.

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

2 years ago[bolt] Remove unneeded cl::ZeroOrMore for cl::opt options
Fangrui Song [Sun, 5 Jun 2022 20:29:49 +0000 (13:29 -0700)]
[bolt] Remove unneeded cl::ZeroOrMore for cl::opt options

2 years ago[libc++][test] Mark ranges.transform.pass.cpp UNSUPPORTED for AIX
Joe Loser [Sat, 4 Jun 2022 16:28:17 +0000 (10:28 -0600)]
[libc++][test] Mark ranges.transform.pass.cpp UNSUPPORTED for AIX

The `ranges.transform.pass.cpp` often times out on CI for AIX (32-bit and 64-bit)
only. Mark the test as `UNSUPPORTED` for `AIX` for now. It should be looked into in
the future.

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

2 years ago[mlir] Tunnel LLVM_USE_LINKER through to the standalone example build.
Stella Laurenzo [Sun, 5 Jun 2022 19:30:28 +0000 (12:30 -0700)]
[mlir] Tunnel LLVM_USE_LINKER through to the standalone example build.

When building in debug mode, the link time of the standalone sample is excessive, taking upwards of a minute if using BFD. This at least allows lld to be used if the main invocation was configured that way. On my machine, this gets a standalone test that requires a relink to run in ~13s for Debug mode. This is still a lot, but better than it was. I think we may want to do something about this test: it adds a lot of latency to a normal compile/test cycle and requires a bunch of arg fiddling to exclude.

I think we may end up wanting a `check-mlir-heavy` target that can be used just prior to submit, and then make `check-mlir` just run unit/lite tests. More just thoughts for the future (none of that is done here).

Reviewed By: bondhugula, mehdi_amini

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

2 years ago[llvm] Convert for_each to range-based for loops (NFC)
Kazu Hirata [Sun, 5 Jun 2022 19:07:14 +0000 (12:07 -0700)]
[llvm] Convert for_each to range-based for loops (NFC)

2 years ago[Sparc] Fix a warning
Kazu Hirata [Sun, 5 Jun 2022 18:49:13 +0000 (11:49 -0700)]
[Sparc] Fix a warning

This patch fixes:

  llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp:910:5: error:
  default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

2 years ago[NFC] Add test cases reported in PR54341
Matheus Izvekov [Sun, 5 Jun 2022 17:00:57 +0000 (19:00 +0200)]
[NFC] Add test cases reported in PR54341

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D127074

2 years ago[Debuginfo][DWARF][NFC] Refactor DwarfStringPoolEntryRef - remove isIndexed().
Alexey Lapshin [Fri, 3 Jun 2022 11:11:43 +0000 (14:11 +0300)]
[Debuginfo][DWARF][NFC] Refactor DwarfStringPoolEntryRef - remove isIndexed().

This patch is extraction from the https://reviews.llvm.org/D126883.
It removes DwarfStringPoolEntryRef::isIndexed() and isIndexed bit
since they are not used.

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

2 years ago[SPARC][MC] Support more relocation types
LemonBoy [Sun, 5 Jun 2022 18:06:50 +0000 (14:06 -0400)]
[SPARC][MC] Support more relocation types

This patch introduces support for %hix, %lox, %gdop_hix22, %gdop_lox10 and %gdop.

An extra test is introduced to make sure the fixups are correctly applied.

Reviewed By: dcederman

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

2 years ago[flang][runtime] Use __float128 where possible & needed in runtime
Peter Klausler [Tue, 31 May 2022 21:06:11 +0000 (14:06 -0700)]
[flang][runtime] Use __float128 where possible & needed in runtime

On targets with __float128 available and distinct from long double,
use it to support more kind=16 entry points.  This affects mostly
x86-64 targets.  This means that more runtime entry points are
defined for lowering to call.

Delete Common/long-double.h and its LONG_DOUBLE macro in favor of
testing the standard macro LDBL_MANT_DIG.

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

2 years ago[Scalar] Remove isValidSingle (NFC)
Kazu Hirata [Sun, 5 Jun 2022 15:45:11 +0000 (08:45 -0700)]
[Scalar] Remove isValidSingle (NFC)

The last use was removed on Feb 18, 2022 in commit
00ab91b70d21f72af59e4e198c6dc819452405af.