platform/upstream/llvm.git
23 months agoRevert "XFAIL some PGO tests on AIX until the new linker becomes publicly available."
Wael Yehia [Mon, 8 Aug 2022 14:04:29 +0000 (14:04 +0000)]
Revert "XFAIL some PGO tests on AIX until the new linker becomes publicly available."

AIX 7.2 TL5 SP4 and AIX 7.3 TL0 SP2 have been released as of now.
The linker in these OS versions recognizes and properly supports
__start_SECNAME and __stop_SECNAME symbols which are needed for PGO.

This reverts commit 93bb2f16e85d2d4c8d3ddadebd99fc0fe26d974b.

23 months ago[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL
Tobias Hieta [Mon, 8 Aug 2022 13:53:15 +0000 (15:53 +0200)]
[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL

These are new debug types that ships with the latest
Windows SDK and would warn and finally fail lld-link.

The symbols seems to be related to Microsoft's XFG
which is their version of CFG. We can't handle any of
this yet, so for now we can just ignore these types
so that lld doesn't fail with a new version of Windows
SDK.

Fixes: #56285

Reviewed By: rnk

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

23 months ago[MLIR][Presburger] make sample test with integer lexmin use containsPointNoLocal
Arjun P [Mon, 8 Aug 2022 13:42:53 +0000 (14:42 +0100)]
[MLIR][Presburger] make sample test with integer lexmin use containsPointNoLocal

IntegerPolyhedron::findIntegerLexmin currently does not return values of
the local ids, so when a test for sampling includes a set with locals, the
result of findIntegerLexmin should be checked using containsPointNoLocal,
not containsPoint.

23 months ago[libc++][doc] Update `SpaceshipProjects` status to reflect in-flight reviews
Adrian Vogelsgesang [Mon, 8 Aug 2022 13:36:20 +0000 (06:36 -0700)]
[libc++][doc] Update `SpaceshipProjects` status to reflect in-flight reviews

23 months ago[X86] X86ISelDAGToDAG.cpp - use auto for all values derived from cast/dyn_cast (style...
Simon Pilgrim [Mon, 8 Aug 2022 13:34:54 +0000 (14:34 +0100)]
[X86] X86ISelDAGToDAG.cpp - use auto for all values derived from cast/dyn_cast (style). NFC.

23 months ago[libc++][NFC] Fix signature of main in test
Louis Dionne [Mon, 8 Aug 2022 13:30:21 +0000 (09:30 -0400)]
[libc++][NFC] Fix signature of main in test

23 months ago[EarlyCSE][ConstantFolding] add tests for atan/atan2; NFC
Mohammed Nurul Hoque [Mon, 8 Aug 2022 13:21:33 +0000 (09:21 -0400)]
[EarlyCSE][ConstantFolding] add tests for atan/atan2; NFC

Baseline coverage for D127964.

23 months ago[EarlyCSE][OpaquePointers]Replace assert with return for mask type check.
Denis Antrushin [Fri, 5 Aug 2022 09:48:28 +0000 (16:48 +0700)]
[EarlyCSE][OpaquePointers]Replace assert with return for mask type check.

When EarlyCSE tries to common vector masked loads/stores, it first checks that
they have same base operand and then assumes that this is enough for mask types
to be equal. This is true for typed pointers but false for opaque ones -
two loads of different vector sizes from same base pointer '%b' are the same,
`ptr %b`. (For typed pointers, `%b` was cast to vector pointer type so bases
were different).
Change assert to return from lambda `isSubmask` so this transformation properly
works with opaque pointers.

Reviewed By: nikic

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

23 months ago[CMake] Check CMAKE_CXX_STANDARD and error if it's to old
Tobias Hieta [Sun, 7 Aug 2022 19:52:37 +0000 (21:52 +0200)]
[CMake] Check CMAKE_CXX_STANDARD and error if it's to old

Also nuke the old value out of the cache if it's there, otherwise
it could lead to problems when the project increases the standard
and the developer just runs the "make/ninja" program.

Reviewed By: royjacobson

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

23 months ago[libc++] Add missing <stdbool.h> to the modulemap
Louis Dionne [Thu, 4 Aug 2022 20:57:27 +0000 (16:57 -0400)]
[libc++] Add missing <stdbool.h> to the modulemap

It used to be defined by the compiler, but libc++ now provides it.

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

23 months ago[libc++] Allow enabling assertions when back-deploying
Louis Dionne [Thu, 4 Aug 2022 19:25:48 +0000 (15:25 -0400)]
[libc++] Allow enabling assertions when back-deploying

When back-deploying to older platforms, we can still provide assertions,
but we might not be able to provide a great implementation for the verbose
handler. Instead, we can just call ::abort().

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

23 months ago[clang-tidy] Fix a regression of readability-container-size-empty after the AST Elabo...
Haojian Wu [Mon, 8 Aug 2022 11:21:06 +0000 (13:21 +0200)]
[clang-tidy] Fix a regression of readability-container-size-empty after the AST ElaboratedType change.

With 15f3cd6bfc670ba6106184a903eb04be059e5977, we no longer emit a
diagnostic on a real std::vector case where the size method returns a
sugar `size_type`. This patch fixes it.

```
std::vector<int> v;
if (v.size() == 0) // => no check diagnostics
  ;
```

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

23 months ago[X86] Add 32-bit test coverage to or-lea.ll
Simon Pilgrim [Mon, 8 Aug 2022 12:30:55 +0000 (13:30 +0100)]
[X86] Add 32-bit test coverage to or-lea.ll

Noticed while triaging D131358

23 months ago[ASTMatchers] Replace hand-coded copy of std::apply with the real C++17 function...
Benjamin Kramer [Mon, 8 Aug 2022 12:08:04 +0000 (14:08 +0200)]
[ASTMatchers] Replace hand-coded copy of std::apply with the real C++17 function. NFCI

23 months ago[Support] Use std::shared_mutex when we're not on old MacOS
Benjamin Kramer [Mon, 8 Aug 2022 11:17:24 +0000 (13:17 +0200)]
[Support] Use std::shared_mutex when we're not on old MacOS

In C++17 mode this is always available.

23 months ago[lld/mac] Use C++17 structured bindings
Nico Weber [Sun, 7 Aug 2022 14:49:26 +0000 (10:49 -0400)]
[lld/mac] Use C++17 structured bindings

No behavior change.

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

23 months ago[mlir] Remove redundant `inline` from D131323
Markus Böck [Mon, 8 Aug 2022 11:17:50 +0000 (13:17 +0200)]
[mlir] Remove redundant `inline` from D131323

23 months agoWrap `llvm_unreachable` macro in do-while loop
Stefan Gränitz [Thu, 4 Aug 2022 11:58:26 +0000 (13:58 +0200)]
Wrap `llvm_unreachable` macro in do-while loop

Macros that expand into multiple terms can cause interesting preprocessor hickups depending
on the context they are used in. https://github.com/llvm/llvm-project/issues/56867 reported
a miscompilation of `llvm_unreachable(msg)` inside a `LLVM_DEBUG({ ... })` block. We were
able to fix it by wrapping the expansion in a `do {} while(false)`.

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

23 months agoRemove superfluous ; outside of a function
Simon Pilgrim [Mon, 8 Aug 2022 11:13:19 +0000 (12:13 +0100)]
Remove superfluous ; outside of a function

23 months ago[lld/mac] Use C++17 nested namespace syntax in most places
Nico Weber [Sun, 7 Aug 2022 14:37:49 +0000 (10:37 -0400)]
[lld/mac] Use C++17 nested namespace syntax in most places

Some header files used

    namespace lld {
    namespace macho {
    // ...
    } // namespace macho
    std::string toString(const Type &t);
    } // namespace lld

In those files, I didn't use a nested namespace since it's not a big win there.

No behavior change.

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

23 months ago[DAG] Emit table lookup from TargetLowering::expandCTTZ()
Shubham Narlawar [Mon, 8 Aug 2022 11:08:05 +0000 (12:08 +0100)]
[DAG] Emit table lookup from TargetLowering::expandCTTZ()

This patch emits table lookup in expandCTTZ.

Context -
https://reviews.llvm.org/D113291 transforms set of IR instructions to
cttz intrinsic but there are some targets which does not support CTTZ or
CTLZ. Hence, I generate a table lookup in TargetLowering::expandCTTZ().

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

23 months agoRemove C++17 #ifdefs around the implicit conversion between StringRef and string_view
Benjamin Kramer [Mon, 8 Aug 2022 10:54:50 +0000 (12:54 +0200)]
Remove C++17 #ifdefs around the implicit conversion between StringRef and string_view

This is no longer needed as LLVM is built with C++17 now. Also drop the
explicit conversion to std::string as the implicit conversion to
std::string_view gets picked first anyways.

23 months ago[DAG] FoldConstantArithmetic - add initial support for undef elements in bitcasted...
Simon Pilgrim [Mon, 8 Aug 2022 10:53:56 +0000 (11:53 +0100)]
[DAG] FoldConstantArithmetic - add initial support for undef elements in bitcasted binop constant folding

FoldConstantArithmetic can fold constant vectors hidden behind bitcasts (e.g. vXi64 -> v2Xi32 on 32-bit platforms), but currently bails if either vector contains undef elements. These undefs can often occur due to SimplifyDemandedBits/VectorElts calls recognising that the upper bits are often unnecessary (e.g. funnel-shift/rotate implicit-modulo and AND masks).

This patch adds a basic 'FoldValueWithUndef' handler that will attempt to constant fold if one or both of the ops are undef - so far this just handles the AND and MUL cases where we always fold to zero.

The RISCV codegen increase is interesting - it looks like the BUILD_VECTOR lowering was loading a constant pool entry but now (with all elements defined constant) it can materialize the constant instead?

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

23 months agoProcessTest.cpp - replace Optional::hasValue() with Optional::has_value()
Simon Pilgrim [Mon, 8 Aug 2022 10:52:22 +0000 (11:52 +0100)]
ProcessTest.cpp - replace Optional::hasValue() with Optional::has_value()

Fixes windows-only build warnings

23 months ago[llvm-objdump,ARM] Fix big-endian AArch32 disassembly.
Simon Tatham [Mon, 1 Aug 2022 12:40:32 +0000 (13:40 +0100)]
[llvm-objdump,ARM] Fix big-endian AArch32 disassembly.

The ABI for big-endian AArch32, as specified by AAELF32, is above-
averagely complicated. Relocatable object files are expected to store
instruction encodings in byte order matching the ELF file's endianness
(so, big-endian for a BE ELF file). But executable images can
//either// do that //or// store instructions little-endian regardless
of data and ELF endianness (to support BE32 and BE8 platforms
respectively). They signal the latter by setting the EF_ARM_BE8 flag
in the ELF header.

(In the case of the Thumb instruction set, this all means that each
16-bit halfword of a Thumb instruction is stored in one or other
endianness. The two halfwords of a 32-bit Thumb instruction must
appear in the same order no matter what, because the first halfword is
the one that must avoid overlapping the encoding of any 16-bit Thumb
instruction.)

llvm-objdump was unconditionally expecting Arm instructions to be
stored little-endian. So it would correctly disassemble a BE8 image,
but if you gave it a BE32 image or a BE object file, it would retrieve
every instruction in byte-swapped form and disassemble it to
nonsense. (Even an object file output by LLVM itself, because
ARMMCCodeEmitter outputs instructions big-endian in big-endian mode,
which is correct for writing an object file.)

This patch allows llvm-objdump to correctly disassemble all three of
those classes of Arm ELF file. It does it by introducing a new
SubtargetFeature for big-endian instructions, setting it from the ELF
image type and flags during llvm-objdump setup, and teaching both
ARMDisassembler and llvm-objdump itself to pay attention to it when
retrieving instruction data from a section being disassembled.

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

23 months ago[Orc][JITLink] Slab based memory allocator to reduce RPC calls
Anubhab Ghosh [Fri, 22 Jul 2022 19:14:03 +0000 (00:44 +0530)]
[Orc][JITLink] Slab based memory allocator to reduce RPC calls

Calling reserve() used to require an RPC call. This commit allows large
ranges of executor address space to be reserved. Subsequent calls to
reserve() will return subranges of already reserved address space while
there is still space available.

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

23 months ago[ADT] Update Optional Deprecation with fix-it
Nathan James [Mon, 8 Aug 2022 09:39:29 +0000 (10:39 +0100)]
[ADT] Update Optional Deprecation with fix-it

When Optional accessors were deprecated, in D131349,  the standard c++14 style attribute was used.
Clang has a slightly better deprecated attribute that enables simpler migration by embedding fix-its.

Reviewed By: kazu

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

23 months ago[DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine
David Green [Mon, 8 Aug 2022 08:47:55 +0000 (09:47 +0100)]
[DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine

D129150 added a combine from shuffles to And that creates a BUILD_VECTOR
of constant elements. We need to ensure that the elements are of a legal
type, to prevent asserts during lowering.

Fixes #56970.

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

23 months ago[AArch64][SVE] Add patterns to select masked FP arith
Cullen Rhodes [Mon, 8 Aug 2022 08:20:36 +0000 (08:20 +0000)]
[AArch64][SVE] Add patterns to select masked FP arith

Add patterns to select predicated instructions when lowering:

  fadd(a, select(mask, b, splat(0)))
  fsub(a, select(mask, b, splat(0)))

'fadd' is unsafe unless no-signed zeros fast-math flag is set, since

  -0.0 + 0.0 = 0.0

changes the sign. Alive2: https://alive2.llvm.org/ce/z/wbhJh_

Also adds FMA patterns for:

  fadd(a, select(mask, mul(b, c), splat(0))) -> fmla(a, mask, b, c)
  fsub(a, select(mask, mul(b, c), splat(0))) -> fmla(a, mask, b, c)

These patterns require the 'contract' fast-math flag to be set, and the
fadd 'nsz' as above.

Reviewed By: paulwalker-arm

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

23 months ago[AArch64][SVE] NFC: Add tests for masked FP arith patterns (D130564)
Cullen Rhodes [Tue, 26 Jul 2022 09:56:25 +0000 (09:56 +0000)]
[AArch64][SVE] NFC: Add tests for masked FP arith patterns (D130564)

23 months ago[mailmap] Add entry for myself
WANG Xuerui [Mon, 8 Aug 2022 08:28:46 +0000 (16:28 +0800)]
[mailmap] Add entry for myself

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

23 months ago[scudo] Try to fix standalone build on armv7
Diana Picus [Fri, 5 Aug 2022 08:54:32 +0000 (10:54 +0200)]
[scudo] Try to fix standalone build on armv7

When linking scudo standalone on armv7, it can't find symbols related to
unwinding (e.g. __aeabi_unwind_cpp_pr0). This is because it is passing
--unwindlib=none. This patch hacks around the issue by adding
COMPILER_RT_UNWINDER_LINK_LIBS to the link line.

I don't know anything about scudo, so I'm not sure what the original
intention was.

See also https://github.com/llvm/llvm-project/issues/56900

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

23 months ago[CodeView] Add function to get size in bytes for TypeIndex/CVType.
Carlos Alberto Enciso [Mon, 8 Aug 2022 07:48:23 +0000 (08:48 +0100)]
[CodeView] Add function to get size in bytes for TypeIndex/CVType.

Given a TypeIndex or CVType return its size in bytes. Basically it
is the inverse to 'CodeViewDebug::lowerTypeBasic', that returns a
TypeIndex based in a size.

Reviewed By: rnk, djtodoro

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

23 months ago[NFC][clang] Bring `and_present` and `if_present` casting functions to clang namespace
Nathan James [Mon, 8 Aug 2022 07:38:50 +0000 (08:38 +0100)]
[NFC][clang] Bring `and_present` and `if_present` casting functions to clang namespace

This should enable simpler migration when the `and_nonnull` and `or_null` functions are deprecated.

23 months ago[llvm] Qualify auto (NFC)
Kazu Hirata [Mon, 8 Aug 2022 06:55:27 +0000 (23:55 -0700)]
[llvm] Qualify auto (NFC)

Identified with readability-qualified-auto.

23 months ago[clang-tidy] Use is_contained (NFC)
Kazu Hirata [Mon, 8 Aug 2022 06:55:25 +0000 (23:55 -0700)]
[clang-tidy] Use is_contained (NFC)

23 months ago[Transforms] Fix comment typos (NFC)
Kazu Hirata [Mon, 8 Aug 2022 06:55:23 +0000 (23:55 -0700)]
[Transforms] Fix comment typos (NFC)

23 months ago[BOLT] Upgrade to C++17
Kazu Hirata [Mon, 8 Aug 2022 06:12:16 +0000 (23:12 -0700)]
[BOLT] Upgrade to C++17

Without this patch, I am getting errors like:

  llvm-project/llvm/include/llvm/ADT/StringRef.h:233:7: error: use of
  the 'nodiscard' attribute is a C++17 extension
  [-Werror,-Wc++17-extensions]

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

23 months ago[LoongArch] Support for varargs
wanglei [Mon, 8 Aug 2022 04:04:14 +0000 (12:04 +0800)]
[LoongArch] Support for varargs

This patch ensures the `$fp` always points to the bottom of the vararg
spill region.
Includes support for expand `ISD::DYNAMIC_STACKALLOC`.

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

23 months ago[llvm-ar] Remove unused parameter. NFC
Fangrui Song [Mon, 8 Aug 2022 04:31:35 +0000 (21:31 -0700)]
[llvm-ar] Remove unused parameter. NFC

23 months ago[M68k] Add MC support for link/unlk
Sheng [Mon, 8 Aug 2022 01:56:04 +0000 (09:56 +0800)]
[M68k] Add MC support for link/unlk

Reviewers: myhsu

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

23 months ago[gn build] (manually) port ace6e172bd2c
Nico Weber [Mon, 8 Aug 2022 02:02:51 +0000 (22:02 -0400)]
[gn build] (manually) port ace6e172bd2c

23 months ago[RISCV] Support fe_getround and fe_raise_inexact in builtins
luxufan [Mon, 8 Aug 2022 01:57:43 +0000 (09:57 +0800)]
[RISCV] Support fe_getround and fe_raise_inexact in builtins

Reviewed By: luismarques

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

23 months ago[Support] move llvm::llvm_is_multithread to header, NFC
Jun Zhang [Mon, 8 Aug 2022 00:46:20 +0000 (08:46 +0800)]
[Support] move llvm::llvm_is_multithread to header, NFC

This allow optimization without LTO. Also remove some useless else-ifs.
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D131313

23 months ago[flang] Handle subnormals while folding SCALE, SET_EXPONENT, & FRACTION
Peter Klausler [Tue, 26 Jul 2022 16:39:34 +0000 (09:39 -0700)]
[flang] Handle subnormals while folding SCALE, SET_EXPONENT, & FRACTION

The implementations of folding for the intrinsic functions SCALE and SET_EXPONENT
do not cope correctly with numbers in the subnormal range.  Fix SCALE,
then modify SET_EXPONENT to be a special case of SCALE.

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

23 months ago[mlir] fix `add_tablegen()` macro to allow installing mlir-pdll
Ashay Rane [Fri, 5 Aug 2022 19:16:51 +0000 (12:16 -0700)]
[mlir] fix `add_tablegen()` macro to allow installing mlir-pdll

Prior to this patch, the `add_tablegen()` macro in
llvm/cmake/modules/TableGen.cmake added the install rule only if
`project` matched `LLVM` or `MLIR`.  This patch adds an optional
`DESTINATION` argument, which, if non-empty, decides whether (and where)
to install the tablegen tool, thus eliminating the need for
project-specific overrides.  This patch also updates all other
invocations of the `add_tablegen()` macro.

Reviewed By: nikic

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

23 months ago[mlir][python] Address deprecation warning for hasValue
Jacques Pienaar [Sun, 7 Aug 2022 22:28:18 +0000 (15:28 -0700)]
[mlir][python] Address deprecation warning for hasValue

23 months ago[flang] Allow assignment to host association in BLOCK in PURE subprogram
Peter Klausler [Tue, 26 Jul 2022 01:03:40 +0000 (18:03 -0700)]
[flang] Allow assignment to host association in BLOCK in PURE subprogram

We need to distinguish BLOCK host association from subprogram host
association when checking assignments in PURE subprograms.
The specific case that is not allowed is an assignment to a variable
from the scope around the PURE subprogram.

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

23 months ago[ORC-RT] Fix missing #include <string_view>s.
Lang Hames [Sun, 7 Aug 2022 21:15:08 +0000 (14:15 -0700)]
[ORC-RT] Fix missing #include <string_view>s.

1dcff823db9 updated the ORC runtime to use std::string_view, rather than its
own placeholder class (__orc_rt::string_view), but failed to add these
includes.

23 months ago[lldb] Use single-argument static_assert where applicable (NFC)
Jonas Devlieghere [Sun, 7 Aug 2022 21:26:04 +0000 (14:26 -0700)]
[lldb] Use single-argument static_assert where applicable (NFC)

Since C++17 the message string for static_assert is optional. Replaces
static asserts with an empty string literal with the single-argument
variant.

23 months ago[InstSimplify] fold scalable vectors with over-shift splat constant to poison
Sanjay Patel [Sun, 7 Aug 2022 20:24:15 +0000 (16:24 -0400)]
[InstSimplify] fold scalable vectors with over-shift splat constant to poison

Fixes #56968

23 months ago[InstSimplify] add test for over-shift of scalable vector; NFC
Sanjay Patel [Sun, 7 Aug 2022 19:05:16 +0000 (15:05 -0400)]
[InstSimplify] add test for over-shift of scalable vector; NFC

23 months ago[flang][runtime] Catch & report attempts at recursive I/O
Peter Klausler [Tue, 26 Jul 2022 00:27:15 +0000 (17:27 -0700)]
[flang][runtime] Catch & report attempts at recursive I/O

When an I/O statement contains a function call that attempts
to perform I/O on the same unit, detect the recursive I/O
and terminate with a useful message rather than deadlocking in
the threading library.

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

23 months agoRevert "[JITLink] Fix some C++17 related fixmes."
Lang Hames [Sun, 7 Aug 2022 18:45:06 +0000 (11:45 -0700)]
Revert "[JITLink] Fix some C++17 related fixmes."

This reverts commit 6ea5bf436a983ea9e16a5fe7534c87beca0a61b7.

6ea5bf436a983ea9e16a5fe7534c87beca0a61b7 made use of new c++17 rules regarding
order of evaluation (specifically: in function calls the expression naming the
function should be sequenced before the evalution of any operands) to simplify
some continuation-passing calls. Unfortunately this appears to break at least
one MSVC bot: https://lab.llvm.org/buildbot/#/builders/123/builds/12149 .

Includes an update to the comments to note that the workaround is now based on
MSVC limitations, not on LLVM adopting c++17.

23 months ago[mlir] Use value instead of getValue
Kazu Hirata [Sun, 7 Aug 2022 18:59:37 +0000 (11:59 -0700)]
[mlir] Use value instead of getValue

23 months ago[ADT] Deprecate Optional::{hasValue,getValue} (NFC)
Kazu Hirata [Sun, 7 Aug 2022 18:30:58 +0000 (11:30 -0700)]
[ADT] Deprecate Optional::{hasValue,getValue} (NFC)

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

23 months ago[ORC-RT] Remove a stray __orc_rt::string_view helper.
Lang Hames [Sun, 7 Aug 2022 18:22:15 +0000 (11:22 -0700)]
[ORC-RT] Remove a stray __orc_rt::string_view helper.

This function was accidentally left in after 1dcff823db9.

23 months ago[lldb] Hoist TraceOn check out of loop (NFC)
Dave Lee [Wed, 25 May 2022 00:22:12 +0000 (17:22 -0700)]
[lldb] Hoist TraceOn check out of loop (NFC)

23 months ago[lldb] Fix formatting in python-reference.rst
Dave Lee [Sun, 24 Jul 2022 23:31:53 +0000 (17:31 -0600)]
[lldb] Fix formatting in python-reference.rst

23 months ago[lldb] Dynamically generate enum names in lldbutil
Dave Lee [Thu, 4 Aug 2022 02:45:47 +0000 (20:45 -0600)]
[lldb] Dynamically generate enum names in lldbutil

Change the `<enum>_to_str` functions in lldbutil to be dynamic.

Instead of a manually maintained if/elif switch, the functions now perform
lookup in a dynamically generated dict. The names are determined by stripping
the enum's prefix, and then lowercasing the remaining suffix, ex:

    eStateRunning -> "running"

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

23 months ago[libc++][NFC] Fix `the the` in comment in `__format/buffer.h`
Adrian Vogelsgesang [Sun, 7 Aug 2022 18:02:28 +0000 (11:02 -0700)]
[libc++][NFC] Fix `the the` in comment in `__format/buffer.h`

I made this commit primarily to test my commit access to the LLVM repo

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

23 months ago[mlir] Fix a warning
Kazu Hirata [Sun, 7 Aug 2022 18:13:19 +0000 (11:13 -0700)]
[mlir] Fix a warning

This patch fixes:

  llvm-project/mlir/include/mlir/IR/OpDefinition.h:1544:19: error: use
  of bitwise '|' with boolean operands
  [-Werror,-Wbitwise-instead-of-logical]

23 months ago[ConstFolding] fix overzealous assert when converting FP half
Sanjay Patel [Sun, 7 Aug 2022 17:33:44 +0000 (13:33 -0400)]
[ConstFolding] fix overzealous assert when converting FP half

Fixes #56981

23 months ago[InstCombine] add tests for bitwise logic; NFC
Sanjay Patel [Sat, 6 Aug 2022 18:22:12 +0000 (14:22 -0400)]
[InstCombine] add tests for bitwise logic; NFC

23 months ago[JITLink] Fix some C++17 related fixmes.
Lang Hames [Sun, 7 Aug 2022 15:58:08 +0000 (08:58 -0700)]
[JITLink] Fix some C++17 related fixmes.

23 months ago[ORC-RT] Drop __orc_rt::string_view now that we have c++17.
Lang Hames [Sun, 7 Aug 2022 04:58:56 +0000 (21:58 -0700)]
[ORC-RT] Drop __orc_rt::string_view now that we have c++17.

b1356504e63 enabled the use of c++17 features in LLVM, which means that we can
drop the ORC runtime's placeholder string_view implemention in favor of
std::string_view.

23 months ago[clang][CodeGen] Factor out Swift ABI hooks (NFCI)
Sergei Barannikov [Sun, 7 Aug 2022 16:21:40 +0000 (00:21 +0800)]
[clang][CodeGen] Factor out Swift ABI hooks (NFCI)

Swift calling conventions stands out in the way that they are lowered in
mostly target-independent manner, with very few customization points.
As such, swift-related methods of ABIInfo do not reference the rest of
ABIInfo and vice versa.
This change follows interface segregation principle; it removes
dependency of SwiftABIInfo on ABIInfo. Targets must now implement
SwiftABIInfo separately if they support Swift calling conventions.

Almost all targets implemented `shouldPassIndirectly` the same way. This
de-facto default implementation has been moved into the base class.

`isSwiftErrorInRegister` used to be virtual, now it is not. It didn't
accept any arguments which could have an effect on the returned value.
This is now a static property of the target ABI.

Reviewed By: rusyaev-roman, inclyc

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

23 months ago[X86] Add test case to recombine LEA from OR.
Amaury Séchet [Sun, 7 Aug 2022 15:55:14 +0000 (15:55 +0000)]
[X86] Add test case to recombine LEA from OR.

23 months ago[flang] Allow pure function references in expandable scalar
Peter Klausler [Wed, 3 Aug 2022 17:25:43 +0000 (10:25 -0700)]
[flang] Allow pure function references in expandable scalar

F18 disallows function references and coarray references from
appearing in scalar expressions that are to be expanded into
arrays to conform with other operands or actual arguments in
an elemental expression.  This is too strong, as pure procedures
can be safely used.

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

23 months ago[mlir] Flip to prefixed accessors (NFC)
Jacques Pienaar [Sun, 7 Aug 2022 15:46:15 +0000 (08:46 -0700)]
[mlir] Flip to prefixed accessors (NFC)

Missed these in td files.

23 months ago[polly] Fixed a number of typos. NFC
Gabriel Ravier [Sun, 7 Aug 2022 14:53:09 +0000 (22:53 +0800)]
[polly] Fixed a number of typos. NFC

I went over the output of the following mess of a command:

`(ulimit -m 2000000; ulimit -v 2000000; git ls-files -z | parallel --xargs -0 cat | aspell list --mode=none --ignore-case | grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n | grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less)`

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

Reviewed By: inclyc

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

23 months ago[clang-tidy] Fix a forwarding-reference-overload crash after the
Haojian Wu [Sat, 6 Aug 2022 21:34:02 +0000 (23:34 +0200)]
[clang-tidy] Fix a forwarding-reference-overload crash after the
ElaboratedType change.

After 15f3cd6bfc670ba6106184a903eb04be059e5977, the nss of
ElaboratedType can be null.

23 months agoRevert "[RDF] Remove explicit template arguments from Print"
Aaron Ballman [Sun, 7 Aug 2022 12:24:01 +0000 (08:24 -0400)]
Revert "[RDF] Remove explicit template arguments from Print"

This reverts commit ede96de751224487aea122af8bfb4e82bc54840b.

This breaks the build on Windows with Visual Studio:
https://lab.llvm.org/buildbot/#/builders/123/builds/12134

23 months ago[Polly] Suppress the LLVM-IR output for pattern matching tests, if there is no FileCh...
Roman Gareev [Sun, 7 Aug 2022 11:48:54 +0000 (14:48 +0300)]
[Polly] Suppress the LLVM-IR output for pattern matching tests, if there is no FileCheck-ing for it.

23 months ago[mlir] Flip to prefixed accessors (NFC)
Jacques Pienaar [Sun, 7 Aug 2022 11:55:58 +0000 (04:55 -0700)]
[mlir] Flip to prefixed accessors (NFC)

23 months ago[ARM] Regenerate vector_store.ll tests. NFC
David Green [Sun, 7 Aug 2022 11:46:28 +0000 (12:46 +0100)]
[ARM] Regenerate vector_store.ll tests. NFC

23 months ago[Polly] Generalize the pattern matching to the case of tensor contractions
Roman Gareev [Sat, 21 May 2022 19:40:33 +0000 (22:40 +0300)]
[Polly] Generalize the pattern matching to the case of tensor contractions

The pattern matching optimization of Polly detects and optimizes dense general
matrix-matrix multiplication. The generated code is close to high performance
implementations of matrix-matrix multiplications, which are contained in
manually tuned libraries. The described pattern matching optimization is
a particular case of tensor contraction optimization, which was
introduced in [1].

This patch generalizes the pattern matching to the case of tensor contractions
using the form of data dependencies and memory accesses produced by tensor
contractions [1].

Optimization of tensor contractions will be added in the next patch. Following
the ideas introduced in [2], it will logically represent tensor contraction
operands as matrix multiplication operands and use an approach for
optimization of matrix-matrix multiplications.

[1] - Gareev R., Grosser T., Kruse M. High-Performance Generalized Tensor
Op­erations: A Compiler-Oriented Approach // ACM Transactions on
Architec­ture and Code Optimization (TACO). 2018. Vol. 15, no. 3.
P. 34:1–34:27. DOI: 10.1145/3235029.

[2] - Matthews D. High-Performance Tensor Contraction without BLAS // SIAM
Journal on Scientific Computing. 2018. Vol. 40, no. 1. P. C 1—C 24.
DOI: 110.1137/16m108968x.

Reviewed By: Meinersbur

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

23 months ago[libc++][test] Fix MSVC warnings C6054, C6001, C4242 in format_tests.h
Igor Zhukov [Sat, 6 Aug 2022 16:01:04 +0000 (23:01 +0700)]
[libc++][test] Fix MSVC warnings C6054, C6001, C4242 in format_tests.h

Reviewed By: Mordante

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

23 months ago[mlir] Make use of C++17 language features
Markus Böck [Sun, 7 Aug 2022 09:16:38 +0000 (11:16 +0200)]
[mlir] Make use of C++17 language features

Now that C++17 is enabled in LLVM, a lot of the TODOs and patterns to emulate C++17 features can be eliminated.
The steps I have taken were essentially:
```
git grep C++17
git grep c++17
git grep "initializer_list<int>"
```
and address given comments and patterns.
Most of the changes boiled down to just using fold expressions rather than initializer_list.

While doing this I also discovered that Clang by default restricts the depth of fold expressions to 256 elements. I specifically hit this with `TestDialect` in `addOperations`. I opted to not replace it with fold expressions because of that but instead adding a comment documenting the issue.
If any other functions may be called with more than 256 elements in the future we might have to revert other parts as well.
I don't think this is a common occurence besides the `TestDialect` however. If need be, this could potentially be fixed via `mlir-tblgen` in the future.

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

23 months ago[demangler] Add getters for Qual/Vector/Pointer types
Alexey Bader [Mon, 1 Aug 2022 15:06:38 +0000 (08:06 -0700)]
[demangler] Add getters for Qual/Vector/Pointer types

These are useful for downstream tool aligning the mangling of data types which differ between different languages/targets.

Patch by Steffen Larsen <steffen.larsen@intel.com>

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

23 months agoAdded warning about outdated feature into Kaleidoscope tutorial text
Shivam Gupta [Sat, 6 Aug 2022 07:52:42 +0000 (13:22 +0530)]
Added warning about outdated feature into Kaleidoscope tutorial text

**Motivation: **  I have been studying LLVM with LLVM Kaleidoscope tutorial. In the 4th part I faced an error which said that I can't redefine a function as shown in the tutorial. After hours of searching, I finally found the reason that produced the error is that the feature of symbols redefinition has been disabled since LLVM-9. There was no information about that in the tutorial's text, so I've decided to add a warning.

**Changes**: The only file I fixed is "`llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst`", I added text warning which says that described feature is outdated and the described functionality will not work properly on LLVM versions older 8 one.

Patch by : DKay7

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

23 months ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:20 +0000 (00:16 -0700)]
[llvm] Use range-based for loops (NFC)

23 months ago[x86] Remove unused declaration processWaitCnt (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:19 +0000 (00:16 -0700)]
[x86] Remove unused declaration processWaitCnt (NFC)

The declaration was introduced without a corresponding definition on
Jan 2, 2022 in commit 85e6e748d426f8992016914b07bc67c4da22e278.

23 months agoUse llvm::is_contained (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:17 +0000 (00:16 -0700)]
Use llvm::is_contained (NFC)

23 months ago[Target] Remove unused forward declarations (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:16 +0000 (00:16 -0700)]
[Target] Remove unused forward declarations (NFC)

23 months ago[llvm] Fix comment typos (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:14 +0000 (00:16 -0700)]
[llvm] Fix comment typos (NFC)

23 months ago[mlir] Remove redundaunt return statements (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:13 +0000 (00:16 -0700)]
[mlir] Remove redundaunt return statements (NFC)

Identified with readability-redundant-control-flow.

23 months ago[llvm] Drop unnecessary const from return types (NFC)
Kazu Hirata [Sun, 7 Aug 2022 07:16:11 +0000 (00:16 -0700)]
[llvm] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

23 months ago[LLDB][NFC] Reliability fixes to TCPSocket code
Slava Gurevich [Fri, 5 Aug 2022 20:54:08 +0000 (13:54 -0700)]
[LLDB][NFC] Reliability fixes to TCPSocket code

Patch the following issues found by static code inspection:
- Unchecked return values from lib calls
- Passing potentially negative arg into a function that requires non-negative input
- Possible socket double-close

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

23 months ago[MLIR] Add MlirValue to PybindAdapters
John Demme [Sun, 7 Aug 2022 04:58:46 +0000 (21:58 -0700)]
[MLIR] Add MlirValue to PybindAdapters

Allows out-of-tree users to automatically cast to/from MlirValue.

23 months ago[clang][docs] use `Fixes` instead of `This fixes` in ReleaseNotes [NFC]
YingChi Long [Sun, 7 Aug 2022 04:42:15 +0000 (12:42 +0800)]
[clang][docs] use `Fixes` instead of `This fixes` in ReleaseNotes [NFC]

23 months ago[mlir][tosa] Flip to prefixed form.
Jacques Pienaar [Sun, 7 Aug 2022 02:24:40 +0000 (19:24 -0700)]
[mlir][tosa] Flip to prefixed form.

Flipped to _Both 2 weeks ago, flipping to _Prefixed now.

23 months ago[llvm] LLVM_NODISCARD => [[nodiscard]]. NFC
Fangrui Song [Sun, 7 Aug 2022 00:26:33 +0000 (00:26 +0000)]
[llvm] LLVM_NODISCARD => [[nodiscard]]. NFC

With C++17 there is no Clang pedantic warning.

23 months ago[lld] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
Fangrui Song [Sun, 7 Aug 2022 00:02:35 +0000 (00:02 +0000)]
[lld] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

With C++17 there is no Clang pedantic warning or MSVC C5051.

23 months agoRevert "[SampleProfileInference] Work around odr-use of const non-inline static data...
Fangrui Song [Sat, 6 Aug 2022 23:48:23 +0000 (16:48 -0700)]
Revert "[SampleProfileInference] Work around odr-use of const non-inline static data member to fix -O0 builds after D120508"

This reverts commit 48c74bb2e2a72830f1068823bfc2f6fd4b53d427.
With C++17 the workaround is no longer needed.

23 months agoRevert "[lld-macho] Work around odr-use of const non-inline static data member to...
Fangrui Song [Sat, 6 Aug 2022 23:44:14 +0000 (16:44 -0700)]
Revert "[lld-macho] Work around odr-use of const non-inline static data member to fix -O0 build after D128298"

This reverts commit 20b2d3260d4a1878ca2a37cee6ee335a21a12d0f.
The workaround is no longer needed for C++17.

23 months ago[clang-tidy] Fix g++ -DCMAKE_CXX_STANDARD=17 build
Fangrui Song [Sat, 6 Aug 2022 23:12:18 +0000 (23:12 +0000)]
[clang-tidy] Fix g++ -DCMAKE_CXX_STANDARD=17 build

`constexpr std::initializer_list<llvm::StringRef>` leads to
```
error: modification of '<temporary>' is not a constant expression
```
Related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102921

23 months ago[ADT] Fix signature of StringSet::insert
Fangrui Song [Sat, 6 Aug 2022 22:48:41 +0000 (22:48 +0000)]
[ADT] Fix signature of StringSet::insert

to match StringMap and unordered_set.

23 months ago[Clang][OpenMP] Fix the issue that `llvm.lifetime.end` is emitted too early for varia...
Shilei Tian [Sat, 6 Aug 2022 20:50:30 +0000 (16:50 -0400)]
[Clang][OpenMP] Fix the issue that `llvm.lifetime.end` is emitted too early for variables captured in linear clause

Currently if an OpenMP program uses `linear` clause, and is compiled with
optimization, `llvm.lifetime.end` for variables listed in `linear` clause are
emitted too early such that there could still be uses after that. Let's take the
following code as example:
```
// loop.c
int j;
int *u;

void loop(int n) {
  int i;
  for (i = 0; i < n; ++i) {
    ++j;
    u = &j;
  }
}
```
We compile using the command:
```
clang -cc1 -fopenmp-simd -O3 -x c -triple x86_64-apple-darwin10 -emit-llvm loop.c -o loop.ll
```
The following IR (simplified) will be generated:
```
@j = local_unnamed_addr global i32 0, align 4
@u = local_unnamed_addr global ptr null, align 8

define void @loop(i32 noundef %n) local_unnamed_addr {
entry:
  %j = alloca i32, align 4
  %cmp = icmp sgt i32 %n, 0
  br i1 %cmp, label %simd.if.then, label %simd.if.end

simd.if.then:                                     ; preds = %entry
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %j)
  store ptr %j, ptr @u, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr @j, align 4
  br label %simd.if.end

simd.if.end:                                      ; preds = %simd.if.then, %entry
  ret void
}
```
The most important part is:
```
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr @j, align 4
```
`%j` is still loaded after `@llvm.lifetime.end.p0(i64 4, ptr nonnull %j)`. This
could cause the backend incorrectly optimizes the code and further generates
incorrect code. The root cause is, when we emit a construct that could have
`linear` clause, it usually has the following pattern:
```
EmitOMPLinearClauseInit(S)
{
  OMPPrivateScope LoopScope(*this);
  ...
  EmitOMPLinearClause(S, LoopScope);
  ...
  (void)LoopScope.Privatize();
  ...
}
EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; });
```
Variables that need to be privatized are added into `LoopScope`, which also
serves as a RAII object. When `LoopScope` is destructed and if optimization is
enabled, a `@llvm.lifetime.end` is also emitted for each privatized variable.
However, the writing back to original variables in `linear` clause happens after
the scope in `EmitOMPLinearClauseFinal`, causing the issue we see above.

A quick "fix" seems to be, moving `EmitOMPLinearClauseFinal` inside the scope.
However, it doesn't work. That's because the local variable map has been updated
by `LoopScope` such that a variable declaration is mapped to the privatized
variable, instead of the actual one. In that way, the following code will be
generated:
```
  %0 = load i32, ptr %j, align 4
  store i32 %0, ptr %j, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %j)
```
Well, now the life time is correct, but apparently the writing back is broken.

In this patch, a new function `OMPPrivateScope::restoreMap` is added and called
before calling `EmitOMPLinearClauseFinal`. This can make sure that
`EmitOMPLinearClauseFinal` can find the orignal varaibls to write back.

Fixes #56913.

Reviewed By: ABataev

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

23 months agolld/cmake: Drop use of llvm-config for LLVM install discovery
Tom Stellard [Sat, 6 Aug 2022 13:22:19 +0000 (09:22 -0400)]
lld/cmake: Drop use of llvm-config for LLVM install discovery

This has been deprecated since D116492 earlier in 2022.

That seems recent, but with the recent cut of LLVM 15 that is still two releases (14 and 15). Meanwhile Clang has deprecated `llvm-config` for a lot longer, and since it is likely that LLD users are also Clang users, this serves as an extra "heads up" that `llvm-config` is on its way out.

Remove it in favor of using CMake's find_package() function.

Reviewed By: MaskRay, mgorny

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