platform/upstream/llvm.git
23 months agoPartially revert "[llvm] Repair the modules build with C++17"
Jonas Devlieghere [Mon, 8 Aug 2022 22:24:26 +0000 (15:24 -0700)]
Partially revert "[llvm] Repair the modules build with C++17"

This reverts commit db008af501534d4590542253ae3acf783986f5f7 because
this now breaks the non-module build...

23 months agoImplement better path matching in FileSpecList::FindCompatibleIndex(...).
Greg Clayton [Fri, 22 Jul 2022 22:12:50 +0000 (15:12 -0700)]
Implement better path matching in FileSpecList::FindCompatibleIndex(...).

Currently a FileSpecList::FindFileIndex(...) will only match the specified FileSpec if:
- it has filename and directory and both match exactly
- if has a filename only and any filename in the list matches

Because of this, we modify our breakpoint resolving so it can handle relative paths by doing some extra code that removes the directory from the FileSpec when searching if the path is relative.

This patch is intended to fix breakpoints so they work as users expect them to by adding the following features:
- allow matches to relative paths in the file list to match as long as the relative path is at the end of the specified path at valid directory delimiters
- allow matches to paths to match if the specified path is relative and shorter than the file paths in the list

This allows us to remove the extra logic from BreakpointResolverFileLine.cpp that added support for setting breakpoints with relative paths.

This means we can still set breakpoints with relative paths when the debug info contains full paths. We add the ability to set breakpoints with full paths when the debug info contains relative paths.

Debug info contains "./a/b/c/main.cpp", the following will set breakpoints successfully:
- /build/a/b/c/main.cpp
- a/b/c/main.cpp
- b/c/main.cpp
- c/main.cpp
- main.cpp
- ./c/main.cpp
- ./a/b/c/main.cpp
- ./b/c/main.cpp
- ./main.cpp

This also ensures that we won't match partial directory names, if a relative path is in the list or is used for the match, things must match at the directory level.

The breakpoint resolving code will now use the new FileSpecList::FindCompatibleIndex(...) function to allow this fuzzy matching to work for breakpoints.

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

23 months ago[llvm] Repair the modules build with C++17
Jonas Devlieghere [Mon, 8 Aug 2022 21:38:09 +0000 (14:38 -0700)]
[llvm] Repair the modules build with C++17

I'm honestly not sure if this is a legitimate issue or not, but after
switching from C++14 to C++17, the modules build started confusing
arrays and initializer lists. Work around the issue by being explicit.

23 months ago[flang][test] Don't require .exe suffix.
Michael Kruse [Mon, 8 Aug 2022 16:32:04 +0000 (11:32 -0500)]
[flang][test] Don't require .exe suffix.

The suffix is only added then the path the (lld-)link.exe is fully
resolved. Otherwise it may stay "link" or "lld-link".

On non-Windows platforms, lld-link also exists as a symbolic link to
lld, such that the full the path to lld-link might also be resolved
without .exe suffix in this case.

Note that CLANG_DEFAULT_LINKER could be set to other linkers such as
mold, in which case the test may still fail. This also applies to the
non-Windows tests that require "ld" in the linker name.

Fixes issue #56955

23 months ago[RISCV] Add {{$}} to some CHECK lines in MC tests.
Craig Topper [Mon, 8 Aug 2022 20:38:05 +0000 (13:38 -0700)]
[RISCV] Add {{$}} to some CHECK lines in MC tests.

This adds {{$}} to most of the CHECK lines for errors about what
extension an instruction requires. This ensures we check all the
extensions when there is a list.

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

23 months ago[ELF] Support --package-metadata
Alex Brachet [Mon, 8 Aug 2022 21:31:58 +0000 (21:31 +0000)]
[ELF] Support --package-metadata

This was recently introduced in GNU linkers and it makes sense for
ld.lld to have the same support. This implementation omits checking if
the input string is valid json to reduce size bloat.

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

23 months ago[libunwind][AIX] Save/restore errno before/after system calls dlopen/dlsym/dlclose
Xing Xue [Mon, 8 Aug 2022 21:21:30 +0000 (17:21 -0400)]
[libunwind][AIX] Save/restore errno before/after system calls dlopen/dlsym/dlclose

