platform/upstream/llvm.git
2 years ago[SimplifyLibCalls] Move handling of constant char earlier (NFC)
Martin Sebor [Mon, 4 Apr 2022 08:47:59 +0000 (10:47 +0200)]
[SimplifyLibCalls] Move handling of constant char earlier (NFC)

Handle the simple constant char case before the bitmask optimization.
This will allow extending the code to handle a non-constant size
argument in a followup change.

Split out from https://reviews.llvm.org/D122836.

2 years ago[flang][NFC] Add tests for array-value-copy pass with array with pointers
Valentin Clement [Mon, 4 Apr 2022 08:44:21 +0000 (10:44 +0200)]
[flang][NFC] Add tests for array-value-copy pass with array with pointers

This patch adds tests for the array-value-copy pass with array assignment
involving Fortran pointers.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

2 years ago[SimplifyLibCalls] Fold memchr() with size 1
Martin Sebor [Mon, 4 Apr 2022 08:36:57 +0000 (10:36 +0200)]
[SimplifyLibCalls] Fold memchr() with size 1

If the memchr() size is 1, then we can convert the call into a
single-byte comparison. This works even if both the string and the
character are unknown.

Split off from https://reviews.llvm.org/D122836.

2 years ago[InstCombine] Add additional memchr test (NFC)
Martin Sebor [Mon, 4 Apr 2022 08:32:40 +0000 (10:32 +0200)]
[InstCombine] Add additional memchr test (NFC)

And fix some test names / comments.

2 years ago[VPlan] Remember previous loop and reset vector loop.
Florian Hahn [Mon, 4 Apr 2022 08:27:15 +0000 (09:27 +0100)]
[VPlan] Remember previous loop and reset vector loop.

At the moment this is NFC, but will be needed once nested loops are also
modeled as regions. Preparation for D123005.

2 years ago[MemCpyOpt] Work around PR54682
Nikita Popov [Fri, 1 Apr 2022 14:33:35 +0000 (16:33 +0200)]
[MemCpyOpt] Work around PR54682

As discussed on https://github.com/llvm/llvm-project/issues/54682,
MemorySSA currently has a bug when computing the clobber of calls
that access loop-varying locations. I think a "proper" fix for this
on the MemorySSA side might be non-trivial, but we can easily work
around this in MemCpyOpt:

Currently, MemCpyOpt uses a location-less getClobberingMemoryAccess()
call to find a clobber on either the src or dest location, and then
refines it for the src and dest clobber. This was intended as an
optimization, as the location-less API is cached, while the
location-affected APIs are not.

However, I don't think this really makes a difference in practice,
because I don't think anything will use the cached clobbers on
those calls later anyway. On CTMark, this patch seems to be very
mildly positive actually.

So I think this is a reasonable way to avoid the problem for now,
though MemorySSA should also get a fix.

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

2 years ago[Float2Int] Make sure dependent ranges are calculated first (PR54669)
Nikita Popov [Fri, 1 Apr 2022 10:28:21 +0000 (12:28 +0200)]
[Float2Int] Make sure dependent ranges are calculated first (PR54669)

The range calculation in walkForwards() assumes that the ranges of
the operands have already been calculated. With the used visit
order, this is not necessarily the case when there are multiple
roots. (There is nothing guaranteeing that instructions are visited
in topological order.)

Fix this by queuing instructions for reprocessing if the operand
ranges haven't been calculated yet.

Fixes https://github.com/llvm/llvm-project/issues/54669.

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

2 years ago[flang] Fold instantiated PDT character component length when needed
Jean Perier [Mon, 4 Apr 2022 07:47:03 +0000 (09:47 +0200)]
[flang] Fold instantiated PDT character component length when needed

In case a character component PDT length only depends on kind parameters,
fold it while instantiating the PDT. This is especially important if the
component has an initializer because later semantic phases (offset
computation or runtime type info generation) might get confused and
generate offset/type info that will lead to crashes in lowering.

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

2 years ago[flang][NFC] Add tests for fir.address_of
Valentin Clement [Mon, 4 Apr 2022 07:25:28 +0000 (09:25 +0200)]
[flang][NFC] Add tests for fir.address_of

This patch adds FIR to LLVM test for fir.address_of.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[ELF][test] Fix RUN lines in lto/sample-profile.ll
Fangrui Song [Mon, 4 Apr 2022 06:57:31 +0000 (23:57 -0700)]
[ELF][test] Fix RUN lines in lto/sample-profile.ll

Reported at https://github.com/llvm/llvm-project/issues/54679#issuecomment-1086862116

2 years ago[M68k] Adopt VarLenCodeEmitter for shift / rotate instructions
Min-Yih Hsu [Fri, 17 Dec 2021 03:34:36 +0000 (11:34 +0800)]
[M68k] Adopt VarLenCodeEmitter for shift / rotate instructions

This patch is covered by existing MC tests.

2 years ago[M68k][test] Remove redundant CHECK-LABEL directive
Min-Yih Hsu [Mon, 4 Apr 2022 05:39:20 +0000 (22:39 -0700)]
[M68k][test] Remove redundant CHECK-LABEL directive

The associated test had a redundant CHECK-LABEL directive that might fail
the test since the inception, but this issue was "burried" by a missing
colon, which was addressed in fb65aaf0be09936e657d339f3dc8e62666a41956.
Thus, the test finally failed after the said commit.

