platform/upstream/llvm.git
2 years ago[libc++] Fix proxy iterator issues that trigger an assertion in Chromium.
Hui Xie [Thu, 21 Jul 2022 00:03:29 +0000 (17:03 -0700)]
[libc++] Fix proxy iterator issues that trigger an assertion in Chromium.

Crash report:
https://bugs.chromium.org/p/chromium/issues/detail?id=1346012

The triggered assertion is related sorting with `v8::internal::AtomicSlot`.
`AtomicSlot` is a proxy iterator with a proxy type `AtomicSlot::Reference`
(see https://chromium.googlesource.com/v8/v8/+/9bcb5eb590643db0c1f688fea316c7f1f4786a3c/src/objects/slots-atomic-inl.h).

https://reviews.llvm.org/D130197 correctly spotted the issue in
`__iter_move` but doesn't actually fix the issue. The reason is that
`AtomicSlot::operator*` returns a prvalue `Reference`. After the fix in
D130197, the return type of `__iter_move` is `Reference&&`. But the
rvalue reference is bound to the temporary value returned by
`operator*`, which will be dangling after `__iter_move` returns.

The idea of the fix in this change is borrowed from C++17's move_iterator
https://timsong-cpp.github.io/cppwp/n4659/move.iterators#move.iterator-1
When the underlying reference is a prvalue, we just return it by value.

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

2 years ago[gn build] Port 4fcf8434dd77
LLVM GN Syncbot [Thu, 21 Jul 2022 00:53:15 +0000 (00:53 +0000)]
[gn build] Port 4fcf8434dd77

2 years ago[ORC] Add a new MemoryMapper-based JITLinkMemoryManager implementation.
Anubhab Ghosh [Thu, 21 Jul 2022 00:32:56 +0000 (17:32 -0700)]
[ORC] Add a new MemoryMapper-based JITLinkMemoryManager implementation.

MapperJITLinkMemoryManager supports executor memory management using any
implementation of MemoryMapper to do the transfer such as InProcessMapper or
SharedMemoryMapper.

Reviewed By: lhames

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

2 years agoRevert "[flang] Run algebraic simplification optimization pass."
Slava Zakharin [Wed, 20 Jul 2022 23:56:28 +0000 (16:56 -0700)]
Revert "[flang] Run algebraic simplification optimization pass."

This reverts commit 4fbd1d6c872e8228f23a6e13914222af40ca6461.

2 years ago[ORC] Don't try to copy from an empty segment in SimpleExecutorMemoryManager.
Lang Hames [Wed, 20 Jul 2022 22:38:34 +0000 (15:38 -0700)]
[ORC] Don't try to copy from an empty segment in SimpleExecutorMemoryManager.

Since 67220c2ad72e empty SPSSequence<char>s deserialize to default-constructed
ArrayRef<char>s, which have a null data field. We need to check for this to
avoid memcpy'ing from a nullptr.

This should fix the bot failure in
https://lab.llvm.org/buildbot/#/builders/85/builds/9323

2 years ago[Darwin toolchain] Tune the logic for finding arclite.
Steven Wu [Wed, 20 Jul 2022 23:45:09 +0000 (16:45 -0700)]
[Darwin toolchain] Tune the logic for finding arclite.

The heuristic used to determine where the arclite libraries are to be
found was based on the path of the `clang` executable. However, in some
scenarios the `clang` executable is within a toolchain that does not
have arclite. When this happens, derive the arclite paths from the
sysroot option.

This allows Clang to correctly derive the arclite directory in, e.g.,
Swift CI, using similar logic to what the Swift driver has been doing
for several years.

Patched by Doug Gregor.

Reviewed By: keith

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

2 years ago[flang] Run algebraic simplification optimization pass.
Slava Zakharin [Thu, 14 Jul 2022 23:50:41 +0000 (16:50 -0700)]
[flang] Run algebraic simplification optimization pass.

Flang algebraic simplification pass will run algebraic simplification
rewrite patterns for Math/Complex/etc. dialects. It is enabled
under opt-for-speed optimization levels (i.e. for O1/O2/O3; Os/Oz will not
enable it).

With this change the FIR/MLIR optimization pipeline becomes affected
by the -O* optimization level switches. Until now these switches
only affected the middle-end and back-end.

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

2 years ago[mlir:LSP] Add a quickfix code action for inserting expected-* diagnostic checks
River Riddle [Wed, 20 Jul 2022 08:43:07 +0000 (01:43 -0700)]
[mlir:LSP] Add a quickfix code action for inserting expected-* diagnostic checks

This allows for automatically inserting expected checks for parser and verifier
diagnostics, which simplifies the workflow when building new dialect
constructs or extending existing ones.

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

2 years ago[Attributor] Deal with complex PHI nodes better during AAPointerInfo
Johannes Doerfert [Sun, 10 Jul 2022 18:49:36 +0000 (13:49 -0500)]
[Attributor] Deal with complex PHI nodes better during AAPointerInfo

We were quite conservative when it came to PHI node handling to avoid
recursive reasoning. Now we check more direct if we have seen a PHI
already or not. This allows non-recursive PHI chains to be handled.

This also exposed a bug as we did only model the effect of one loop
traversal. `phi_no_store_3` has been adapted to show how we would have
used `undef` instead of `1` before. With this patch we don't replace
it at all, which is expected as we do not argue about loop iterations
(or alignments).

2 years ago[Attributor] Only non-exact accesses require a uniform bit-pattern (=0)
Johannes Doerfert [Sun, 10 Jul 2022 18:46:42 +0000 (13:46 -0500)]
[Attributor] Only non-exact accesses require a uniform bit-pattern (=0)

If we only have exact accesses we should never require the bit-pattern
to be uniform (in this case 0). Only a non-exact access should force us
to require only 0 values.

2 years ago[GlobalOpt] Enable evaluation of atomic stores
Alexander Shaposhnikov [Wed, 20 Jul 2022 22:29:03 +0000 (22:29 +0000)]
[GlobalOpt] Enable evaluation of atomic stores

Relax the check to allow evaluation of atomic stores
(but still skip volatile stores).

Test plan:
1/ ninja check-llvm check-clang
2/ Bootstrapped LLVM/Clang pass tests

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

2 years ago[MemProf] Basic metadata support and verification
Teresa Johnson [Mon, 6 Jun 2022 13:57:36 +0000 (06:57 -0700)]
[MemProf] Basic metadata support and verification

Add basic support for the MemProf metadata (!memprof and !callsite)
which was initially described in "RFC: IR metadata format for MemProf"
(https://discourse.llvm.org/t/rfc-ir-metadata-format-for-memprof/59165).

The bulk of the patch is verification support, along with some tests.

There are a couple of changes to the format described in the original
RFC:

Initial measurements suggested that a tree format for the stack ids in
the contexts would be more efficient, but subsequent evaluation with
large applications showed that in fact the cost of the additional
metadata nodes required by this deduplication scheme overwhelmed the
benefit from sharing stack id nodes. Therefore, the implementation here
and in follow on patches utilizes a simpler scheme of lists of stack id
integers in the memprof profile contexts and callsite metadata. The
follow on matching patch employs context trimming optimizations to
reduce the cost.

Secondly, instead of verbosely listing all profiled fields in each
profiled context (memory info block or MIB), and deferring the
interpretation of the profile data, the profile data is evaluated and
converted into string tags specifying the behavior (e.g. "cold") during
profile matching. This reduces the verbosity of the profile metadata,
and allows additional context trimming optimizations. As a result, the
named metadata schema description is also no longer needed.

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

2 years ago[ThinLTO] Support aliased GlobalIFunc
Schrodinger ZHU Yifan [Wed, 20 Jul 2022 22:30:38 +0000 (15:30 -0700)]
[ThinLTO] Support aliased GlobalIFunc

Fixes https://github.com/llvm/llvm-project/issues/56290: when an ifunc is
aliased in LTO, clang will attempt to create an alias summary; however, as ifunc
is not included in the module summary, doing so will lead to crash.

Reviewed By: MaskRay

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

2 years agollvm-reduce: Fix register mask test
Matt Arsenault [Wed, 20 Jul 2022 20:52:07 +0000 (16:52 -0400)]
llvm-reduce: Fix register mask test

This was sometimes failing with "input module no longer interesting
after counting chunks" assert.

2 years ago[RISCV] Recognize bexti from (srl (and X, 1<<C), C).
Craig Topper [Wed, 20 Jul 2022 21:55:09 +0000 (14:55 -0700)]
[RISCV] Recognize bexti from (srl (and X, 1<<C), C).

This is the form we get for (zext (setne (and X 1<<C))). We only
had bexti patterns for the alternative form (and (srl X, C), 1).

2 years ago[RISCV] Add test cases for failure to use bexti for (setne (and X, 1<<C))
Craig Topper [Wed, 20 Jul 2022 21:48:43 +0000 (14:48 -0700)]
[RISCV] Add test cases for failure to use bexti for (setne (and X, 1<<C))

This will get converted to (srl (and X, 1<<C), C) which we need
to isel to bexti.

2 years ago[MLIR] Add function to create Float16 array attribute
Tanyo Kwok [Wed, 20 Jul 2022 19:12:41 +0000 (19:12 +0000)]
[MLIR] Add function to create Float16 array attribute

This patch adds a new function mlirDenseElementsAttrFloat16Get(),
which accepts the shaped type, the number of Float16 values, and a
pointer to an array of Float16 values, each of which is a uint16_t
value.

This commit is repeating https://reviews.llvm.org/D123981 + #761 but for Float16

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

2 years ago[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan
Slava Gurevich [Wed, 20 Jul 2022 20:32:53 +0000 (13:32 -0700)]
[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan

Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com:

1094796 1095721 1095728 1095737 1095741
1095756 1095779 1095789 1095805 1214552
1229457 1232475 1274006 1274010 1293427
1364800 1364802 1364804 1364812 1364816
1374902 1374909 1384975 1399312 1420451
1431704 1454230 1454554 1454615 1454579
1454594 1454832 1457759 1458696 1461909
1467658 1487814 1487830 1487845

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

2 years ago[LV] Refresh a couple of autogen tests for naming change
Philip Reames [Wed, 20 Jul 2022 21:43:08 +0000 (14:43 -0700)]
[LV] Refresh a couple of autogen tests for naming change

These appear to just be changes in temporary identifiers; bit suprising we have so many.

2 years ago[mlir][spirv] Rename spv.ocl to spv.cl. NFC.
Jakub Kuderski [Wed, 20 Jul 2022 21:46:11 +0000 (17:46 -0400)]
[mlir][spirv] Rename spv.ocl to spv.cl. NFC.

This is to improve the consistency within the SPIR-V dialect and to make op names a bit shorter.

Reviewed By: antiagainst

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

2 years ago[HIP] Allow the new driver to compile HIP in non-RDC mode
Joseph Huber [Thu, 14 Jul 2022 15:46:43 +0000 (11:46 -0400)]
[HIP] Allow the new driver to compile HIP in non-RDC mode

The new driver primarily allows us to support RDC-mode compilations with
proper linking. This is not needed for non-RDC mode compilation, but we
still would like the new driver to be able to handle this mode so we can
transition away from the old driver in the future. This patch adds the
necessary code to support creating a fatbinary for HIP code generation.

Reviewed By: yaxunl

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

2 years ago[libc++] Fix `_IterOps::__iter_move` to support proxy iterators.
Konstantin Varlamov [Wed, 20 Jul 2022 20:17:25 +0000 (13:17 -0700)]
[libc++] Fix `_IterOps::__iter_move` to support proxy iterators.

The return type was specified incorrectly for proxy iterators that
define `reference` to be a class that implicitly converts to
`value_type`. `__iter_move` would end up returning an object of type
`reference` which would then implicitly convert to `value_type`; thus,
the function will return a `value_type&&` rvalue reference to the local
temporary.

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

2 years ago[llvm] [cmake] Skip driver-related code unless LLVM_TOOL_LLVM_DRIVER_BUILD
Michał Górny [Wed, 20 Jul 2022 10:28:17 +0000 (12:28 +0200)]
[llvm] [cmake] Skip driver-related code unless LLVM_TOOL_LLVM_DRIVER_BUILD

Disable the code responsible for preparing object libraries
for the driver and filling LLVM_DRIVER_* properties
if LLVM_TOOL_LLVM_DRIVER_BUILD is disabled.  These properties are
consumed only by tools/llvm-driver, and so they are not used at all
if LLVM_TOOL_LLVM_DRIVER_BUILD is not enabled.  At the same time,
the related code breaks standalone clang builds against LLVM built
with LLVM_LINK_LLVM_DYLIB.

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

2 years ago[gn build] Port 23cf42e706fb
LLVM GN Syncbot [Wed, 20 Jul 2022 20:02:41 +0000 (20:02 +0000)]
[gn build] Port 23cf42e706fb

2 years ago[libc++] Use uninitialized algorithms for vector
Nikolas Klauser [Wed, 20 Jul 2022 18:24:46 +0000 (20:24 +0200)]
[libc++] Use uninitialized algorithms for vector

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[Libomptarget] Make libomptarget an LLVM library
Joseph Huber [Wed, 20 Jul 2022 19:00:23 +0000 (15:00 -0400)]
[Libomptarget] Make libomptarget an LLVM library

This patch makes libomptarget depend on LLVM libraries to be built. The
reason for this is because we already have an implicit dependency on
LLVM headers for ELF identification and extraction as well as an
optional dependenly on the LLVMSupport library for time tracing
information. Furthermore, there are changes in the future that require
using more LLVM libraries, and will heavily simplify some future code as
well as open up the large amount of useful LLVM libraries to
libomptarget.

This will make "standalone" builds of `libomptarget' more difficult for
vendors wishing to ship their own. This will require a sufficiently new
version of LLVM to be installed on the system that should be picked up
by the existing handling for the implicit headers.

The things this patch changes are as follows:
  - `libomptarget.so` links against LLVMSupport and LLVMObject
  - `libomptarget.so` is a symbolic link to `libomptarget.so.15`
  - If using a shared library build, user applications will depend on LLVM
    libraries as well
  - We can now use LLVM resources in Libomptarget.

Note that this patch only changes this to apply to libomptarget itself,
not the plugins. Additional patches will be necessary for that.

Reviewed By: JonChesterfield

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

2 years ago[NFC] Suppress unused variable warning in non-assert builds
Arthur Eubanks [Wed, 20 Jul 2022 19:26:16 +0000 (12:26 -0700)]
[NFC] Suppress unused variable warning in non-assert builds

2 years ago[mlir:LSP] Add a doc blurb for code completion
River Riddle [Wed, 20 Jul 2022 19:01:34 +0000 (12:01 -0700)]
[mlir:LSP] Add a doc blurb for code completion

This also gets used for the vscode extension documentation.

2 years ago[mlir:LSP] Remove several more annoying completion commit characters
River Riddle [Wed, 20 Jul 2022 19:00:18 +0000 (12:00 -0700)]
[mlir:LSP] Remove several more annoying completion commit characters

These characters are annoying in that they accept completions
that weren't intended, causing user frustration.

2 years ago[LAA] Fix latent missing check bug when mixing scalable and non-scalabe strides
Philip Reames [Wed, 20 Jul 2022 18:54:05 +0000 (11:54 -0700)]
[LAA] Fix latent missing check bug when mixing scalable and non-scalabe strides

Noticed via inspection; to my knowledge, impossible to hit today.  In theory, we could have a fixed stride check be analyzed, then a scalable one.  With the old code, the scalable one would be silently dropped, and the runtime guard would go ahead with only the fixed one.  This would be a miscompile.

2 years ago[libc++][ranges] Implement `std::ranges::partition_{point,copy}`.
Konstantin Varlamov [Wed, 20 Jul 2022 08:57:13 +0000 (01:57 -0700)]
[libc++][ranges] Implement `std::ranges::partition_{point,copy}`.

Reviewed By: #libc, huixie90, ldionne

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

2 years ago[lld-macho] Fold cfstrings with --deduplicate-literals
Keith Smiley [Wed, 20 Jul 2022 00:03:34 +0000 (17:03 -0700)]
[lld-macho] Fold cfstrings with --deduplicate-literals

Similar to cstrings ld64 always deduplicates cfstrings. This was already
being done when enabling ICF, but for debug builds you may want to flip
this on if you cannot eliminate your instances of this, so this change
makes --deduplicate-literals also apply to cfstrings.

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

2 years ago[HLSL] add -I option for dxc mode.
Xiang Li [Thu, 23 Jun 2022 21:07:07 +0000 (14:07 -0700)]
[HLSL] add -I option for dxc mode.

A new option -I is added for dxc mode.
It is just alias of existing cc1 -I option.

Reviewed By: beanz

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

2 years ago[InstCombine] Add mul with negated power of 2 constant to canEvaluateShifted.
Craig Topper [Tue, 19 Jul 2022 17:24:15 +0000 (10:24 -0700)]
[InstCombine] Add mul with negated power of 2 constant to canEvaluateShifted.

If we are right shifting a multiply by a negated power of 2 where
the power of 2 is the same as the shift amount, we can replace with
a negate followed by an And.

New tests have not been committed yet but the patch shows the diffs.
Let me know if you want any changes or additional tests.

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

2 years ago[InstCombine] Pre-commit test for D130103.
Craig Topper [Tue, 19 Jul 2022 17:21:03 +0000 (10:21 -0700)]
[InstCombine] Pre-commit test for D130103.

2 years ago[test] Add missing REQUIRES: arm-registered-target
Arthur Eubanks [Wed, 20 Jul 2022 17:58:42 +0000 (10:58 -0700)]
[test] Add missing REQUIRES: arm-registered-target

2 years ago[NFC][tests] Remove XFAIL for AIX for passing tests
Hubert Tong [Wed, 20 Jul 2022 17:55:57 +0000 (13:55 -0400)]
[NFC][tests] Remove XFAIL for AIX for passing tests

https://lab.llvm.org/buildbot/#/builders/214/builds/2425 reports these
tests as XPASS.

2 years ago[test] Remove unnecessary -verify-machineinstrs=0
Arthur Eubanks [Wed, 20 Jul 2022 17:55:03 +0000 (10:55 -0700)]
[test] Remove unnecessary -verify-machineinstrs=0

Issue #38784 seems to be fixed and removing these doesn't cause any issues.

2 years ago[AMDGPU] NFC. Assert that mask is full with VOPC DPP
Joe Nash [Tue, 19 Jul 2022 16:49:15 +0000 (12:49 -0400)]
[AMDGPU] NFC. Assert that mask is full with VOPC DPP

VOPC DPP should not be formed when the row_mask and bank_mask are not
0xf (full) because the resulting VOP DPP would have different semantics
than the MOV DPP followed by VOP. Existing checks in GCNDPPCombine cover
this case but for different reasons, so assert the property for
future-proofing.

Reviewed By: nhaehnle

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

2 years ago[libc++][format] Updates the status page.
Mark de Wever [Wed, 20 Jul 2022 17:26:28 +0000 (19:26 +0200)]
[libc++][format] Updates the status page.

2 years ago[RISCV][test] Add tests for atomic compare exchange + branch on result
Alex Bradbury [Wed, 20 Jul 2022 16:49:33 +0000 (17:49 +0100)]
[RISCV][test] Add tests for atomic compare exchange + branch on result

Due to the late expansion of the compare exchange sequences, there's
scope for improving codegen by folding the branches into the cmpxchg
loop (avoiding a branch-to-branch).

2 years ago[gn build] Port 857a78c04dee
LLVM GN Syncbot [Wed, 20 Jul 2022 16:42:40 +0000 (16:42 +0000)]
[gn build] Port 857a78c04dee

2 years ago[IPO] Restore a call to has_value (NFC)
Kazu Hirata [Wed, 20 Jul 2022 16:40:18 +0000 (09:40 -0700)]
[IPO] Restore a call to has_value (NFC)

This patch restores a call to has_value to make it clear that we are
checking the presence of an optional value, not the underlying value.

This patch partially reverts d08f34b592ff06ccb1f36da88ec09aa926427a4d.

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

2 years ago[libc++] Implements Unicode grapheme clustering
Mark de Wever [Sat, 28 May 2022 13:30:10 +0000 (15:30 +0200)]
[libc++] Implements Unicode grapheme clustering

This implements the Grapheme clustering as required by
P1868R2 width: clarifying units of width and precision in std::format

This was omitted in the initial patch, but the paper was marked as completed. This really completes the paper.

Reviewed By: ldionne, #libc

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

2 years ago [flang][nfc] Test folding of bit-population count intrinsics
Tarun Prabhu [Wed, 20 Jul 2022 16:27:22 +0000 (11:27 -0500)]
[flang][nfc] Test folding of bit-population count intrinsics

Test compile-time folding of the leadz, trailz, popcnt and poppar Fortran 2008 intrinsics.

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

2 years agofix bug for useless malloc elimination in CodeGenPrepare
Ruobing Han [Tue, 19 Jul 2022 21:39:14 +0000 (21:39 +0000)]
fix bug for useless malloc elimination in CodeGenPrepare

Put AllocationFn check before I->willReturn can allow CodeGenPrepare to remove useless malloc instruction

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

2 years ago[libc++][doc] Updates the release notes.
Mark de Wever [Mon, 18 Jul 2022 18:32:39 +0000 (20:32 +0200)]
[libc++][doc] Updates the release notes.

This is a preparation for the upcoming LLVM 16 release.

Reviewed By: ldionne, #libc

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

2 years ago[RISCV][test] Add tests showing signext behaviour of cmpxchg
Alex Bradbury [Wed, 20 Jul 2022 16:08:30 +0000 (17:08 +0100)]
[RISCV][test] Add tests showing signext behaviour of cmpxchg

2 years agoUse llvm::is_contained (NFC)
Kazu Hirata [Wed, 20 Jul 2022 16:09:19 +0000 (09:09 -0700)]
Use llvm::is_contained (NFC)

2 years ago[flang] Use value instead of getValue (NFC)
Kazu Hirata [Wed, 20 Jul 2022 15:56:23 +0000 (08:56 -0700)]
[flang] Use value instead of getValue (NFC)

Flang C++ Style Guide tells us to use x.value() when no presence test
is obviously protecting the reference.  Since assert can be disabled,
I don't count it as "protection" here.

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

2 years ago[LV] Autogen a test for ease of update
Philip Reames [Wed, 20 Jul 2022 15:14:45 +0000 (08:14 -0700)]
[LV] Autogen a test for ease of update

2 years agoRevert "[Libomptarget] Make libomptarget an LLVM library"
Joseph Huber [Wed, 20 Jul 2022 14:18:23 +0000 (10:18 -0400)]
Revert "[Libomptarget] Make libomptarget an LLVM library"

This reverts commit 643dfd97d52e7b0c0dfbe7fd6046de9d43b3daa6.

This patch still makes the AMDGPU buildbots unhappy. Reverting for now
until the AMD folks figure it out.

2 years ago[Libomptarget] Fix LTO command line in test
Joseph Huber [Wed, 20 Jul 2022 14:17:35 +0000 (10:17 -0400)]
[Libomptarget] Fix LTO command line in test

Summary:
The test passed -offload-lto instead of -foffload-lto.

2 years agoredo UNSUPPORT test on 64-bit AIX too
Jake Egan [Wed, 20 Jul 2022 14:17:35 +0000 (10:17 -0400)]
redo UNSUPPORT test on 64-bit AIX too

The test failure affects both bitmodes.

2 years ago[LV] Autogen several tests for ease of update in upcoming change
Philip Reames [Wed, 20 Jul 2022 14:17:44 +0000 (07:17 -0700)]
[LV] Autogen several tests for ease of update in upcoming change

2 years agoUNSUPPORT test on 64-bit AIX too
Jake Egan [Wed, 20 Jul 2022 14:03:20 +0000 (10:03 -0400)]
UNSUPPORT test on 64-bit AIX too

The test failure affects both bitmodes.

2 years ago[LLD] [COFF] Improve the error message for too many exported symbols
Martin Storsjö [Mon, 18 Jul 2022 06:27:11 +0000 (09:27 +0300)]
[LLD] [COFF] Improve the error message for too many exported symbols

Print the actual number of symbols that would have been exported
too, which helps assessing the situation.

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

2 years ago[TableGen] Add a location for a class definition that was forward-declared
Roman Rusyaev [Wed, 20 Jul 2022 13:25:02 +0000 (15:25 +0200)]
[TableGen] Add a location for a class definition that was forward-declared

This change improves ctags generation for tablegen files.

For the following example
```
class A;

class A {
  int a;
}
```
Previously, tags were generated only for a forward declaration of class 'A'.

This patch allows generating tags for the forward declarations
and further definition of class 'A'.

Reviewed By: barannikov88

Original patch by: rusyaev-roman (Roman Rusyaev)
Some adjustments by: nhaehnle (Nicolai Hähnle)

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

2 years ago[Libomptarget] Make libomptarget an LLVM library
Joseph Huber [Fri, 15 Jul 2022 16:10:18 +0000 (12:10 -0400)]
[Libomptarget] Make libomptarget an LLVM library

This patch makes libomptarget depend on LLVM libraries to be built. The
reason for this is because we already have an implicit dependency on
LLVM headers for ELF identification and extraction as well as an
optional dependenly on the LLVMSupport library for time tracing
information. Furthermore, there are changes in the future that require
using more LLVM libraries, and will heavily simplify some future code as
well as open up the large amount of useful LLVM libraries to
libomptarget.

This will make "standalone" builds of `libomptarget' more difficult for
vendors wishing to ship their own. This will require a sufficiently new
version of LLVM to be installed on the system that should be picked up
by the existing handling for the implicit headers.

The things this patch changes are as follows:
  - `libomptarget.so` links against LLVMSupport and LLVMObject
  - `libomptarget.so` is a symbolic link to `libomptarget.so.15`
  - If using a shared library build, user applications will depend on LLVM
    libraries as well
  - We can now use LLVM resources in Libomptarget.

Note that this patch only changes this to apply to libomptarget itself,
not the plugins. Additional patches will be necessary for that.

Reviewed By: JonChesterfield

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

2 years ago[mlir][bufferize][doc] Fix documentation of return type of `to_memref`.
Ingo Müller [Wed, 20 Jul 2022 12:04:09 +0000 (12:04 +0000)]
[mlir][bufferize][doc] Fix documentation of return type of `to_memref`.

This is my very first contact with this dialect, so I am not very
confident with this commit, but it seems like the op returns a memref,
not a tensor, so that's what comment about the result type should say.

[mlir][bufferization][doc] Improve typesetting of inline code. Fix Typo.

Reviewed By: pifon2a

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

2 years ago[clang] Small adjustments for -fexperimental-library
Louis Dionne [Wed, 20 Jul 2022 13:10:40 +0000 (09:10 -0400)]
[clang] Small adjustments for -fexperimental-library

Move -lc++experimental before -lc++abi (that was forgotten in the
original patch), and mark a test as UNSUPPORTED on AIX. I contacted
the owners of the AIX bot that failed because I was unable to reproduce
the issue locally.

2 years ago[AMDGPU] Change RUN lines to not depend on code sinking. NFC.
Jay Foad [Wed, 20 Jul 2022 12:40:06 +0000 (13:40 +0100)]
[AMDGPU] Change RUN lines to not depend on code sinking. NFC.

Change a couple of RUN lines to not depend on the presence or position
of the IR code sinking pass in the codegen pipeline, since it does not
belong in there anyway.

2 years ago[LV] Fix miscompile due to srem/sdiv speculation safety condition
Philip Reames [Tue, 19 Jul 2022 18:42:55 +0000 (11:42 -0700)]
[LV] Fix miscompile due to srem/sdiv speculation safety condition

An srem or sdiv has two cases which can cause undefined behavior, not just one. The existing code did not account for this, and as a result, we miscompiled when we encountered e.g. a srem i64 %v, -1 in a conditional block.

Instead of hand rolling the logic, just use the utility function which exists exactly for this purpose.

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

2 years agoUpdate the Windows packaging script.
Carlos Alberto Enciso [Wed, 20 Jul 2022 12:22:10 +0000 (13:22 +0100)]
Update the Windows packaging script.

As discussed on:
  https://discourse.llvm.org/t/build-llvm-release-bat-script-options/63146/6

Giving:
  call :function if errorlevel 1 exit /b 1

Due to a missing new line, the error code returned by the function
is taking as another argument.

Changed to use standard '||' to exit if the errorlevel greater than zero.

  call :function || exit /b 1

Reviewed By: hans

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

2 years agoInliner: don't mark call sites as 'nounwind' if that would be redundant
Nicolai Hähnle [Fri, 15 Jul 2022 13:27:26 +0000 (15:27 +0200)]
Inliner: don't mark call sites as 'nounwind' if that would be redundant

When F calls G calls H, G is nounwind, and G is inlined into F, then the
inlined call-site to H should be effectively nounwind so as not to lose
information during inlining.

If H itself is nounwind (which often happens when H is an intrinsic), we
no longer mark the callsite explicitly as nounwind. Previously, there
were cases where the inlined call-site of H differs from a pre-existing
call-site of H in F *only* in the explicitly added nounwind attribute,
thus preventing common subexpression elimination.

v2:
- just check CI->doesNotThrow

v3 (resubmit after revert at 344378808778c61d5599f4e0ac783ef7e6f8ed05):
- update Clang tests

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

2 years ago[SCEV][NFC][CT] Do not waste time proving contextual facts for unreached loops and...
Max Kazantsev [Wed, 20 Jul 2022 12:01:43 +0000 (19:01 +0700)]
[SCEV][NFC][CT] Do not waste time proving contextual facts for unreached loops and blocks

In fact, in unreached code we can say that every fact is true. So do not waste time trying to
do something smarter.

Formally it's not an NFC because it may change query results in unreached code, but they
won't have any impact on execution.

Hypothetical CT boost expected but not measured in practice.

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

2 years agoUpdate some more tests with update_cc_test_checks.py
Nicolai Hähnle [Tue, 19 Jul 2022 06:58:31 +0000 (08:58 +0200)]
Update some more tests with update_cc_test_checks.py

2 years ago[flang][driver] Fix opt-level option parsing
Andrzej Warzynski [Tue, 19 Jul 2022 17:48:31 +0000 (17:48 +0000)]
[flang][driver] Fix opt-level option parsing

This update makes sure that `flang-new -O2 -O0` will run at `-O0` rather
than `-O2`.

This bug was identified and originally fixed by Vyacheslav Zakharin in
https://reviews.llvm.org/D130035. I've extracted the fix into a separate
patch.

co-authored by: Vyacheslav Zakharin <vyacheslav.p.zakharin@intel.com>

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

2 years ago[XCOFF] write the aux header when the visibility is specified in XCOFF32.
esmeyi [Wed, 20 Jul 2022 11:09:34 +0000 (07:09 -0400)]
[XCOFF] write the aux header when the visibility is specified in XCOFF32.

The n_type field in the symbol table entry has two interpretations in XCOFF32, and a single interpretation in XCOFF64.
The new interpretation is used in XCOFF32 if the value of the o_vstamp field in the auxiliary header is 2.
In XCOFF64 and the new XCOFF32 interpretation, the n_type field is used for the symbol type and visibility.
The patch writes the aux header with an o_vstamp field value of 2 when the visibility is specified in XCOFF32 to make the new XCOFF32 interpretation used.

Reviewed By: DiggerLin, jhenderson

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

2 years ago[DAG] getNode - don't bother creating ADDO(X,0) or SUBO(X,0) nodes.
Simon Pilgrim [Wed, 20 Jul 2022 11:04:23 +0000 (12:04 +0100)]
[DAG] getNode - don't bother creating ADDO(X,0) or SUBO(X,0) nodes.

Similar to what we already do in getNode for basic ADD/SUB nodes, return the X operand directly, but here we know that there will be no/zero overflow as well.

As noted on D127115 - this path is being exercised by llvm/test/CodeGen/ARM/dsp-mlal.ll, although I haven't been able to get any codegen without a topological worklist.

2 years ago[ARM] Fix Thumb2 compare being emitted ExpandCMP_SWAP
David Green [Wed, 20 Jul 2022 11:04:22 +0000 (12:04 +0100)]
[ARM] Fix Thumb2 compare being emitted ExpandCMP_SWAP

Given a patch like D129506, using instructions not valid for the current
target feature set becomes an error. This fixes an issue in
ARMExpandPseudo::ExpandCMP_SWAP where Thumb2 compares were used in
Thumb1Only code, such as thumbv8m.baseline targets.

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

2 years ago[X86] shuffle-blend.ll - add avx512f-only test coverage
Simon Pilgrim [Wed, 20 Jul 2022 10:36:07 +0000 (11:36 +0100)]
[X86] shuffle-blend.ll - add avx512f-only test coverage

2 years ago[DAG] getNode - assert that ADDO/SUBO nodes have the correct ops + types
Simon Pilgrim [Wed, 20 Jul 2022 10:23:48 +0000 (11:23 +0100)]
[DAG] getNode - assert that ADDO/SUBO nodes have the correct ops + types

2 years ago[X86] shuffle-blend.ll - add 32-bit test coverage
Simon Pilgrim [Wed, 20 Jul 2022 10:22:08 +0000 (11:22 +0100)]
[X86] shuffle-blend.ll - add 32-bit test coverage

Noticed while reviewing D129537

2 years ago[VPlan] Initial def-use verification.
Florian Hahn [Wed, 20 Jul 2022 10:06:32 +0000 (11:06 +0100)]
[VPlan] Initial def-use verification.

This patch introduces some initial def-use verification. This catches
cases like the one fixed by D129436.

Reviewed By: Ayal

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

2 years ago[DAG] PromoteIntRes_BUILD_VECTOR - extend constant boolean vectors according to targe...
Simon Pilgrim [Wed, 20 Jul 2022 09:48:11 +0000 (10:48 +0100)]
[DAG] PromoteIntRes_BUILD_VECTOR - extend constant boolean vectors according to target BooleanContents

PromoteIntRes_BUILD_VECTOR currently always ANY_EXTENDs build vector operands, but if this is a constant boolean vector we're losing the useful ability to keep the vector matching the BooleanContents mode used by the target.

This patch extends constant boolean vectors according to target BooleanContents, allowing a number of additional all-bits folds (notable XOR -> NOT conversions) to occur.

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

2 years ago[bazel] Also add -lrt to OrcTargetProcess for 1b1f1c778695442c2683813ec7d4b557bb279e26
Benjamin Kramer [Wed, 20 Jul 2022 09:28:26 +0000 (11:28 +0200)]
[bazel] Also add -lrt to OrcTargetProcess for 1b1f1c778695442c2683813ec7d4b557bb279e26

2 years ago[libc++] Implement P1423R3 (char8_t backward compatibility remediation)
Nikolas Klauser [Tue, 19 Jul 2022 00:03:10 +0000 (02:03 +0200)]
[libc++] Implement P1423R3 (char8_t backward compatibility remediation)

Reviewed By: Mordante, #libc

Spies: h-vetinari, libcxx-commits, arichardson

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

2 years ago[libc++] Add clang-tidy for the tests
Nikolas Klauser [Mon, 18 Jul 2022 00:01:02 +0000 (02:01 +0200)]
[libc++] Add clang-tidy for the tests

Reviewed By: Mordante, huixie90, #libc

Spies: aheejin, libcxx-commits

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

2 years ago[bazel] Add -lrt on non-darwin/non-windows for 1b1f1c778695442c2683813ec7d4b557bb279e26
Benjamin Kramer [Wed, 20 Jul 2022 09:21:53 +0000 (11:21 +0200)]
[bazel] Add -lrt on non-darwin/non-windows for 1b1f1c778695442c2683813ec7d4b557bb279e26

For shm_open in orc jit.

2 years agoupdate-test-checks: safely handle tests with #if's
Nicolai Hähnle [Tue, 19 Jul 2022 07:43:58 +0000 (09:43 +0200)]
update-test-checks: safely handle tests with #if's

There is at least one Clang test (clang/test/CodeGen/arm_acle.c) which
has functions guarded by #if's that cause those functions to be compiled
only for a subset of RUN lines.

This results in a case where one RUN line has a body for the function
and another doesn't. Treat this case as a conflict for any prefixes that
the two RUN lines have in common.

This change exposed a bug where functions with '$' in the name weren't
properly recognized in ARM assembly (despite there being a test case
that was supposed to catch the problem!). This bug is fixed as well.

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

2 years ago[InstCombine] add more tests for xor_of_icmps. nfc
Chenbing Zheng [Wed, 20 Jul 2022 09:00:34 +0000 (17:00 +0800)]
[InstCombine] add more tests for xor_of_icmps. nfc

2 years agoRevert "Don't treat readnone call in presplit coroutine as not access memory"
Chuanqi Xu [Wed, 20 Jul 2022 09:00:58 +0000 (17:00 +0800)]
Revert "Don't treat readnone call in presplit coroutine as not access memory"

This reverts commit 57224ff4a6833dca1f17568cc9cf77f9579030ae. This
commit may trigger crashes on some workloads. Revert it for clearness.

2 years agoReland "[AArch64] Add a tablegen pattern for UZP2."
Alexandros Lamprineas [Mon, 18 Jul 2022 07:07:59 +0000 (08:07 +0100)]
Reland "[AArch64] Add a tablegen pattern for UZP2."

Converts concat_vectors((trunc (lshr)), (trunc (lshr))) to UZP2
when the shift amount is half the width of the vector element.

Prioritize the ADDHN(2), SUBHN(2) patterns over UZP2.
Fixes https://github.com/llvm/llvm-project/issues/52919

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

2 years ago[mlir:LSP][NFC] Make the LSPServer class private
River Riddle [Wed, 20 Jul 2022 03:39:09 +0000 (20:39 -0700)]
[mlir:LSP][NFC] Make the LSPServer class private

There is no benefit to making it public, and the code is much
cleaner and easier to follow when inlined. This also matches
the pattern within the PDLL lsp server.

2 years ago[LoopVectorize][AArch64] Add TTI hook preferPredicatedReductionSelect
David Sherwood [Thu, 14 Jul 2022 10:45:41 +0000 (11:45 +0100)]
[LoopVectorize][AArch64] Add TTI hook preferPredicatedReductionSelect

By default if SVE is enabled we want the select instruction used for
reductions to be inside the loop, rather than outside. This makes it
possible for the backend to fold the select into the operation to
produce a single predicated add, fadd, etc.

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

2 years ago[VP] Legalize the stride operand for EXPERIMENTAL_VP_STRIDED SDNodes
Lorenzo Albano [Wed, 20 Jul 2022 08:20:55 +0000 (10:20 +0200)]
[VP] Legalize the stride operand for EXPERIMENTAL_VP_STRIDED SDNodes

Add promotion and expansion of integer operands for
experimental_vp_strided SelectionDAG nodes; the expansion is actually
just a truncation of the stride operand.

Reviewed By: simoll

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

2 years ago[mlir] Fix macOS tests
Anush Elangovan [Wed, 20 Jul 2022 08:18:23 +0000 (10:18 +0200)]
[mlir] Fix macOS tests

Fix shared library names on macOS for execution_engine.py test.

Reviewed By: stellaraccident

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

2 years ago[InstCombine] add tests for icmp-shr. nfc
Chenbing Zheng [Wed, 20 Jul 2022 07:44:31 +0000 (15:44 +0800)]
[InstCombine] add tests for icmp-shr. nfc

2 years ago[sanitizer] Port sanitizer_common to LoongArch
Xi Ruoyao [Wed, 20 Jul 2022 07:58:40 +0000 (00:58 -0700)]
[sanitizer] Port sanitizer_common to LoongArch

Initial libsanitizer support for LoongArch. It survived all GCC UBSan tests.

Major changes:

1. LoongArch port of Linux kernel only supports `statx` for `stat` and its families.  So we need to add `statx_to_stat` and use it for `stat`-like libcalls.  The logic is "borrowed" from Glibc.
2. `sanitizer_syscall_linux_loongarch64.inc` is mostly duplicated from RISC-V port, as the syscall interface is almost same.

Reviewed By: SixWeining, MaskRay, XiaodongLoong, vitalybuka

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

2 years ago[X86] Add test case for shuffle.
Luo, Yuanke [Wed, 20 Jul 2022 07:49:08 +0000 (15:49 +0800)]
[X86] Add test case for shuffle.

The test case focus on shuffle which can be transformed to select or
blend.

2 years ago[llvm] Use llvm::any_of and llvm::none_of (NFC)
Kazu Hirata [Wed, 20 Jul 2022 07:36:19 +0000 (00:36 -0700)]
[llvm] Use llvm::any_of and llvm::none_of (NFC)

2 years ago[mlir][Math] Add constant folder for Log1pOp.
jacquesguan [Mon, 18 Jul 2022 02:36:12 +0000 (10:36 +0800)]
[mlir][Math] Add constant folder for Log1pOp.

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

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

2 years ago[LegacyPM] Remove InstrOrderFileLegacyPass
Fangrui Song [Wed, 20 Jul 2022 06:58:51 +0000 (23:58 -0700)]
[LegacyPM] Remove InstrOrderFileLegacyPass

Following recent changes removing non-core features of the legacy
PM/optimization pipeline.

2 years agoUpdate the Windows packaging script.
Carlos Alberto Enciso [Wed, 20 Jul 2022 06:15:13 +0000 (07:15 +0100)]
Update the Windows packaging script.

As discussed on:
https://discourse.llvm.org/t/build-llvm-release-bat-script-options/63146/6

- In stage1 use the following binaries from stage0:
  lld-link, llvm-lib and llvm-windres

Reviewed By: hans

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

2 years ago[mlir][TilingInterface] Add support for interchange to tiling patterns that use the...
Mahesh Ravishankar [Sun, 17 Jul 2022 06:03:14 +0000 (06:03 +0000)]
[mlir][TilingInterface] Add support for interchange to tiling patterns that use the `TilingInterface`.

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

2 years ago[flang] Use value instead of getValue (NFC)
Kazu Hirata [Wed, 20 Jul 2022 04:49:14 +0000 (21:49 -0700)]
[flang] Use value instead of getValue (NFC)

Flang C++ Style Guide tells us to use x.value() when no presence test
is obviously protecting the reference.

2 years agoRevert "[libasan] Remove 4Mb stack limit for swapcontext unpoisoning"
Vitaly Buka [Wed, 20 Jul 2022 04:17:06 +0000 (21:17 -0700)]
Revert "[libasan] Remove 4Mb stack limit for swapcontext unpoisoning"

This patches exposed existing incorectness of swapcontext imlementation.
swapcontext does not set oucp->uc_stack. Unpoisoning works if ucp is
from makecontext, but may try to use garbage pointers if it's from
previos swapcontext or from getcontext. Existing limit reduces
probability of garbage pointers are used.

I restore behavour which we had for years, and will look to improve
swapcontext support.

This reverts commit d0751c9725aab1dad3d86481e13a4628356e7422.

2 years ago[X86][test] Use Min behavior for "cf-protection-{branch,return}" tests
Fangrui Song [Wed, 20 Jul 2022 04:25:55 +0000 (21:25 -0700)]
[X86][test] Use Min behavior for "cf-protection-{branch,return}" tests

The behavior does not match that much. Min is the new Clang codegen behavior
since D130065.

2 years ago[X86] Use Min behavior for cf-protection-{return,branch}/ibt-seal module flags
Fangrui Song [Wed, 20 Jul 2022 04:20:01 +0000 (21:20 -0700)]
[X86] Use Min behavior for cf-protection-{return,branch}/ibt-seal module flags

These features require that all object files are compiled with the support. When
the feature is disabled for an object file, the merge behavior should treat the
file having a value of 0 (see D129911).

Reviewed By: xiangzhangllvm

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