Summary:
libunwind on AIX calls dlopen()/dlsym()/dlclose() to dynamically load libc++abi and get the personality for state table EH when it is running against the legacy xlcang++ compiler genereated applications. dlopen() sets errno to 0 when it is successful, which clobbers the value in errno from the user code. This seems to be an AIX bug that it should not set errno to 0 according to POSIX. We will open a bug report to AIX but in the mean time there won't be time line when AIX will have a fix and even AIX does fix it, it won't help earlier AIX releases in the field. This patch saves and restores errno before and after these calls so that user code can work as expected.

Reviewed by: compnerd, libunwind

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

23 months ago[mlir][vector] Fix warp distribution test
Thomas Raoux [Mon, 8 Aug 2022 20:57:10 +0000 (20:57 +0000)]
[mlir][vector] Fix warp distribution test

The test was using a missing prefix. Add the prefix and fix the naming.

Found by @csigg

Reviewed By: csigg

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

23 months ago[DAGCombiner] Add some BE store forwarding tests; NFC
Roland Froese [Mon, 8 Aug 2022 20:29:15 +0000 (16:29 -0400)]
[DAGCombiner] Add some BE store forwarding tests; NFC

Add tests before D130115. NFC.

23 months ago[mlir][sparse] improve sparse attribute documentation
Aart Bik [Mon, 8 Aug 2022 17:23:40 +0000 (10:23 -0700)]
[mlir][sparse] improve sparse attribute documentation

Moved some parts from comments (not user facing) to the actual description
(user facing). Rephrased a bit as well.

Reviewed By: Peiming

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

23 months ago[MC] [Win64EH] Fix the calculation of the end of epilogs
Martin Storsjö [Mon, 8 Aug 2022 09:34:29 +0000 (12:34 +0300)]
[MC] [Win64EH] Fix the calculation of the end of epilogs

Exclude the terminating end opcode from the epilog - it doesn't
correspond to an actual instruction that is included in the epilog
itself (within the .seh_startepilogue/.seh_endepilogue range).

In most (all?) cases, an epilog is followed by a matching terminating
instruction though (a ret or a branch to a tail call), but it's not
strictly within the .seh_startepilogue/.seh_endepilogue range.

This fixes a number of failed asserts in cases where the codegen
has incorrectly reoredered SEH opcodes so they don't match up
exactly with their instructions.

However this still just avoids failing the assertion; the root cause
of generating unexpected epilogs is still present (and fixing that is
a less obvious issue).

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

23 months agoAdd -misc-const-correctness to .clang-tidy
Arthur Eubanks [Mon, 8 Aug 2022 17:16:20 +0000 (10:16 -0700)]
Add -misc-const-correctness to .clang-tidy

I keep getting suggestions from clangd to add 'const' to a bunch of local variables, which is not LLVM's style. This suppresses those.

Reviewed By: kadircet, aaron.ballman

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

23 months ago[lldb] Prevent race condition when fetching /proc/cpuinfo
Walter Erquinigo [Wed, 3 Aug 2022 16:57:57 +0000 (09:57 -0700)]
[lldb] Prevent race condition when fetching /proc/cpuinfo

@clayborg found a potential race condition when setting a static
variable. The fix seems simply to use call_once.

All relevant tests pass.

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

23 months ago[clang][deps] Stop sharing FileManager across module builds in scanner
Ben Langmuir [Mon, 8 Aug 2022 16:52:35 +0000 (09:52 -0700)]
[clang][deps] Stop sharing FileManager across module builds in scanner

Sharing the FileManager across implicit module builds currently leaks
paths looked up in an importer into the built module itself. This can
cause non-deterministic results across scans. It is especially bad for
modules since the path can be saved into the pcm file itself, leading to
stateful behaviour if the cache is shared.

This should not impact the number of real filesystem accesses in the
scanner, since it is already caching in the
DependencyScanningWorkerFilesystem.

Note: this change does not affect whether or not the FileManager is
shared across TUs in the scanner, which is a separate issue.

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