This patch remove that CHECK-LABEL directive.

2 years agoReland "[lit] Use sharding for GoogleTest format"
Yuanfang Chen [Mon, 4 Apr 2022 03:14:26 +0000 (20:14 -0700)]
Reland "[lit] Use sharding for GoogleTest format"

This relands commit a87ba5c86d5d72defdbcdb278baad6515ec99463.

Adjust llvm/utils/lit/tests/googletest-timeout.py for new test output.

2 years ago[Support/BLAKE3] CMake: Remove the workaround that checks for "CC=ccache /path/to...
Argyrios Kyrtzidis [Mon, 4 Apr 2022 04:02:02 +0000 (21:02 -0700)]
[Support/BLAKE3] CMake: Remove the workaround that checks for "CC=ccache /path/to/clang"

The LLVM builders that were doing that have been updated to use "-DLLVM_CCACHE_BUILD=ON" instead.

2 years agoAttributorAttributes: guard against TLI being nullptr
Augie Fackler [Thu, 31 Mar 2022 18:46:51 +0000 (14:46 -0400)]
AttributorAttributes: guard against TLI being nullptr

I didn't dig into this very much because it appears to be totally valid
(especially once these properties can come from attributes instead
of only from hard-coded library functions) for TLI to not be defined,
and nothing broke when I added this check, including with all my other
patches applied.

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

2 years agoCallBase: fix getFnAttr so it also checks the function
Augie Fackler [Thu, 31 Mar 2022 14:30:26 +0000 (10:30 -0400)]
CallBase: fix getFnAttr so it also checks the function

Prior to this change, CallBase::hasFnAttr checked the called function to
see if it had an attribute if it wasn't set on the CallBase, but
getFnAttr didn't do the same delegation, which led to very confusing
behavior. This patch fixes the issue by making CallBase::getFnAttr also
check the function under the same circumstances.

Test changes look (to me) like they're cleaning up redundant attributes
which no longer get specified both on the callee and call. We also clean
up the one ad-hoc implementation of this getter over in InlineCost.cpp.

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

2 years ago[LV] Handle non-integral types when considering interleave widening legality
Philip Reames [Mon, 4 Apr 2022 03:09:03 +0000 (20:09 -0700)]
[LV] Handle non-integral types when considering interleave widening legality

In general, anywhere we might need to insert a blind bitcast, we need to make sure the types are losslessly convertible.

This fixes pr54634.

2 years ago[memcpyopt] Restructure store(load src, dest) form of callslotopt for compile time
Philip Reames [Tue, 29 Mar 2022 03:29:41 +0000 (20:29 -0700)]
[memcpyopt] Restructure store(load src, dest) form of callslotopt for compile time

The search for the clobbering call is fairly expensive if uses are not optimized at construction.  Defer the clobber walk to the point in the implementation we need it; there are a bunch of bailouts before that point.  (e.g. If the source pointer is not an alloca, we can't do callslotopt.)

On a test case which involves a bunch of copies from argument pointers, this switches memcpyopt from > 1/2 second to < 10ms.

2 years agoRevert "[lit] Use sharding for GoogleTest format"
Yuanfang Chen [Mon, 4 Apr 2022 03:04:55 +0000 (20:04 -0700)]
Revert "[lit] Use sharding for GoogleTest format"

This reverts commit a87ba5c86d5d72defdbcdb278baad6515ec99463.

Breaks bots:
https://lab.llvm.org/buildbot/#/builders/196/builds/10454

2 years ago[lit] Use sharding for GoogleTest format
Yuanfang Chen [Sat, 2 Apr 2022 19:28:23 +0000 (12:28 -0700)]
[lit] Use sharding for GoogleTest format

This helps lit unit test performance by a lot, especially on windows. The performance gain comes from launching one gtest executable for many subtests instead of one (this is the current situation).

The shards are executed by the test runner and the results are stored in the
json format supported by the GoogleTest. Later in the test reporting stage,
all test results in the json file are retrieved to continue the test results
summary etc.

On my Win10 desktop, before this patch: `check-clang-unit`: 177s, `check-llvm-unit`: 38s; after this patch: `check-clang-unit`: 37s, `check-llvm-unit`: 11s.
On my Linux machine, before this patch: `check-clang-unit`: 46s, `check-llvm-unit`: 8s; after this patch: `check-clang-unit`: 7s, `check-llvm-unit`: 4s.

Reviewed By: yln, rnk

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

2 years agoCorrect spelling error in TLS-Load-Hoist
Xiang1 Zhang [Mon, 4 Apr 2022 00:27:28 +0000 (08:27 +0800)]
Correct spelling error in TLS-Load-Hoist

2 years agoRevert "[NFCI] Regenerate SROA/LoopVectorize test checks"
Dávid Bolvanský [Sun, 3 Apr 2022 23:14:34 +0000 (01:14 +0200)]
Revert "[NFCI] Regenerate SROA/LoopVectorize test checks"

This reverts commit 14e3450fb57305aa9ff3e9e60687b458e43835c9.

2 years ago[NFCI] Regenerate SROA test checks
Dávid Bolvanský [Sun, 3 Apr 2022 22:55:54 +0000 (00:55 +0200)]
[NFCI] Regenerate SROA test checks

2 years ago[NFCI] Regenerate PhaseOrdering test checks
Dávid Bolvanský [Sun, 3 Apr 2022 22:28:57 +0000 (00:28 +0200)]
[NFCI] Regenerate PhaseOrdering test checks

2 years ago[NFCI] Regenerate LoopIdiomRecognize test checks
Dávid Bolvanský [Sun, 3 Apr 2022 22:21:00 +0000 (00:21 +0200)]
[NFCI] Regenerate LoopIdiomRecognize test checks

2 years agoRevert "[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs"
Nico Weber [Sun, 3 Apr 2022 21:21:06 +0000 (17:21 -0400)]
Revert "[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs"

This reverts commit 4cf98f973a13c5049322abff43f0dff3c214311b.
The test fails on mac bots, see comments on https://reviews.llvm.org/D122820

Also reverts follow-ups eb920989865d992093993143ba3c6e71126cbb89 and
861c189d2a5203ba8c8e983e8d2e109c0de153a5.

2 years ago[AArch64] Remove unsued WideningBaseCost. NFC
David Green [Sun, 3 Apr 2022 21:16:39 +0000 (22:16 +0100)]
[AArch64] Remove unsued WideningBaseCost. NFC

The WideningBaseCost is always 0. This removes it to clean up the code.

2 years ago[libc++] Remove unused <iosfwd> include from <__debug>
Louis Dionne [Sun, 3 Apr 2022 16:40:39 +0000 (12:40 -0400)]
[libc++] Remove unused <iosfwd> include from <__debug>

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

2 years ago[NFCI] Regenerate LoopVectorize test checks
Dávid Bolvanský [Sun, 3 Apr 2022 19:55:58 +0000 (21:55 +0200)]
[NFCI] Regenerate LoopVectorize test checks

2 years ago[IR] Remove unused forward declarations (NFC)
Kazu Hirata [Sun, 3 Apr 2022 19:54:54 +0000 (12:54 -0700)]
[IR] Remove unused forward declarations (NFC)

2 years ago[NFCI] Regenerate instsimplify test checks
Dávid Bolvanský [Sun, 3 Apr 2022 18:54:13 +0000 (20:54 +0200)]
[NFCI] Regenerate instsimplify test checks

2 years ago[libc++][NFC] Fix weird indentation in test
Louis Dionne [Sun, 3 Apr 2022 16:47:21 +0000 (12:47 -0400)]
[libc++][NFC] Fix weird indentation in test

2 years ago[BOLT] AArch64: Read all static relocations
Vladislav Khmelevsky [Sun, 20 Mar 2022 14:15:56 +0000 (17:15 +0300)]
[BOLT] AArch64: Read all static relocations

Read static relocs on the same address, as dynamic in order to update
constant island data address properly.

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

2 years agoRevert "[Flang][OpenMP] Add semantic check for OpenMP Private, Firstprivate and Lastp...
Kiran Chandramohan [Sun, 3 Apr 2022 15:23:54 +0000 (15:23 +0000)]
Revert "[Flang][OpenMP] Add semantic check for OpenMP Private, Firstprivate and Lastprivate clauses."

This reverts commit a2ca6bbda6160c1b474fffd6204bcac9456c7eb1.

D93213 performs some checks to ensure that variables that appear in
statement functions are not in privatisation clauses. The point at
which this check is currently performed, there can be misparses that
cause more constructs to be identified as statement functions. This
can lead to various kinds of errors, hence reverting.

This revert hopefully fixes:
https://github.com/llvm/llvm-project/issues/54477
https://github.com/llvm/llvm-project/issues/54161
https://github.com/llvm/llvm-project/issues/54163

Reviewed By: shraiysh

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

2 years ago[lldb][gui] underline the current token
Luboš Luňák [Sun, 3 Apr 2022 15:32:11 +0000 (17:32 +0200)]
[lldb][gui] underline the current token

Just like the non-gui listing already does.

2 years ago[lldb][gui] use symbolic names rather than hardcoded values
Luboš Luňák [Sun, 3 Apr 2022 15:01:54 +0000 (17:01 +0200)]
[lldb][gui] use symbolic names rather than hardcoded values

2 years ago[lldb][gui] fix background of syntax-highlighted non-selected PC line
Luboš Luňák [Sun, 3 Apr 2022 14:29:44 +0000 (16:29 +0200)]
[lldb][gui] fix background of syntax-highlighted non-selected PC line

It is the PC line, selected or not, that gets the blue-background
highlight. Without this, a keyword like 'bool' got black background
if the line wasn't selected.
And the blue-background highlight is handled by OutputColoredStringTruncated(),
so no point in setting it explicitly in the calling code.

2 years ago[lldb][gui] draw highlight for selected line even if empty
Luboš Luňák [Sun, 3 Apr 2022 14:08:02 +0000 (16:08 +0200)]
[lldb][gui] draw highlight for selected line even if empty

2 years agoRevert "Apply clang-tidy fixes for readability-redundant-declaration in Debug.cpp...
Kazu Hirata [Sun, 3 Apr 2022 15:14:11 +0000 (08:14 -0700)]
Revert "Apply clang-tidy fixes for readability-redundant-declaration in Debug.cpp (NFC)"

This reverts commit 0fe01a9346658c0955b68b123f2b470b018114b1.

The commit caused build failures like:

  llvm/lib/Support/Debug.cpp:65:3: error: ‘setCurrentDebugTypes’ was
  not declared in this scope; did you mean ‘setCurrentDebugType’?

2 years ago[gn build] Port e476df5629ee
LLVM GN Syncbot [Sun, 3 Apr 2022 15:09:33 +0000 (15:09 +0000)]
[gn build] Port e476df5629ee

2 years ago[libc++][ranges] Implement ranges::max
Nikolas Klauser [Sun, 3 Apr 2022 07:17:01 +0000 (09:17 +0200)]
[libc++][ranges] Implement ranges::max

Reviewed By: Mordante, var-const, #libc

Spies: sstefan1, libcxx-commits, mgorny

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

2 years agoApply clang-tidy fixes for readability-redundant-declaration in Debug.cpp (NFC)
Kazu Hirata [Sun, 3 Apr 2022 15:04:12 +0000 (08:04 -0700)]
Apply clang-tidy fixes for readability-redundant-declaration in Debug.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-redundant-member-init in YAMLParser.cpp (NFC)
Kazu Hirata [Sun, 3 Apr 2022 15:04:11 +0000 (08:04 -0700)]
Apply clang-tidy fixes for readability-redundant-member-init in YAMLParser.cpp (NFC)

2 years ago[clang-tidy] Add release notes for changes made in 2b21fc5520b39fba555f4e5f2480a56510...
Danny Mösch [Sun, 3 Apr 2022 13:48:39 +0000 (15:48 +0200)]
[clang-tidy] Add release notes for changes made in 2b21fc5520b39fba555f4e5f2480a5651056be84

2 years ago[flang][NFC] Add tests for fir.array_modify in array-value-copy pass
Valentin Clement [Sun, 3 Apr 2022 13:25:36 +0000 (15:25 +0200)]
[flang][NFC] Add tests for fir.array_modify in array-value-copy pass

This patch adds some test for the `fir.array_modify` operation
in the array-value-copy pass

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang][NFC] Add more test cases for the array-value-copy pass
Valentin Clement [Sun, 3 Apr 2022 13:24:20 +0000 (15:24 +0200)]
[flang][NFC] Add more test cases for the array-value-copy pass