23 months ago[LinkerWrapper] Use C++17 structured bindings
Joseph Huber [Mon, 8 Aug 2022 17:32:48 +0000 (13:32 -0400)]
[LinkerWrapper] Use C++17 structured bindings

Summary:
This patch updates the linker wrapper to use C++17 structured bindings
now that they are availible.

23 months ago[compiler-rt] Use -std=c++17 for standalone build
Fangrui Song [Mon, 8 Aug 2022 19:04:41 +0000 (12:04 -0700)]
[compiler-rt] Use -std=c++17 for standalone build

Follow-up to D130689.

Reviewed By: thieta

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

23 months ago[lldb] Remove include/lldb/lldb-private.h
Fangrui Song [Mon, 8 Aug 2022 19:03:53 +0000 (12:03 -0700)]
[lldb] Remove include/lldb/lldb-private.h

The header from 62e0681afb478a4005efb6ba3598c24dc24866ee does something with
LLVM_FALLTHROUGH. Now that llvm-project has switched to C++17 and
LLVM_FALLTHROUGH uses have been migrated to [[fallthrough]], the header is
unneeded.

Reviewed By: JDevlieghere

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

23 months ago[Symbolizer] Fix symbolizer-filter-markup-pc.test on Windows
Daniel Thornburgh [Mon, 8 Aug 2022 18:39:44 +0000 (11:39 -0700)]
[Symbolizer] Fix symbolizer-filter-markup-pc.test on Windows

23 months ago[libc] Website fixes (sidebar and mobile)
Jeff Bailey [Sat, 6 Aug 2022 05:30:08 +0000 (05:30 +0000)]
[libc] Website fixes (sidebar and mobile)

Add "using" and "status" sections to the sidebar to make getting these
easier.

Fixed mobile formatting not overflow left and right.

Tested:
Chrome on Desktop, using mobile restrictions in devtools.

Reviewed By: sivachandra

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

23 months ago[lldb] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
Fangrui Song [Mon, 8 Aug 2022 18:31:49 +0000 (11:31 -0700)]
[lldb] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

23 months ago[mlir][spirv] Unify mixed scalar/vector primitive type resources
Lei Zhang [Mon, 8 Aug 2022 18:23:22 +0000 (14:23 -0400)]
[mlir][spirv] Unify mixed scalar/vector primitive type resources

This further relaxes the requirement to allow aliased resources
to have different primitive types and some are scalars while the
other are vectors.

Reviewed By: ThomasRaoux

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