This patch adds some test cases for the array-value-copy pass with slices.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang][NFC] Add tests for fir.is_present
Valentin Clement [Sun, 3 Apr 2022 13:21:42 +0000 (15:21 +0200)]
[flang][NFC] Add tests for fir.is_present

This patch adds tests for the `fir.is_present`
translation.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang] Add global and global box initialization tests
Valentin Clement [Sun, 3 Apr 2022 13:19:38 +0000 (15:19 +0200)]
[flang] Add global and global box initialization tests

This patch addes some global initialization and global
box initialization tests.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang][NFC] Add tests for select constructs
Valentin Clement [Sun, 3 Apr 2022 13:17:21 +0000 (15:17 +0200)]
[flang][NFC] Add tests for select constructs

Add tests for fir.select_rank and
fir.select_case.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoReapply "[InstSimplify][NFC] Add baseline tests for folds of icmp with ctpop"
Hirochika Matsumoto [Sun, 3 Apr 2022 13:05:18 +0000 (22:05 +0900)]
Reapply "[InstSimplify][NFC] Add baseline tests for folds of icmp with ctpop"

This change was previously reverted because I forgot rerunning
update_test_checks.py and tests were not actually baseline.

Extracted from: https://reviews.llvm.org/D122757

2 years ago[libunwind] Add missing licenses in test files
Louis Dionne [Sun, 3 Apr 2022 12:55:57 +0000 (08:55 -0400)]
[libunwind] Add missing licenses in test files

2 years ago[NFCI] Fixed missing colon in CHECK directives - part 2
Dávid Bolvanský [Sun, 3 Apr 2022 12:42:35 +0000 (14:42 +0200)]
[NFCI] Fixed missing colon in CHECK directives - part 2

2 years ago[C++20][Modules] Fix a testcase warning on Windows [NFC].
Iain Sandoe [Sun, 3 Apr 2022 08:50:20 +0000 (09:50 +0100)]
[C++20][Modules] Fix a testcase warning on Windows [NFC].

As reported, using "-DTDIR=%t" with a path name of 'C:\Users\...' causes
a warning to be emitted about the use of \U without following hex digits.

Since the value is only required for the FileCheck cases resolve this by
omitting the -D from the compile lines.

2 years ago[NFCI] Fixed missing colon in CHECK directives
Dávid Bolvanský [Sun, 3 Apr 2022 09:51:33 +0000 (11:51 +0200)]
[NFCI] Fixed missing colon in CHECK directives

2 years ago[X86] lowerShuffleAsRepeatedMaskAndLanePermute - allow v16i32 sub-lane permutes for...
Simon Pilgrim [Sun, 3 Apr 2022 09:05:10 +0000 (10:05 +0100)]
[X86] lowerShuffleAsRepeatedMaskAndLanePermute - allow v16i32 sub-lane permutes for v64i8 shuffles

Without VBMI, we are better off permuting v16i32 sub-lanes, even though its a variable shuffle, if it allows us to then shuffle v64i8 inlane repeated masks (PSHUFB etc.)

Fixes #54658