23 months ago[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
Fangrui Song [Mon, 8 Aug 2022 18:24:15 +0000 (11:24 -0700)]
[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

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

23 months ago[lld/mac] Remove unusual "Fallthrough" comments
Nico Weber [Mon, 8 Aug 2022 18:18:39 +0000 (14:18 -0400)]
[lld/mac] Remove unusual "Fallthrough" comments

Normally we'd use LLVM_FALLTHROUGH, or now, [[fallthrough]].
But for case labels followed directly by other case labels, we
use neither.

No behavior change.

23 months ago[gn build] port 59bb9e37c6
Nico Weber [Mon, 8 Aug 2022 18:16:21 +0000 (14:16 -0400)]
[gn build] port 59bb9e37c6

23 months ago[SimpleLoopUnswitch] Skip non-trivial unswitching of cold loops
Ruobing Han [Mon, 1 Aug 2022 17:22:45 +0000 (17:22 +0000)]
[SimpleLoopUnswitch] Skip non-trivial unswitching of cold loops

With profile data, non-trivial LoopUnswitch will only apply on non-cold loops, as unswitching cold loops may not gain much benefit but significantly increase the code size.

Reviewed By: aeubanks, asbirlea

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

23 months ago[X86][ARM] Add tests for bitwise logic trees of shifts; NFC
Filipp Zhinkin [Mon, 8 Aug 2022 17:54:49 +0000 (20:54 +0300)]
[X86][ARM] Add tests for bitwise logic trees of shifts; NFC

Baseline tests for D131189.

23 months ago[Symbolizer] Implement pc element in symbolizing filter.
Daniel Thornburgh [Mon, 1 Aug 2022 21:35:25 +0000 (14:35 -0700)]
[Symbolizer] Implement pc element in symbolizing filter.

Implements the pc element for the symbolizing filter, including it's
"ra" and "pc" modes. Return addresses ("ra") are adjusted by
decrementing one. By default, {{{pc}}} elements are assumed to point to
precise code ("pc") locations. Backtrace elements will adopt the
opposite convention.

Along the way, some minor refactors of value printing and colorization.

Reviewed By: peter.smith

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

23 months ago[SROA] Try harder to find a vector promotion viable type when rewriting
Vang Thao [Fri, 10 Jun 2022 19:06:15 +0000 (12:06 -0700)]
[SROA] Try harder to find a vector promotion viable type when rewriting

We are seeing significant performance loss when an alloca fails to get promoted
to register. I have observed that this is due to the common type found when
attempting to rewrite partition users being unviable for promotion. While if we
would have continue looking for a type, we would have found a subtype in the
original allocated type that would have enabled promotion. Thus first check if
the initial common type found is promotion viable and if not then continue
looking instead of stopping with the initial common type found.

Reviewed By: arsenm

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

23 months ago[lldb] Pass TestExternCSymbols.py on Windows
Alex Langford [Mon, 8 Aug 2022 18:01:13 +0000 (11:01 -0700)]
[lldb] Pass TestExternCSymbols.py on Windows

This test previously was expected to fail on windows. As of my previous
patch (1d2a62afaf7561e331e2f3daf3937d14225b21bf) this test now passes on
windows consistently. This patch adjusts the expectations of the test
accordingly.

23 months ago[flang] Replace more pgmath with libm.
Slava Zakharin [Thu, 4 Aug 2022 16:24:33 +0000 (09:24 -0700)]
[flang] Replace more pgmath with libm.

With this change all supported pgmath functions for non-complex
data types are replaced with either libm calls or MLIR operations,
except for MOD and some flavors of POW, which are going to be addressed
by other commits.

At the current stage a few math intrinsics are lowered into libm calls
always. When appropriate MLIR operation are available, the table can be
updated to generate them.

23 months ago[X86] Add test coverage for ctpop/parity with freeze
Simon Pilgrim [Mon, 8 Aug 2022 17:24:40 +0000 (18:24 +0100)]
[X86] Add test coverage for ctpop/parity with freeze

These are safe to fold from freeze(unaryop(x)) -> unaryop(freeze(x))

23 months ago[mlir][sparse] Add new concatente operator to sparse tensor
Peiming Liu [Wed, 3 Aug 2022 19:23:42 +0000 (19:23 +0000)]
[mlir][sparse] Add new concatente operator to sparse tensor

See https://www.tensorflow.org/xla/operation_semantics#concatenate for the operator semantics

Reviewed By: aartbik

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

23 months ago[llvm-ranlib] Support more than one input file
Fangrui Song [Mon, 8 Aug 2022 17:15:39 +0000 (10:15 -0700)]
[llvm-ranlib] Support more than one input file

BSD and GNU ranlib support more than one input file. Implement this.

While here, update OVERVIEW (Ranlib => ranlib) since "ranlib" is more common.
Remove "speed access" since the index has nothing to do with performance: it is
mandatory for GNU ld and gold but ignored for ld.lld (D119074).

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

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

23 months ago[mlir][math] Fix pythong bindings after 00f7096d31cc7896ffd490e65104d264923f0df5
Benjamin Kramer [Mon, 8 Aug 2022 17:14:44 +0000 (19:14 +0200)]
[mlir][math] Fix pythong bindings after 00f7096d31cc7896ffd490e65104d264923f0df5

23 months ago[libc++] Implement `operator==` for `filesystem::space_info`
Adrian Vogelsgesang [Sun, 31 Jul 2022 23:12:42 +0000 (16:12 -0700)]
[libc++] Implement `operator==` for `filesystem::space_info`

Implements part of P1614R2 "The Mothership has Landed"

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

23 months ago[mlir][doc] Cross link the dependent dialect section to the tablegen field definition
Mehdi Amini [Mon, 8 Aug 2022 16:57:33 +0000 (16:57 +0000)]
[mlir][doc] Cross link the dependent dialect section to the tablegen field definition

23 months ago[llvm-tblgen] Fix copy+paste typo in CodeGenSchedModels::collectLoadStoreQueueInfo
Simon Pilgrim [Mon, 8 Aug 2022 16:51:33 +0000 (17:51 +0100)]
[llvm-tblgen] Fix copy+paste typo in CodeGenSchedModels::collectLoadStoreQueueInfo

Confirmed with @andreadb - repeated PM.LoadQueue->getLoc() should have been PM.StoreQueue->getLoc()

Found by coverity

23 months ago[mlir][sparse][nfc] Use tensor.generate in sparse integration tests
Rajas Vanjape [Mon, 8 Aug 2022 15:23:36 +0000 (15:23 +0000)]
[mlir][sparse][nfc] Use tensor.generate in sparse integration tests

Currently, dense tensors are initialized in Sparse Integration tests using
"buffer.tensor_alloc and scf.for" . This makes code harder to read and maintain.
This diff uses tensor.generate instead to initialize dense tensors.

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

Reviewed By: springerm

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

23 months ago[flang] Add an explicit condition for the BITS=0 case in the MASKL and MASKR intrinsics.
Tarun Prabhu [Mon, 8 Aug 2022 14:56:29 +0000 (08:56 -0600)]
[flang] Add an explicit condition for the BITS=0 case in the MASKL and MASKR intrinsics.

This fixes issue #56706.

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

23 months ago[RISCV] Add ReadFStoreData as a SchedRead.
Craig Topper [Mon, 8 Aug 2022 16:06:28 +0000 (09:06 -0700)]
[RISCV] Add ReadFStoreData as a SchedRead.

The floating point stores use a different register class, it
probably makes sense to have a different SchedRead.

Reviewed By: monkchiang

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

23 months ago[DAG] canCreateUndefOrPoison - add freeze(bswap(x)) -> bswap(freeze(x)) and freeze...
Simon Pilgrim [Mon, 8 Aug 2022 16:27:05 +0000 (17:27 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(bswap(x)) -> bswap(freeze(x)) and freeze(bitreverse(x)) -> bitreverse(freeze(x)) support

Both are guaranteed not to create undef/poison

23 months ago[MLIR][Linalg] Remove `TiledLoops` from tiling options
lorenzo chelini [Mon, 8 Aug 2022 08:35:55 +0000 (10:35 +0200)]
[MLIR][Linalg] Remove `TiledLoops` from tiling options

TiledLoopOp has been removed in: https://github.com/llvm/llvm-project/commit/1a829d2d06958abf09bb6aff81120959206887f6

Reviewed By: ftynse

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

23 months ago[ADT] Retire llvm::apply_tuple in favor of C++17 std::apply
Benjamin Kramer [Mon, 8 Aug 2022 16:23:10 +0000 (18:23 +0200)]
[ADT] Retire llvm::apply_tuple in favor of C++17 std::apply

23 months ago[mlir][spirv] Refresh base definitions to latest spec (v1.6)
Lei Zhang [Mon, 8 Aug 2022 16:07:40 +0000 (12:07 -0400)]
[mlir][spirv] Refresh base definitions to latest spec (v1.6)

This commit updates all SPIR-V enum definitions to match the latest
specification (v1.6 revision 2). Along the way, fixed some issues
in `gen_spirv_dialect.py` and added a new script for refreshing
all op definitions for such cases.

Reviewed By: kuhar

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

23 months ago[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
Fangrui Song [Mon, 8 Aug 2022 16:12:46 +0000 (09:12 -0700)]
[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

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

Reviewed By: aaron.ballman

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

23 months agoRename OPENMP_HAVE_STD_CPP14_FLAG to match c++17
Jon Chesterfield [Mon, 8 Aug 2022 16:07:45 +0000 (17:07 +0100)]
Rename OPENMP_HAVE_STD_CPP14_FLAG to match c++17

23 months agoMove openmp from -std=c++14 to -std=c++17
Ron Lieberman [Mon, 8 Aug 2022 16:04:52 +0000 (16:04 +0000)]
Move openmp from -std=c++14 to -std=c++17

23 months ago[LLDB][NFC] Fix suspicious bitwise expression in PrintBTEntry()
Slava Gurevich [Sat, 6 Aug 2022 04:27:28 +0000 (21:27 -0700)]
[LLDB][NFC] Fix suspicious bitwise expression in PrintBTEntry()

Current application of bitwise-OR to a binary mask always results in True, which seems
inconsistent with the intent of the statement, a likely typo.

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

23 months ago[lld/win] Use C++17 structured bindings
Nico Weber [Mon, 8 Aug 2022 15:20:24 +0000 (11:20 -0400)]
[lld/win] Use C++17 structured bindings

No behavior change.

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

23 months ago[lld/win] Use C++17 nested namespace syntax in most places
Nico Weber [Mon, 8 Aug 2022 15:32:26 +0000 (11:32 -0400)]
[lld/win] Use C++17 nested namespace syntax in most places

Like D131354, but for COFF.

No behavior change.

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

23 months ago[DAG] canCreateUndefOrPoison - add freeze(sext(x)) -> sext(freeze(x)) and freeze...
Simon Pilgrim [Mon, 8 Aug 2022 15:43:30 +0000 (16:43 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(sext(x)) -> sext(freeze(x)) and freeze(zext(x)) -> zext(freeze(x)) support

Both are guaranteed not to create undef/poison

23 months ago[lldb] Make Process and subclass constructors protected
Michał Górny [Fri, 5 Aug 2022 17:39:42 +0000 (19:39 +0200)]
[lldb] Make Process and subclass constructors protected

Make constructors of the Process and its subclasses class protected,
to prevent accidentally constructing Process on stack when it could be
afterwards accessed via a shared_ptr (since it uses
std::enable_shared_from_this<>).

The only place where a stack allocation was used were unittests,
and fixing them via declaring an explicit public constructor
in the respective mock classes is trivial.

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

23 months agoUpdate the C status page from the latest working draft
Aaron Ballman [Mon, 8 Aug 2022 15:29:34 +0000 (11:29 -0400)]
Update the C status page from the latest working draft

WG14 N3047 is the last C working draft before the document goes out
for committee ballot, so this should be the last of the C2x compiler
features to be added.

23 months ago[nfc][openmp] clang-format system.cpp prior to D131401
Jon Chesterfield [Mon, 8 Aug 2022 15:24:34 +0000 (16:24 +0100)]
[nfc][openmp] clang-format system.cpp prior to D131401

23 months ago[lld/mac] Use C++17 structured bindings in two more places
Nico Weber [Mon, 8 Aug 2022 15:09:22 +0000 (11:09 -0400)]
[lld/mac] Use C++17 structured bindings in two more places

No behavior change.

23 months ago[mlir][math] Add `math.absi` op
Jeff Niu [Sat, 6 Aug 2022 16:09:57 +0000 (12:09 -0400)]
[mlir][math] Add `math.absi` op

Adds an integer absolute value op to the math dialect.

When converting to LLVM, this op is lowered to the LLVM `abs` intrinsic.
When converting to SPIRV, this op is lowered to `spv.GL.SAbs`.

Depends on D131325

Reviewed By: ftynse

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

23 months ago[mlir][math] Rename math.abs -> math.absf
Jeff Niu [Sat, 6 Aug 2022 15:07:51 +0000 (11:07 -0400)]
[mlir][math] Rename math.abs -> math.absf

To make room for introducing `math.absi`.

Reviewed By: ftynse

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

23 months ago[X86] Add test coverage for sext/zext/bswap/bitreverse with freeze
Simon Pilgrim [Mon, 8 Aug 2022 14:39:11 +0000 (15:39 +0100)]
[X86] Add test coverage for sext/zext/bswap/bitreverse with freeze

All of these are safe to fold from freeze(unaryop(x)) -> unaryop(freeze(x))

23 months ago[StandardInstrumentations] Handle case where block order changes
Arthur Eubanks [Tue, 26 Jul 2022 20:03:53 +0000 (13:03 -0700)]
[StandardInstrumentations] Handle case where block order changes

Previously we'd go off the end of the BI iterator because we expected
that the relative positions of common blocks before and after were
consistent. That's not always true though, for example with
jump-threading.

Reviewed By: jamieschmeiser

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

23 months agoRecommit [RDF] Remove explicit template arguments from Print
Krzysztof Parzyszek [Mon, 8 Aug 2022 14:24:09 +0000 (07:24 -0700)]
Recommit [RDF] Remove explicit template arguments from Print

The build breakages should be addressed by d4abdd2e3d:
  [CMake] Check CMAKE_CXX_STANDARD and error if it's to old

Thanks to Tobias and Roy for addressing these issues.

23 months ago[NFC][Flang][OpenMP] Refactor OpenMP.cpp::genOpenMPReduction
Dylan Fleming [Mon, 8 Aug 2022 14:04:45 +0000 (14:04 +0000)]
[NFC][Flang][OpenMP] Refactor OpenMP.cpp::genOpenMPReduction

This patch serves two main purposes:
Firstly, to split some of the logic into a seperate method
to try and improve readability

On top of this, it aims to make creating the reductions more generic.
That way, subsequent patches adding reductions shouldn't need
to add a significant amount of extra logic checks, such as checking
for specific operators.

Reviewed By: awarzynski

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

23 months ago[ADT] Add is_splat overload accepting initializer_list
Jakub Kuderski [Mon, 8 Aug 2022 14:19:34 +0000 (10:19 -0400)]
[ADT] Add is_splat overload accepting initializer_list

Allow for `is_splat` to be used inline, similar to `is_contained`, e.g.,
```
if (is_splat({type1, type2, type3, type4}))
  ...
```

which is much more concise and less typo-prone than an equivalent chain of equality comparisons.

My immediate motivation is to clean up some code in the SPIR-V dialect that currently needs to either construct a temporary container or use `makeArrayRef` before calling `is_splat`.

Reviewed By: dblaikie

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

23 months ago[DAG] Add initial SelectionDAG::canCreateUndefOrPoison support
Simon Pilgrim [Mon, 8 Aug 2022 14:15:56 +0000 (15:15 +0100)]
[DAG] Add initial SelectionDAG::canCreateUndefOrPoison support

This patch adds basic support for a DAG variant of the canCreateUndefOrPoison call and updates DAGCombiner::visitFREEZE to use it, further Opcodes (including target specific Opcodes) can be handled when we have test coverage.

So far, I've left visitFREEZE to just use this for unary nodes (which currently means the existing BITCAST/FREEZE cases) - later patches will add other unary opcodes (with test coverage) and we can also refactor visitFREEZE to support a general number of operands like we do in InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating.

I'm not aware of any vector test freeze coverage so the DemandedElts (and the Depth) args are not being used yet - but they are in place. Similarly we will be able to handle poison generating SDNodeFlags as and when it becomes an issue.

Part of the work for D106675 / PR50468

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

23 months ago[llvm-dwarfutil] Remove unnecessarily dependency.
Alexey Lapshin [Thu, 4 Aug 2022 12:03:03 +0000 (15:03 +0300)]
[llvm-dwarfutil] Remove unnecessarily dependency.

llvm-dwarutil.cpp redundantly calls to InitializeAllAsmParsers.
That call might be removed as well as dependency on ${LLVM_TARGETS_TO_BUILD}

Reviewed By: thakis

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

23 months ago[EarlyCSE][ConstantFolding] move test files to dir of pass in RUN line; NFC
Sanjay Patel [Mon, 8 Aug 2022 14:08:04 +0000 (10:08 -0400)]
[EarlyCSE][ConstantFolding] move test files to dir of pass in RUN line; NFC

23 months ago[Docs] Add HLSL ResourceType documentation
Chris Bieneman [Fri, 29 Jul 2022 19:20:27 +0000 (14:20 -0500)]
[Docs] Add HLSL ResourceType documentation

Along with the new documentation this also re-organizes the HLSL docs
to a subdirectory. The hope is to continue to expand this documentation
as the HLSL implementation advances.

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

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.