2 years ago[InstCombine] Fold srem(X, PowerOf2) == C into (X & Mask) == C for positive C
Alexander Shaposhnikov [Sun, 3 Apr 2022 03:57:05 +0000 (03:57 +0000)]
[InstCombine] Fold srem(X, PowerOf2) == C into (X & Mask) == C for positive C

This diff extends InstCombinerImpl::foldICmpSRemConstant to handle the cases
srem(X, PowerOf2) == C and
srem(X, PowerOf2) != C
for positive C.
This addresses the issue https://github.com/llvm/llvm-project/issues/54650

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

Test plan: make check-all

2 years ago[InstCombine][NFC] Add baseline tests for folds of srem(X, PowerOf2) == C
Alexander Shaposhnikov [Sun, 3 Apr 2022 03:26:47 +0000 (03:26 +0000)]
[InstCombine][NFC] Add baseline tests for folds of srem(X, PowerOf2) == C

Extracted from: https://reviews.llvm.org/D122942

Test plan: make check-all

2 years ago[InstCombine] limit icmp fold with sub if other sub user is a phi
Sanjay Patel [Sat, 2 Apr 2022 23:23:42 +0000 (19:23 -0400)]
[InstCombine] limit icmp fold with sub if other sub user is a phi

This is a hacky fix for:
https://github.com/llvm/llvm-project/issues/54558

As discussed there, codegen regressed when we opened up this transform
to allow extra uses ( 61580d0949fd3465 ), and it's not clear how to
undo the transforms at the later stage of compilation.

As noted in the code comments, there's a set of remaining folds that
are still limited to one-use, so we can try harder to refine and
expand the limitations on these folds, but it's likely to be an
up-and-down battle as we find and overcome similar regressions.

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

2 years ago[InstCombine] fold fcmp with lossy casted constant (2nd try)
Sanjay Patel [Sat, 2 Apr 2022 22:52:18 +0000 (18:52 -0400)]
[InstCombine] fold fcmp with lossy casted constant (2nd try)

This is a retry of 9397bdc67eb2 - that was reverted until
we had a clang warning in place to alert users about a
possible mistake in source. The warning was added with
ab982eace6e4.

This is noted as a missing clang warning in #54222,
but it is also a missing optimization opportunity.

Alive2 proofs:
https://alive2.llvm.org/ce/z/Q8drDq
https://alive2.llvm.org/ce/z/pE6LRt

I don't see a single conversion for all predicates
using "getFCmpCode" logic, so other predicates are
left as a TODO item.

2 years ago[MLIR][Presburger] Use PresburgerSpace in SetCoalescer
Groverkss [Sat, 2 Apr 2022 22:36:11 +0000 (04:06 +0530)]
[MLIR][Presburger] Use PresburgerSpace in SetCoalescer

This patch changes the implementation of SetCoalescer to use PresburgerSpace
instead of reimplementing parts of PresburgerSpace.

Reviewed By: arjunp

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

2 years ago[InstCombine] Fold `(X | C2) ^ C1 --> (X & ~C2) ^ (C1^C2)`
Roman Lebedev [Sat, 2 Apr 2022 20:54:33 +0000 (23:54 +0300)]
[InstCombine] Fold `(X | C2) ^ C1 --> (X & ~C2) ^ (C1^C2)`

These two are equivalent,
and i *think* the `and` form is more-ish canonical.

General proof: https://alive2.llvm.org/ce/z/RrF5s6

If constant on the (outer) `xor` is an `undef`,
the whole lane is dead: https://alive2.llvm.org/ce/z/mu4Sh2

However, if the constant on the (inner) `or` is an `undef`,
we must sanitize it first: https://alive2.llvm.org/ce/z/MHYJL7
I guess, producing a zero `and`-mask is optimal in that case.

alive-tv is happy about the entirety of `xor-of-or.ll`.

2 years ago[NFC][InstCombine] Autogenerate check lines in a test affected by the future change
Roman Lebedev [Sat, 2 Apr 2022 21:03:15 +0000 (00:03 +0300)]
[NFC][InstCombine] Autogenerate check lines in a test affected by the future change

2 years ago[NFC][InstCombine] Add some tests for `(X | C2) ^ C1` pattern
Roman Lebedev [Sat, 2 Apr 2022 20:04:44 +0000 (23:04 +0300)]
[NFC][InstCombine] Add some tests for `(X | C2) ^ C1` pattern

2 years ago[Support] [BLAKE3] Fix compilation with CMAKE_OSX_ARCHITECTURES
Martin Storsjö [Fri, 1 Apr 2022 08:50:25 +0000 (11:50 +0300)]
[Support] [BLAKE3] Fix compilation with CMAKE_OSX_ARCHITECTURES

With CMake, one can build for multiple macOS architectures
at the same time by setting CMAKE_OSX_ARCHITECTURES to multiple
architectures (avoiding needing to do two separate builds and
gluing the binaries together after the build).

In this case, while targeting x86_64 and arm64, neither IS_X64
nor IS_ARM64 is set, while compilation of the individual source
files will hit those cases (in either architecture mode).

Therefore, if we on the CMake level decide not to include the
architecture specific SIMD implementation files, also tell the
source this explicitly by passing the defines indicating that we
don't expect to use them.

Such a build clearly is less ideal than explicitly targeting one
architecture at a time if it won't include all the SIMD optimizations,
but that's a tradeoff that is up to the one deciding to do such an
universal build.

This also fixes builds for i386. The blake3 source code automatically
enables the SIMD implementations when building for i386, but we don't
provide the sources for that build configuration.

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

2 years ago[Support] [BLAKE3] Remove .hidden directives from windows-gnu assembly sources
Martin Storsjö [Fri, 1 Apr 2022 11:29:54 +0000 (14:29 +0300)]
[Support] [BLAKE3] Remove .hidden directives from windows-gnu assembly sources

COFF symbols don't have anything corresponding to a `.hidden` flag;
both GNU binutils as and LLVM's built-in assembler errors out on
these directives.

This reverts one part of
7f05aa2d4c36d6d53f97ac3e0db30ec600abbc62, fixing builds for
mingw x86_64.

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

2 years ago[VPlan] Set VPlan header block name to vector.body.
Florian Hahn [Sat, 2 Apr 2022 18:33:58 +0000 (19:33 +0100)]
[VPlan] Set VPlan header block name to vector.body.

This brings the VPlan block naming in line with the naming of the
generated basic blocks.

2 years ago[MLIR][Presburger][NFC] Rename getCompatibleSpace to getSpaceWithoutLocals
Groverkss [Sat, 2 Apr 2022 18:09:57 +0000 (23:39 +0530)]
[MLIR][Presburger][NFC] Rename getCompatibleSpace to getSpaceWithoutLocals

Reviewed By: arjunp

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

2 years ago[trace][intel pt] Handle better tsc in the decoder
Walter Erquinigo [Fri, 1 Apr 2022 04:13:03 +0000 (21:13 -0700)]
[trace][intel pt] Handle better tsc in the decoder

A problem that I introduced in the decoder is that I was considering TSC decoding
errors as actual instruction errors, which mean that the trace has a gap. This is
wrong because a TSC decoding error doesn't mean that there's a gap in the trace.
Instead, now I'm just counting how many of these errors happened and I'm using
the `dump info` command to check for this number.

Besides that, I refactored the decoder a little bit to make it simpler, more
readable, and to handle TSCs in a cleaner way.

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

2 years agoRevert "[InstSimplify][NFC] Add baseline tests for folds of icmp with ctpop"
Hirochika Matsumoto [Sat, 2 Apr 2022 17:27:59 +0000 (02:27 +0900)]
Revert "[InstSimplify][NFC] Add baseline tests for folds of icmp with ctpop"

This reverts commit b48abeea44ac3c7860b13b863210116e8db1d978.

Accidentally added already optimized tests, not baseline tests.

2 years ago[InstSimplify][NFC] Add baseline tests for folds of icmp with ctpop
Hirochika Matsumoto [Sat, 2 Apr 2022 17:14:51 +0000 (02:14 +0900)]
[InstSimplify][NFC] Add baseline tests for folds of icmp with ctpop

Extracted from: https://reviews.llvm.org/D122757

2 years ago[ConstraintElimination] Move logic to build worklist to helper (NFC).
Florian Hahn [Sat, 2 Apr 2022 15:55:04 +0000 (16:55 +0100)]
[ConstraintElimination] Move logic to build worklist to helper (NFC).

This refactor makes it easier to extend the logic to collect information
from blocks in the future, without even further increasing the size of
eliminateConstriants.

2 years ago[Driver][AArch64] Split up aarch64-cpus.c tests further
tyb0807 [Mon, 7 Mar 2022 10:17:00 +0000 (10:17 +0000)]
[Driver][AArch64] Split up aarch64-cpus.c tests further

This is the continuation of https://reviews.llvm.org/D120875. Now
aarch64-cpus-[12].c are further splitted and renamed to better reflect
the tests.

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

2 years ago[AArch64] Avoid scanning feature list for target parsing
tyb0807 [Thu, 3 Mar 2022 02:12:00 +0000 (02:12 +0000)]
[AArch64] Avoid scanning feature list for target parsing

As discussed in https://reviews.llvm.org/D120111, this patch proposes an
alternative implementation to avoid scanning feature list for
architecture version over and over again. The insertion position for
default extensions is also captured during this single scan of the
feature list.

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

2 years ago[AArch64] Default HBC/MOPS features in clang
tyb0807 [Tue, 1 Feb 2022 13:37:43 +0000 (13:37 +0000)]
[AArch64] Default HBC/MOPS features in clang

This implements minimum support in clang for default HBC/MOPS features
on v8.8-a/v9.3-a or later architectures.

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

2 years agoRevert "[AMDPU][Sanitizer] Refactor sanitizer options handling for AMDGPU Toolchain"
Ron Lieberman [Sat, 2 Apr 2022 13:25:50 +0000 (13:25 +0000)]
Revert "[AMDPU][Sanitizer] Refactor sanitizer options handling for AMDGPU Toolchain"

This reverts commit cc2139524f77248c7e147d4cc3befb31fe3e6daa.

failed a few buildbots

2 years ago[MLIR][Presburger] Make constructors from PresburgerSpace explicit
Groverkss [Sat, 2 Apr 2022 12:44:38 +0000 (18:14 +0530)]
[MLIR][Presburger] Make constructors from PresburgerSpace explicit

This patch makes constructors of IntegerRelation, IntegerPolyhedron,
PresburgerRelation, PresburgerSet from PresburgerSpace explicit. This
prevents bugs like:

```
void fun(IntegerRelation a, IntegerRelation b) {
  IntegerPolyhedron c = a.intersect(b);
}
```

Here, `a.intersect(b)` will return `IntegerRelation`, which will be implicitly
converted to `PresburgerSpace` and will use the `PresburgerSpace` constructor
for IntegerPolyhedron. Leading to loss of any constraints in the intersection
of `a` and `b`. After this patch, this will give a compile error.

Reviewed By: arjunp

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

2 years ago[AMDPU][Sanitizer] Refactor sanitizer options handling for AMDGPU Toolchain
Ron Lieberman [Sat, 2 Apr 2022 11:01:04 +0000 (11:01 +0000)]
[AMDPU][Sanitizer] Refactor sanitizer options handling for AMDGPU Toolchain

authored by amit.pandey@amd.com  ampandey-AMD

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

2 years ago[MLIR][Presburger] LexSimplex: support is{Redundant,Separate}Inequality
Arjun P [Fri, 1 Apr 2022 17:46:52 +0000 (18:46 +0100)]
[MLIR][Presburger] LexSimplex: support is{Redundant,Separate}Inequality

Add integer-exact checks for inequalities being separate and redundant in LexSimplex.

Reviewed By: Groverkss

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

2 years ago[MLIR][Presburger] Make the SimplexBase constructor protected
Arjun P [Thu, 31 Mar 2022 12:19:37 +0000 (13:19 +0100)]
[MLIR][Presburger] Make the SimplexBase constructor protected

This is not supposed to be instantiated directly anyway.

Reviewed By: Groverkss

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

2 years ago[LoongArch] Fix instruction definition
wanglei [Sat, 2 Apr 2022 10:07:22 +0000 (18:07 +0800)]
[LoongArch] Fix instruction definition

This patch fixes issue with the LU32I_D instruction, which did not have
an input register operand.

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

2 years agoRemove duplicate code from wouldInstructionBeTriviallyDead
Serge Pavlov [Sat, 2 Apr 2022 06:30:20 +0000 (13:30 +0700)]
Remove duplicate code from wouldInstructionBeTriviallyDead

There is a similar check few lines above in this function.

2 years ago[lld][COFF] Fix TypeServerSource lookup on GUID collisions
Tobias Hieta [Thu, 24 Mar 2022 15:07:39 +0000 (16:07 +0100)]
[lld][COFF] Fix TypeServerSource lookup on GUID collisions

Microsoft shipped a bunch of PDB files with broken/invalid GUIDs
which lead lld to use 0xFF as the key for these files in an internal
cache. When multiple files have this key it will lead to collisions
and confused symbol lookup.

Several approaches to fix this was considered. Including making the key
the path to the PDB file, but this requires some filesystem operations
in order to normalize the file path.

Since this only happens with malformatted PDB files and we haven't
seen this before they malformatted files where shipped with visual
studio we probably shouldn't optimize for this use-case.

Instead we now just don't insert files with Guid == 0xFF into the
cache map and warn if we get collisions so similar problems can be
found in the future instead of being silent.

Discussion about the root issue and the approach to this fix can be found on Github: https://github.com/llvm/llvm-project/issues/54487

Reviewed By: aganea

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

2 years ago[mlir] Allow for using OpPassManager in pass options
River Riddle [Fri, 1 Apr 2022 05:34:00 +0000 (22:34 -0700)]
[mlir] Allow for using OpPassManager in pass options

This significantly simplifies the boilerplate necessary for passes
to define nested pass pipelines.

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

2 years ago[mlir:PassOption] Rework ListOption parsing and add support for std::vector/SmallVect...
River Riddle [Fri, 1 Apr 2022 07:55:35 +0000 (00:55 -0700)]
[mlir:PassOption] Rework ListOption parsing and add support for std::vector/SmallVector options

ListOption currently uses llvm::cl::list under the hood, but the usages
of ListOption are generally a tad different from llvm::cl::list. This
commit codifies this by making ListOption implicitly comma separated,
and removes the explicit flag set for all of the current list options.
The new parsing for comma separation of ListOption also adds in support
for skipping over delimited sub-ranges (i.e. {}, [], (), "", ''). This
more easily supports nested options that use those as part of the
format, and this constraint (balanced delimiters) is already codified
in the syntax of pass pipelines.

See https://discourse.llvm.org/t/list-of-lists-pass-option/5950 for
related discussion

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

2 years ago[libc++] Canonicalize the ranges results and their tests
Nikolas Klauser [Thu, 31 Mar 2022 05:06:49 +0000 (07:06 +0200)]
[libc++] Canonicalize the ranges results and their tests

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

Spies: ldionne, libcxx-commits

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

2 years ago[clang][Sparc] Enable IAS on the remaining OS's
Brad Smith [Sat, 2 Apr 2022 06:18:30 +0000 (02:18 -0400)]
[clang][Sparc] Enable IAS on the remaining OS's

2 years ago[X86][AMX] enable amx cast intrinsics in FE.
Luo, Yuanke [Thu, 17 Mar 2022 14:48:33 +0000 (22:48 +0800)]
[X86][AMX] enable amx cast intrinsics in FE.

We have some discission in D99152 and llvm-dev and finially come up with
a solution to add amx specific cast intrinsics. We've support the
intrinsics in llvm IR. This patch is to replace bitcast with amx cast
intrinsics in code emitting in FE.

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

2 years ago[libc][NFC] Do not call mmap and munmap from thread functions.
Siva Chandra Reddy [Fri, 1 Apr 2022 07:33:34 +0000 (07:33 +0000)]
[libc][NFC] Do not call mmap and munmap from thread functions.

Instead, memory is allocated and deallocated using mmap and munmap
syscalls directly.

Reviewed By: lntue, michaelrj

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

2 years ago[cmake] Remove LLVM_USE_NEWPM option
Arthur Eubanks [Fri, 1 Apr 2022 23:40:46 +0000 (16:40 -0700)]
[cmake] Remove LLVM_USE_NEWPM option

This option tells the host clang to use the new pass manager.
Given that it's been the default for a while, this seems unnecessary.

This was added in D57068.

(this does not affect any LLVM/Clang functionality)

Reviewed By: MaskRay

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

2 years ago[mlir][Vector] Add constant folder for extractelement.
jacquesguan [Fri, 1 Apr 2022 09:21:12 +0000 (17:21 +0800)]
[mlir][Vector] Add constant folder for extractelement.

This revision adds constant folder for vector.extractelement.

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

2 years ago[AIX] XFAIL tests because of no big archive writer operation support
Jake Egan [Sat, 2 Apr 2022 02:38:43 +0000 (22:38 -0400)]
[AIX] XFAIL tests because of no big archive writer operation support

Big archive writer operation is not currently supported so mark these tests XFAIL for now.

Reviewed By: jsji

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

2 years ago[mlir][Vector] Add constant folder for insertelement.
jacquesguan [Wed, 30 Mar 2022 11:14:00 +0000 (19:14 +0800)]
[mlir][Vector] Add constant folder for insertelement.

This revision adds constant folder for vector.insertelement.

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

2 years ago[RISCV] Add lowering for vp.fptoui and vp.uitofp.
Craig Topper [Sat, 2 Apr 2022 01:28:08 +0000 (18:28 -0700)]
[RISCV] Add lowering for vp.fptoui and vp.uitofp.

This is a straightforward extension of D122512 to unsigned integers.

2 years ago[lldb] Remove remaining calls to DataBufferLLVM::GetChars
Jonas Devlieghere [Sat, 2 Apr 2022 00:41:36 +0000 (17:41 -0700)]
[lldb] Remove remaining calls to DataBufferLLVM::GetChars

Update the Linux and NetBSD Host libraries for 2165c36be445 which
removed DataBufferLLVM::GetChars. These files are compiled conditionally
based on the host platform.

2 years ago[lldb] Return a DataBuffer from FileSystem::CreateDataBuffer (NFC)
Jonas Devlieghere [Thu, 31 Mar 2022 22:16:29 +0000 (15:16 -0700)]
[lldb] Return a DataBuffer from FileSystem::CreateDataBuffer (NFC)

The concrete class (DataBufferLLVM) is an implementation detail.

2 years ago[clang-format] Fix a crash in qualifier alignment
Owen Pan [Wed, 30 Mar 2022 18:50:52 +0000 (11:50 -0700)]
[clang-format] Fix a crash in qualifier alignment

Related to #54513.

2 years ago[BOLT][test] Fix AArch64 cross-platform tests
Maksim Panchenko [Fri, 1 Apr 2022 23:43:21 +0000 (16:43 -0700)]
[BOLT][test] Fix AArch64 cross-platform tests

Use target-specific flags for building AArch64 non-runnable tests.

Reviewed By: yota9

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

2 years ago[debug-info] As an NFC commit, refactor EmitFuncArgumentDbgValue so that it can be...
Michael Gottesman [Fri, 1 Apr 2022 22:57:52 +0000 (15:57 -0700)]
[debug-info] As an NFC commit, refactor EmitFuncArgumentDbgValue so that it can be extended to support llvm.dbg.addr.

The reason why I am making this change is that before this commit,
EmitFuncArgumentDbgValue relied on a boolean flag IsDbgDeclare both to signal
that a DBG_VALUE should be made to be indirect /and/ that the original intrinsic
was a dbg.declare. This is no longer always true if we add support for handling
dbg.addr since we will have an indirect DBG_VALUE that is a different intrinsic
from dbg.declare.

With that in mind, in this NFC patch, we prepare for future fixes by introducing
a 3 case-enum argument to EmitFuncArgumentDbgValue that allows the caller to
explicitly specify how the argument's DBG_VALUE should be emitted. This then
allows us to turn the indirect checks into a != FuncArgumentDbgValueKind::Value
and prepare us for a future where we add support here for llvm.dbg.addr
directly.

rdar://83957028

Reviewed By: aprantl

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

2 years ago[NFCI] clang-format SanitizerArgs.cpp
Mitch Phillips [Fri, 1 Apr 2022 23:26:55 +0000 (16:26 -0700)]
[NFCI] clang-format SanitizerArgs.cpp

2 years ago[mlir] Switch debugString helper to << operator
Jacques Pienaar [Fri, 1 Apr 2022 23:33:35 +0000 (16:33 -0700)]
[mlir] Switch debugString helper to << operator

Supports more cases.