platform/upstream/llvm.git
2 years ago[mlir][sparse] bazel correction after filename change
Aart Bik [Tue, 2 Nov 2021 21:05:51 +0000 (14:05 -0700)]
[mlir][sparse] bazel correction after filename change

Reviewed By: GMNGeoffrey, rdzhabarov

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

2 years ago[sanitizer_common] Fix readlink error handling in sanitizer_procmaps_solaris.cpp
Rich Lowe [Tue, 2 Nov 2021 21:06:17 +0000 (22:06 +0100)]
[sanitizer_common] Fix readlink error handling in sanitizer_procmaps_solaris.cpp

As pointed out in Bug 52371, the Solaris version of
`MemoryMappingLayout::Next` completely failed to handle `readlink` errors
or properly NUL-terminate the result.

This patch fixes this.  Originally provided in the PR with slight
formatting changes.

Tested on `amd64-pc-solaris2.11`.

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

2 years agoRevert "[clang] deprecate frelaxed-template-template-args, make it on by default"
Yaxun (Sam) Liu [Tue, 2 Nov 2021 20:24:04 +0000 (16:24 -0400)]
Revert "[clang] deprecate frelaxed-template-template-args, make it on by default"

This reverts commit 2d7fba5f95f0614f6f2c4a4ed966b307d617898b.

The patch was reverted because it caused regression with rocThrust
due to ambiguity of template specialization.

For details please see https://reviews.llvm.org/D109496

2 years agoRevert "[lld-macho] Change bitfield types to be identical."
Vy Nguyen [Tue, 2 Nov 2021 20:57:51 +0000 (16:57 -0400)]
Revert "[lld-macho] Change bitfield types to be identical."

This reverts commit ae31f9fbaddd57a3c1c63bfd7baf1511122a49f7.

Reason: bitfields can't be merged across parent/child classes anyway. So this change doesn't help.

2 years ago[mlir][sparse] Rename SparseUtils.cpp file to SparseTensorUtils.cpp
HarrietAkot [Tue, 2 Nov 2021 20:29:56 +0000 (13:29 -0700)]
[mlir][sparse] Rename SparseUtils.cpp file to SparseTensorUtils.cpp

Bug 52304 - Rename the sparse runtime support library cpp file

Reviewed By: aartbik

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

2 years ago[BasicAA] Check known access sizes earlier (NFC)
Nikita Popov [Tue, 2 Nov 2021 20:26:26 +0000 (21:26 +0100)]
[BasicAA] Check known access sizes earlier (NFC)

All heuristics for variable accesses require both access sizes to
be known, so check this once at the start, rather than for each
particular heuristic.

2 years ago[BasicAA] Use early returns (NFC)
Nikita Popov [Tue, 2 Nov 2021 20:16:24 +0000 (21:16 +0100)]
[BasicAA] Use early returns (NFC)

Reduce nesting in aliasGEP() a bit by returning early.

2 years ago[X86][AVX] combineConcatVectorOps - use getBROADCAST_LOAD helper for splat of normal...
Simon Pilgrim [Tue, 2 Nov 2021 20:03:11 +0000 (20:03 +0000)]
[X86][AVX] combineConcatVectorOps - use getBROADCAST_LOAD helper for splat of normal vector loads. NFCI.

Reapplied from rG1cfecf4fc427 with fix for PR51226 - ensure the load is a normal (non-ext) load.

2 years ago[libcxx] [test] Remove a LIBCXX-WINDOWS-FIXME, don't test an unsupported strftime...
Martin Storsjö [Fri, 22 Oct 2021 21:54:42 +0000 (00:54 +0300)]
[libcxx] [test] Remove a LIBCXX-WINDOWS-FIXME, don't test an unsupported strftime() pattern

Testing the unsupported pattern can trigger the invalid parameter handler,
which depending on CRT configuration can abort the process.

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

2 years ago[lld-macho] Change bitfield types to be identical.
Vy Nguyen [Tue, 2 Nov 2021 19:14:38 +0000 (15:14 -0400)]
[lld-macho] Change bitfield types to be identical.

Symbol's subclasses all have an additional bitfield of type uint8_t (RefState enum).
For the bitfields in the same block tomerge, they should be of the same type. (clang/gcc will work, but others like MSVC does not)

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

2 years ago[BasicAA] Use saturating multiply on range if nsw
Nikita Popov [Fri, 29 Oct 2021 21:38:44 +0000 (23:38 +0200)]
[BasicAA] Use saturating multiply on range if nsw

If we know that the var * scale multiplication is nsw, we can use
a saturating multiplication on the range (as a good approximation
of an nsw multiply). This recovers some cases where the fix from
D112611 is unnecessarily strict. (This can be further strengthened
by using a saturating add, but we currently don't track all the
necessary information for that.)

This exposes an issue in our NSW tracking for multiplies. The code
was assuming that (X +nsw Y) *nsw Z results in
(X *nsw Z) +nsw (Y *nsw Z) -- however, it is possible that the
distributed multiplications overflow, even if the non-distributed
one does not. We should discard the nsw flag if the the offset is
non-zero. If we just have (X *nsw Y) *nsw Z then concluding
X *nsw (Y *nsw Z) is fine.

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

2 years ago[AIX] Avoid depending on objdump
Jinsong Ji [Tue, 2 Nov 2021 18:57:58 +0000 (18:57 +0000)]
[AIX] Avoid depending on objdump

On AIX, we are currently relying on `objdump` to detemine the
is_32_bit_windows.

`objdump` is not installed by default on AIX, it is creating problem to
depend on it, especially just for an always false detection on AIX.

So this patch simply provide a always false function to satify the
detection.

Reviewed By: #powerpc, daltenty

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

2 years ago[CodeView] Fortran debug info emission in Code View.
Chih-Ping Chen [Fri, 29 Oct 2021 15:46:53 +0000 (11:46 -0400)]
[CodeView] Fortran debug info emission in Code View.

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

2 years agoFix complex types declared using mode TC
Elizabeth Andrews [Mon, 1 Nov 2021 20:28:20 +0000 (13:28 -0700)]
Fix complex types declared using mode TC

This patch reverts incorrect IR introduced in commit d11ec6f67e45
[Clang] Enable IC/IF mode for __ibm128, for complex types declared
using __attribute__((mode(TC))). TC corresponds to an unspecified
128-bit format, which on some targets is a double-double format
(like __ibm128_t) and on others is float128_t. The bug in d11ec6f67e45
is that long double is only safe to use when it's known to be one of
these formats.

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

2 years ago[X86][AVX] Add PR51226 test case
Simon Pilgrim [Tue, 2 Nov 2021 18:56:18 +0000 (18:56 +0000)]
[X86][AVX] Add PR51226 test case

2 years ago[NFC] Reformat VerifyPreservedCFG for non-CPP-aware syntax highlighters
Christopher Tetreault [Tue, 2 Nov 2021 16:53:52 +0000 (09:53 -0700)]
[NFC] Reformat VerifyPreservedCFG for non-CPP-aware syntax highlighters

* Move `);` outside the #ENDIF. Syntax highlighters that highlight missed
  closing parens, but are not aware of the C Preprocessor saw the original
  code as having missed parens.

2 years ago[flang][CodeGen] Transform `fir.unreachable` to `llvm.unreachable`
Andrzej Warzynski [Tue, 2 Nov 2021 10:13:49 +0000 (10:13 +0000)]
[flang][CodeGen] Transform `fir.unreachable` to `llvm.unreachable`

This patch extends the `FIRToLLVMLowering` pass in Flang by adding a
hook to transform `fir.unreachable` to `llvm.unreachable`.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Differential Revision: https://reviews.llvm.org/D113023

2 years ago[InstCombine] Precommit updated and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Tue, 2 Nov 2021 18:13:30 +0000 (11:13 -0700)]
[InstCombine] Precommit updated and-xor-or.ll tests. NFC.

Tests for (~a & b & c) | ~(a | b) -> (c | ~b) & ~a

2 years agoRevert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM"
Med Ismail Bennani [Tue, 2 Nov 2021 18:10:50 +0000 (18:10 +0000)]
Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM"

This reverts commit 6fd2db04d0f22ea22c5317d98ce2126aa64b6a73 since it
broke GreenDragon LLDB-Incremental bot:

https://green.lab.llvm.org/green/job/lldb-cmake/37560/console

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[X86][AVX] combineConcatVectorOps - use getBROADCAST_LOAD helper. NFCI.
Simon Pilgrim [Tue, 2 Nov 2021 17:54:26 +0000 (17:54 +0000)]
[X86][AVX] combineConcatVectorOps - use getBROADCAST_LOAD helper. NFCI.

This is part of rG1cfecf4fc427 that was reverted to fix PR51226 - concating the broadcasts is OK, its the splatted loads that crash (we're not detecting extloads). I'm still creating a reduced test case so haven't added the load handling again yet.

2 years ago[lldb] fix --source-quietly
Lawrence D'Anna [Tue, 2 Nov 2021 18:01:53 +0000 (11:01 -0700)]
[lldb] fix --source-quietly

Jim says:

lldb has a -Q or --source-quietly option, which supposedly does:

    --source-quietly     Tells the debugger to execute this one-line lldb command before any file has been loaded.

That seems like a weird description, since we don't generally use source for one line entries, but anyway, let's try it:

    > $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q "script print('I should be quiet')" a.out -O "script print('I should be before')" -o "script print('I should be after')"
    (lldb) script print('I should be before')
    I should be before
    (lldb) target create "script print('I should be quiet')"
    error: unable to find executable for 'script print('I should be quiet')'

That was weird.  The first real -O gets sourced but not quietly, then the argument to the -Q gets treated as the target.

    > $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q a.out -O "script print('I should be before')" -o "script print('I should be after')"
    (lldb) script print('I should be before')
    I should be before
    (lldb) target create "a.out"
    Current executable set to '/tmp/a.out' (x86_64).
    (lldb) script print('I should be after')
    I should be after

Well, that's a little better, but the -Q option seems to have done nothing.

---

This fixes the description of --source-quietly, as well as causing it
to actually suppress echoing while executing the initialization
commands.

Reviewed By: jingham

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

2 years ago[lld/mac] Write -v output to stderr
Nico Weber [Tue, 2 Nov 2021 14:13:27 +0000 (10:13 -0400)]
[lld/mac] Write -v output to stderr

This matches ld64, and it's conceivable that projects try to read
this information off stderr for that reason.

--version keeps writing to stdout.

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

2 years ago[clang] Fix cmake error
Dave Lee [Tue, 2 Nov 2021 17:45:31 +0000 (10:45 -0700)]
[clang] Fix cmake error

2 years ago[cmake] Make LLVM_ENABLE_LLD=ON work better on macOS
Nico Weber [Tue, 2 Nov 2021 14:35:45 +0000 (10:35 -0400)]
[cmake] Make LLVM_ENABLE_LLD=ON work better on macOS

LLVM_LINKER_IS_LLD is now set with LLVM_ENABLE_LLD=ON (or LLVM_USER_LINKER=lld)
even on APPLE, and we pass -Wl,-order_file when LLVM_LINKER_IS_LLD on APPLE
too.

To make this straightforward, change the linker detection logic to go through
the compiler driver on APPLE like on the other platforms.

No intended behavior change if LLVM_ENABLE_LLD isn't set.

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

2 years ago[RISCV] Rename vfredusum/vfredosum intrinsic test files. Merge some tests. NFC
Craig Topper [Tue, 2 Nov 2021 15:57:24 +0000 (08:57 -0700)]
[RISCV] Rename vfredusum/vfredosum intrinsic test files. Merge some tests. NFC

I recently renamed some tests from vfredsum to vfredusum without
noticing they tested both ordered and unordered reductions. This
patch renames them back.

I've also merged test files for vfwredosum/vfwredusum into a single
file for consistency with the other 3 floating point reduction test
files. The inconsistency is what caused my original confusion.

2 years ago[RISCV] Optimize vp.load with an all-ones mask
Fraser Cormack [Tue, 2 Nov 2021 14:44:05 +0000 (14:44 +0000)]
[RISCV] Optimize vp.load with an all-ones mask

Similar to D110206, this patch optimizes unmasked vp.load intrinsics to
avoid the need of a vmset instruction to set the mask. It does so by
selecting a riscv_vle intrinsic rather than a riscv_vle_mask intrinsic.

Reviewed By: craig.topper

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

2 years ago[InstCombine] add tests for bitwise select of vectors; NFC
Sanjay Patel [Tue, 2 Nov 2021 14:35:08 +0000 (10:35 -0400)]
[InstCombine] add tests for bitwise select of vectors; NFC

2 years agoSpecify explicit casts of types in pair construction
Tres Popp [Tue, 2 Nov 2021 17:15:16 +0000 (18:15 +0100)]
Specify explicit casts of types in pair construction

This was failing on some platforms.

2 years agoRevert "Update bazel file after fe364e5dc78c58a915986d9a44cfd65f919a00c2"
Tres Popp [Tue, 2 Nov 2021 17:02:39 +0000 (18:02 +0100)]
Revert "Update bazel file after fe364e5dc78c58a915986d9a44cfd65f919a00c2"

This reverts commit 8af9912113fb74f4fcc5457f9e830337fff19df1.

The other relevant commit was reverted.

2 years ago[RISCV][VP] Mangle pointers in vp.load and vp.store tests
Fraser Cormack [Mon, 1 Nov 2021 16:49:51 +0000 (16:49 +0000)]
[RISCV][VP] Mangle pointers in vp.load and vp.store tests

Although this isn't required, it better matches the suggested syntax as
per the documentation work ongoing in D112930.

Reviewed By: craig.topper

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

2 years ago[lld-macho] Remove no_dtrace_dof from un-implemented group.
Vy Nguyen [Tue, 2 Nov 2021 15:44:03 +0000 (11:44 -0400)]
[lld-macho] Remove no_dtrace_dof from un-implemented group.

One fewer warning.
In practice, lld already "implements" it. (ie., it does not do dtrace-dof processing ever).

Reviewed By: #lld-macho, thakis

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

2 years agoUpdate bazel file after fe364e5dc78c58a915986d9a44cfd65f919a00c2
Tres Popp [Tue, 2 Nov 2021 16:22:11 +0000 (17:22 +0100)]
Update bazel file after fe364e5dc78c58a915986d9a44cfd65f919a00c2

2 years ago[LoopPeel] Peel loops with exits followed by an unreachable or deopt block
Dmitry Makogon [Tue, 2 Nov 2021 16:09:37 +0000 (23:09 +0700)]
[LoopPeel] Peel loops with exits followed by an unreachable or deopt block

Added support for peeling loops with exits that are followed either by an
unreachable-terminated block or block that has a terminatnig deoptimize call.
All blocks in the sequence must have an unique successor, maybe except
for the last one.

Reviewed By: mkazantsev

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

2 years agoRevert "[NFC] Remove LinkAll*.h"
Arthur Eubanks [Tue, 2 Nov 2021 16:08:09 +0000 (09:08 -0700)]
Revert "[NFC] Remove LinkAll*.h"

This reverts commit fe364e5dc78c58a915986d9a44cfd65f919a00c2.

Causes breakages, e.g. https://lab.llvm.org/buildbot/#/builders/188/builds/5266

2 years agoAdd new choices dot-cfg and dot-cfg-quiet to print-changed.
Jamie Schmeiser [Tue, 2 Nov 2021 16:03:05 +0000 (12:03 -0400)]
Add new choices dot-cfg and dot-cfg-quiet to print-changed.

Summary:
Add new options -print-changed=[dot-cfg | dot-cfg-quiet] which create
a website of DOT files showing colourized changes as the IR is changed
by passes in the new pass manager pipeline.

A new change reporter is introduced that creates a website of changes made
by passes in the opt pipeline that change the IR. The hidden option
-dot-cfg-dir=<dir> specifies a directory (defaulting to "./") into which the
website will be created.

A file passes.html is created that contains a list of all the passes that
act on the IR. Those that do not change the IR are listed as omitted
because of no change, ignored or filtered out (using -filter-print-func
and -filter-passes) or not listed in quiet mode. Those that
do change the IR are listed as a link to a DOT file which contains a
CFG depiction of the IR (ala -dot-cfg) except that the instructions,
basic blocks and links that are only in the IR before the pass (ie, removed)
and those that are only in the IR after the pass (ie, added) are shown in
red and green, respectively, while the aspects of the CFG that do not change
are shown in black. Additional hidden options
-dot-cfg-before-color=<dot named color>,
-dot-cfg-after-color=<dot named color> and
-dot-cfg-common-color=<dot named color> are defined that allow the
customization of the colors used in colorizing the CFG.
-change-printer-dot-path=<path to dot exe> is also added.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D87202

2 years ago[fir] Add fir.zero_bits conversion pattern to LLVM IR dialect
Valentin Clement [Tue, 2 Nov 2021 15:53:18 +0000 (16:53 +0100)]
[fir] Add fir.zero_bits conversion pattern to LLVM IR dialect

This patch adds the ZeroOpConversion pattern to LLVM IR dialect.
Conversion of aggregate types is not implemented yet and will trigger a
failure to legalize the operation. This is tested in the
convert-to-llvm-invalid.fir test file.

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

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[llvm-reduce] Reduce more GlobalValue properties
Arthur Eubanks [Sun, 31 Oct 2021 04:31:41 +0000 (21:31 -0700)]
[llvm-reduce] Reduce more GlobalValue properties

Reviewed By: hans

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

2 years ago[llvm-reduce] Reduce some GlobalObject properties
Arthur Eubanks [Sun, 31 Oct 2021 02:27:35 +0000 (19:27 -0700)]
[llvm-reduce] Reduce some GlobalObject properties

Specifically, the section and the alignment.

Reviewed By: hans

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

2 years ago[gn build] Add missing llvm-reduce dependency
Arthur Eubanks [Tue, 2 Nov 2021 15:46:46 +0000 (08:46 -0700)]
[gn build] Add missing llvm-reduce dependency

2 years ago[NFC] Remove LinkAll*.h
Arthur Eubanks [Mon, 1 Nov 2021 23:45:21 +0000 (16:45 -0700)]
[NFC] Remove LinkAll*.h

These were added to prevent functions from being removed by WPO.

But that doesn't make sense, correct WPO will not remove functions we actually use.

I noticed these because compiling cc1_main.cpp was pulling in random LLVM pass headers.

Reviewed By: MaskRay

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

2 years ago[gn build] Manually port 6fd2db04
Arthur Eubanks [Tue, 2 Nov 2021 15:42:24 +0000 (08:42 -0700)]
[gn build] Manually port 6fd2db04

2 years ago[Hexagon] Add machine verification to some tests
Jay Foad [Wed, 27 Oct 2021 09:19:47 +0000 (10:19 +0100)]
[Hexagon] Add machine verification to some tests

2 years ago[lld-macho][nfc][cleanup] Fix a few code style lints and clang-tidy findings
Vy Nguyen [Tue, 26 Oct 2021 19:14:25 +0000 (15:14 -0400)]
[lld-macho][nfc][cleanup] Fix a few code style lints and clang-tidy findings

- Use .empty() instead of `size() == 0` when possible.
- Use const-ref to avoid copying

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

2 years ago[lldb] Remove ConstString from TypeSystem and REPL plugin names
Pavel Labath [Tue, 2 Nov 2021 15:09:14 +0000 (16:09 +0100)]
[lldb] Remove ConstString from TypeSystem and REPL plugin names

2 years ago[mlir][gpuTonvvm] Remove hardcoded values in MMAType to llvm struct
thomasraoux [Tue, 2 Nov 2021 15:03:07 +0000 (08:03 -0700)]
[mlir][gpuTonvvm] Remove hardcoded values in MMAType to llvm struct

Also relax the types allowed in GPU wmma ops

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

2 years ago[Test] Regenerate IndVars test's checks
Dmitry Makogon [Tue, 2 Nov 2021 15:01:22 +0000 (22:01 +0700)]
[Test] Regenerate IndVars test's checks

This just regenerates a certain IndVars test's checks.

2 years ago[AMDGPU] Really preserve LiveVariables in SILowerControlFlow
Jay Foad [Wed, 27 Oct 2021 15:05:40 +0000 (16:05 +0100)]
[AMDGPU] Really preserve LiveVariables in SILowerControlFlow

https://bugs.llvm.org/show_bug.cgi?id=52204

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

2 years ago[mlir][VectorToGPU] Add support for elementwise mma to vector to GPU
thomasraoux [Tue, 2 Nov 2021 14:41:16 +0000 (07:41 -0700)]
[mlir][VectorToGPU] Add support for elementwise mma to vector to GPU

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

2 years ago[HWASan] Print short tags in tag mismatch description.
Matt Morehouse [Tue, 2 Nov 2021 15:00:27 +0000 (08:00 -0700)]
[HWASan] Print short tags in tag mismatch description.

I recently spent some extra time debugging a false positive because I
didn't realize the "real" tag was in the short granule.  Adding the
short tag here makes it more obvious that we could be dealing with a
short granule.

Reviewed By: hctim, eugenis

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

2 years ago[HWASan] Print short tags in __hwasan_print_shadow.
Matt Morehouse [Tue, 2 Nov 2021 14:59:16 +0000 (07:59 -0700)]
[HWASan] Print short tags in __hwasan_print_shadow.

Reviewed By: eugenis

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

2 years ago[Test] Fix tests showing generation of already existent PHIs by GVN
Dmitry Makogon [Tue, 2 Nov 2021 14:56:07 +0000 (21:56 +0700)]
[Test] Fix tests showing generation of already existent PHIs by GVN

Add target triple to the test module, so IndVars has a TTI to perform
congruent IVs elimination.

2 years ago[LangRef][VP] Correct mask type in vp.slice documentation
Fraser Cormack [Mon, 1 Nov 2021 11:39:01 +0000 (11:39 +0000)]
[LangRef][VP] Correct mask type in vp.slice documentation

The mask type for the llvm.experimental.vp.splice intrinsics must have
the same number of elements as the result type.

Reviewed By: simoll

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

2 years agoRevert "[AArch64][SVE] Combine predicated FMUL/FADD into FMA"
Matt [Tue, 2 Nov 2021 14:43:34 +0000 (14:43 +0000)]
Revert "[AArch64][SVE] Combine predicated FMUL/FADD into FMA"

This reverts commit fc28a2f8ced4ff3565f2c47fead824a017c25d21.

2 years ago[Test] Add tests showing congruent IVs not removed by IndVars
Dmitry Makogon [Tue, 2 Nov 2021 14:43:03 +0000 (21:43 +0700)]
[Test] Add tests showing congruent IVs not removed by IndVars

In the added cases we have two congruent IVs. IndVars widens at least one of them.
If they are both widened, then one of them is erased as they stay congruent after
widening. However if only one IV is widened, the other one stays in the loop.
We can simply erase the narrow IV and replace its uses with truncates of the
widest IV.

2 years ago[RISCV][VP] Add tests for "unmasked" VP loads
Fraser Cormack [Tue, 2 Nov 2021 14:04:08 +0000 (14:04 +0000)]
[RISCV][VP] Add tests for "unmasked" VP loads

These aren't currently matched against unmasked vector load
instructions. A patch to fix that will come later.

2 years ago[Sema] Avoid crash in CheckEnumConstant with contains-error expressions
Sam McCall [Fri, 20 Aug 2021 08:01:45 +0000 (10:01 +0200)]
[Sema] Avoid crash in CheckEnumConstant with contains-error expressions

Fixes https://bugs.llvm.org/show_bug.cgi?id=51554

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

2 years agoUse `GNUInstallDirs` to support custom installation dirs. -- LLVM
John Ericson [Sun, 4 Apr 2021 17:02:18 +0000 (13:02 -0400)]
Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

This is a new draft of D28234. I previously did the unorthodox thing of
pushing to it when I wasn't the original author, but since this version

- Uses `GNUInstallDirs`, rather than mimics it, as the original author
  was hesitant to do but others requested.

- Is much broader, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I am using this patch (and many back-ports) as the basis of
https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS). It
looked like people were generally on board in D28234, but I make note of
this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM
already has some partial support for these sorts of things. For example
`LLVM_LIBDIR_SUFFIX`, or `COMPILER_RT_INSTALL_PATH`. Because it's not
quite clear yet what to do about those, we are holding off on changing
libdirs and `compiler-rt`. for this initial PR.

---

On the advice of @lebedev.ri, I am splitting this up a bit per
subproject, starting with LLVM. To allow it to be more easily reviewed. This and the subsequent patch must be landed together, as this will not build alone. But the rest can be landed on their own.

Reviewed By: compnerd

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

2 years ago[SimpleLoopUnswitch] Remove duplicate include.
Youngsuk Kim [Tue, 2 Nov 2021 14:05:54 +0000 (15:05 +0100)]
[SimpleLoopUnswitch] Remove duplicate include.

Header "llvm/Transforms/Scalar/SimpleLoopUnswitch.h" is currently
included twice. This commit removes the duplicate 'include' line.

Previous commit 693eedb13833245e2670308fa0e6fe47324ce553
seems to have mistakenly added the duplicate 'include'.

Reviewed By: fhahn

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

2 years ago[mlir] replace class with struct in a forward declaration
Alex Zinenko [Tue, 2 Nov 2021 14:05:45 +0000 (15:05 +0100)]
[mlir] replace class with struct in a forward declaration

Silence the warning.

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

2 years ago[InstCombine] change 'not' match for bitwise select
Sanjay Patel [Tue, 2 Nov 2021 13:42:41 +0000 (09:42 -0400)]
[InstCombine] change 'not' match for bitwise select

The tests diffs are logically equivalent, and so this is
generally NFC, but this makes the code match the code
comment.

It should also be more efficient. If we choose the 'not'
operand (rather than the 'not' instruction) as the select
condition, then we don't have to invert the select
condition/operands as a subsequent transform.

2 years ago[mlir] drop spurious semicolon
Alex Zinenko [Tue, 2 Nov 2021 14:15:03 +0000 (15:15 +0100)]
[mlir] drop spurious semicolon

2 years ago[X86][AVX] SimplifyDemandedVectorEltsForTargetNode - use getBROADCAST_LOAD helper...
Simon Pilgrim [Tue, 2 Nov 2021 13:07:36 +0000 (13:07 +0000)]
[X86][AVX] SimplifyDemandedVectorEltsForTargetNode - use getBROADCAST_LOAD helper. NFCI.

Reduce width of X86ISD::SUBV_BROADCAST_LOAD node.

2 years ago[X86][AVX] lowerV2X128Shuffle - use getBROADCAST_LOAD helper. NFCI.
Simon Pilgrim [Tue, 2 Nov 2021 12:52:05 +0000 (12:52 +0000)]
[X86][AVX] lowerV2X128Shuffle - use getBROADCAST_LOAD helper. NFCI.

2 years ago[Clang] Add min/max reduction builtins.
Florian Hahn [Tue, 2 Nov 2021 14:01:41 +0000 (15:01 +0100)]
[Clang] Add min/max reduction builtins.

This patch implements __builtin_reduce_max and __builtin_reduce_min as
specified in D111529.

The order of operations does not matter for min or max reductions and
they can be directly lowered to the corresponding
llvm.vector.reduce.{fmin,fmax,umin,umax,smin,smax} intrinsic calls.

Reviewed By: aaron.ballman

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

2 years ago[mlir][linalg] Rewrite `linalg.conv_2d_nhwc_hwcf` into 1-D
Lei Zhang [Tue, 2 Nov 2021 13:55:34 +0000 (09:55 -0400)]
[mlir][linalg] Rewrite `linalg.conv_2d_nhwc_hwcf` into 1-D

We'd like to take a progressive approach towards Fconvolution op
CodeGen, by 1) tiling it to fit compute hierarchy first, and then
2) tiling along window dimensions with size 1 to reduce the problem
to be matmul-like. After that, we can 3) downscale high-D convolution
ops to low-D by removing the size-1 window dimensions. The final
step would be 4) vectorizing the low-D convolution op directly.

We have patterns for 1), 2), and 4). This commit adds a pattern for
3) for `linalg.conv_2d_nhwc_hwcf` ops as a starter. Supporting other
high-D convolution ops should be similar and mechanical.

Reviewed By: nicolasvasilache

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

2 years ago[Scalarizer] Do not insert instructions between PHI nodes and debug intrinsics.
Daniele Vettorel [Tue, 2 Nov 2021 13:52:46 +0000 (09:52 -0400)]
[Scalarizer] Do not insert instructions between PHI nodes and debug intrinsics.

The scalarizer pass seems to be inserting instructions in-between PHI nodes or debug intrinsics that end up staying at the end of the pass, resulting in malformed IR and violating assumptions.

This patch adds a check to make sure the `extractelement` instructions that it adds are correctly placed after all PHI nodes and debug intrinsics.

Patch by vettoreldaniele.

Reviewed By: bjope

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

2 years ago[gn build] Port 9b5c9c469d90
LLVM GN Syncbot [Tue, 2 Nov 2021 13:45:10 +0000 (13:45 +0000)]
[gn build] Port 9b5c9c469d90

2 years ago[analyzer] Dump checker name if multiple checkers evaluate the same call
Balazs Benics [Tue, 2 Nov 2021 13:42:14 +0000 (14:42 +0100)]
[analyzer] Dump checker name if multiple checkers evaluate the same call

Previously, if accidentally multiple checkers `eval::Call`-ed the same
`CallEvent`, in debug builds the analyzer detected this and crashed
with the message stating this. Unfortunately, the message did not state
the offending checkers violating this invariant.
This revision addresses this by printing a more descriptive message
before aborting.

Reviewed By: martong

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

2 years ago[AST] injected-class-name is not a redecl, even in template specializations
Sam McCall [Thu, 28 Oct 2021 22:48:42 +0000 (00:48 +0200)]
[AST] injected-class-name is not a redecl, even in template specializations

Back in the mists of time, the CXXRecordDecl for the injected-class-name was
a redecl of the outer class itself.
This got changed in 470c454a6176ef31474553e408c90f5ee630df89, but only for plain
classes: class template instantation was still detecting the injected-class-name
in the template body and marking its instantiation as a redecl.

This causes some subtle inconsistent behavior between the two, e.g.
hasDefinition() returns true for Foo<int>::Foo but false for Bar::Bar.
This is the root cause of PR51912.

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

2 years agoFix building with GCC 12:
Martin Liska [Tue, 2 Nov 2021 08:34:09 +0000 (09:34 +0100)]
Fix building with GCC 12:

Fixes: https://bugs.llvm.org/show_bug.cgi?id=52380

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

2 years ago[AMDGPU] More robust checks in extract_vector_dynelt.ll
Jay Foad [Tue, 2 Nov 2021 13:19:43 +0000 (13:19 +0000)]
[AMDGPU] More robust checks in extract_vector_dynelt.ll

2 years ago[mlir] provide C API and Python bindings for symbol tables
Alex Zinenko [Tue, 2 Nov 2021 11:39:36 +0000 (12:39 +0100)]
[mlir] provide C API and Python bindings for symbol tables

Symbol tables are a largely useful top-level IR construct, for example, they
make it easy to access functions in a module by name instead of traversing the
list of module's operations to find the corresponding function.

Depends On D112886

Reviewed By: mehdi_amini

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

2 years ago[mlir] return the updated symbol table after inserting into SymbolTable
Alex Zinenko [Tue, 2 Nov 2021 11:38:01 +0000 (12:38 +0100)]
[mlir] return the updated symbol table after inserting into SymbolTable

Inserting a symbol into a SymbolTable may lead to the name of the symbol being
changed in order to ensure uniqueness of symbol names in the table. Return this
new name to spare the caller the need to extract it from the symbol operation.

Depends On D112700

Reviewed By: mehdi_amini

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

2 years ago[DAGCombiner] Teach combineShiftToMULH to handle constant and const splat vector.
jacquesguan [Tue, 2 Nov 2021 11:13:04 +0000 (11:13 +0000)]
[DAGCombiner] Teach combineShiftToMULH to handle constant and const splat vector.

Fold (srl (mul (zext i32:$a to i64), i64:c), 32) -> (mulhu $a, $b),
if c can truncate to i32 without loss.

Reviewed By: frasercrmck, craig.topper, RKSimon

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

2 years ago[RISCV] Fix invalid kill on callee save
David Callahan [Tue, 2 Nov 2021 11:55:12 +0000 (11:55 +0000)]
[RISCV] Fix invalid kill on callee save

A callee save may be live (specifically X1) on entry and so a spill
should not mark it killed.

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

2 years ago[lldb] Fix a use-after-free in FindFileTest.cpp
Raphael Isemann [Tue, 2 Nov 2021 11:39:25 +0000 (12:39 +0100)]
[lldb] Fix a use-after-free in FindFileTest.cpp

ArrayRef doesn't take ownership.

2 years ago[SelectionDAG] Optimize expansion for rotates/funnel shifts
Simon Pilgrim [Tue, 2 Nov 2021 11:38:25 +0000 (11:38 +0000)]
[SelectionDAG] Optimize expansion for rotates/funnel shifts

If the type of a funnel shift needs to be expanded, expand it to two funnel shifts instead of regular shifts. For constant shifts, this doesn't make much difference, but for variable shifts it allows a more optimal lowering.

Also use the optimized funnel shift lowering for rotates.

Alive2: https://alive2.llvm.org/ce/z/TvHDB- / https://alive2.llvm.org/ce/z/yzPept

(Branched from D108058 as getting this completed should help unlock some other WIP patches).

Original Patch: @efriedma (Eli Friedman)

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

2 years ago[DAG] MatchRotate - remove (redundant) legal type check.
Simon Pilgrim [Tue, 2 Nov 2021 11:24:35 +0000 (11:24 +0000)]
[DAG] MatchRotate - remove (redundant) legal type check.

Rely on the hasOperation() instead - as commented on D77804, the mid-term intention is to recognise rotate/funnel-by-constant pre-legalization to help avoid SimplifyDemandedBits regressions.

2 years ago[bazel] Update BUILD file for llvm-reduce
Tres Popp [Tue, 2 Nov 2021 11:00:32 +0000 (12:00 +0100)]
[bazel] Update BUILD file for llvm-reduce

This is needed after fd41738e2ca975b6d3bea021ef38e6d49f27a71b

2 years ago[libc] Add more robust compile time architecture detection
Guillaume Chatelet [Tue, 2 Nov 2021 11:00:32 +0000 (11:00 +0000)]
[libc] Add more robust compile time architecture detection

We may want to restrict the detected platforms to only `x86_64` and `aarch64`.
There are still custom detection in api.td but I don't think we can handle these:
 - config/linux/api.td:205
 - config/linux/api.td:199

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

2 years ago[sanitizers] remove extra comma for sha2 interceptors
David Carlier [Tue, 2 Nov 2021 10:35:26 +0000 (10:35 +0000)]
[sanitizers] remove extra comma for sha2 interceptors

2 years ago[ARM] Some extra gather/scatter tests. NFC
David Green [Tue, 2 Nov 2021 10:32:22 +0000 (10:32 +0000)]
[ARM] Some extra gather/scatter tests. NFC

2 years ago[clang-tidy] Add check 'cert-err33-c'.
Balázs Kéri [Tue, 2 Nov 2021 09:30:14 +0000 (10:30 +0100)]
[clang-tidy] Add check 'cert-err33-c'.

The CERT rule ERR33-C can be modeled partially by the existing check
'bugprone-unused-return-value'. The existing check is reused with
a fixed set of checked functions.

Reviewed By: aaron.ballman

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

2 years ago[mlir][linalg][bufferize] Move BufferizableOpInterface implementations
Matthias Springer [Tue, 2 Nov 2021 07:05:53 +0000 (16:05 +0900)]
[mlir][linalg][bufferize] Move BufferizableOpInterface implementations

This commit moves parts of the existing bufferization code into external op interface implementations. Furthermore, Comprehensive Bufferize is adapted to use the new interface.

Future commits will decouple the interface and its op implementations from Comprehensive Bufferize and the Linalg dialect, as well as split them into multiple files with their own build targets. This commit leaves the file structure and build rules mostly unchanged.

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

2 years ago[gn build] Port fd41738e2ca9
LLVM GN Syncbot [Tue, 2 Nov 2021 09:21:12 +0000 (09:21 +0000)]
[gn build] Port fd41738e2ca9

2 years ago[mlir][linalg][bufferize] Add BufferizableOpInterface
Matthias Springer [Tue, 2 Nov 2021 07:05:27 +0000 (16:05 +0900)]
[mlir][linalg][bufferize] Add BufferizableOpInterface

This commit adds a new op interface: BufferizableOpInterface. In the future, ops that implement this interface can be bufferized using Comprehensive Bufferize.

Note: The interface methods of this interface correspond to the "op interface" in ComprehensiveBufferize.cpp.

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

2 years ago[llvm-readobj] Add support for reading OpenBSD ELF core notes.
Frederic Cambus [Mon, 1 Nov 2021 21:46:30 +0000 (22:46 +0100)]
[llvm-readobj] Add support for reading OpenBSD ELF core notes.

Notes generated in OpenBSD core files provide additional information
about the kernel state and CPU registers. These notes are described
in core.5, which can be viewed here: https://man.openbsd.org/core.5

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

2 years agoRecommit "[llvm-reduce] Add MIR support"
Markus Lavin [Tue, 2 Nov 2021 09:11:54 +0000 (10:11 +0100)]
Recommit "[llvm-reduce] Add MIR support"

(Second try. Need to link against CodeGen and MC libs.)

The llvm-reduce tool has been extended to operate on MIR (import, clone and
export). Current limitation is that only a single machine function is
supported. A single reducer pass that operates on machine instructions (while
on SSA-form) has been added. Additional MIR specific reducer passes can be
added later as needed.

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

2 years ago[lldb][gmodules] Fix TestDataFormatterGlobals under gmodules
Raphael Isemann [Tue, 2 Nov 2021 09:08:03 +0000 (10:08 +0100)]
[lldb][gmodules] Fix TestDataFormatterGlobals under gmodules

Same reason as in 548dbfaf447cc5fdfc26d34e60e3da08eb609531 -> macOS has a
struct called 'Point' in the libc module. Just remove the redundant includes
here.

2 years ago[LoopVectorize] Propagate fast-math flags for inloop reductions
Rosie Sumpter [Tue, 26 Oct 2021 11:58:18 +0000 (12:58 +0100)]
[LoopVectorize] Propagate fast-math flags for inloop reductions

This patch updates VPReductionRecipe::execute so that the fast-math
flags associated with the underlying instruction of the VPRecipe are
propagated through to the reductions which are created.

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

2 years agoFix inline builtin handling in case of redefinition
serge-sans-paille [Tue, 19 Oct 2021 09:23:27 +0000 (11:23 +0200)]
Fix inline builtin handling in case of redefinition

Basically, inline builtin definition are shadowed by externally visible
redefinition. This matches GCC behavior.

The implementation has to workaround the fact that:

1. inline builtin are renamed at callsite during codegen, but
2. they may be shadowed by a later external definition

As a consequence, during codegen, we need to walk redecls and eventually rewrite
some call sites, which is totally inelegant.

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

2 years ago[lldb] Unbreak the macOS build after dfd499a61c45778b7f01458d50ccc384343f53d5
Benjamin Kramer [Tue, 2 Nov 2021 08:47:44 +0000 (09:47 +0100)]
[lldb] Unbreak the macOS build after dfd499a61c45778b7f01458d50ccc384343f53d5

2 years ago[gn build] Port aee7f3384b40
LLVM GN Syncbot [Tue, 2 Nov 2021 08:41:58 +0000 (08:41 +0000)]
[gn build] Port aee7f3384b40

2 years agoRevert "[llvm-reduce] Add MIR support"
Markus Lavin [Tue, 2 Nov 2021 08:38:57 +0000 (09:38 +0100)]
Revert "[llvm-reduce] Add MIR support"

This reverts commit bc2773cb1bdfacfda773eb492e7b0cc65a78cda6.

Broke the clang-ppc64le-linux-multistage build. Reverting while I
investigate.

2 years ago[gn build] Port bc2773cb1bdf
LLVM GN Syncbot [Tue, 2 Nov 2021 08:28:36 +0000 (08:28 +0000)]
[gn build] Port bc2773cb1bdf

2 years agoRevert "[NFC][sanitizer] Disable a test with large stderr output"
Vitaly Buka [Tue, 2 Nov 2021 08:24:51 +0000 (01:24 -0700)]
Revert "[NFC][sanitizer] Disable a test with large stderr output"

This reverts commit 6eb38e517159f1fa5686d661d2aceb0a4002d8f0.

The test was not the reason of sanitizer-x86_64-linux-android failures.

2 years ago[llvm-reduce] Add MIR support
Markus Lavin [Tue, 2 Nov 2021 08:10:34 +0000 (09:10 +0100)]
[llvm-reduce] Add MIR support

The llvm-reduce tool has been extended to operate on MIR (import, clone and
export). Current limitation is that only a single machine function is
supported. A single reducer pass that operates on machine instructions (while
on SSA-form) has been added. Additional MIR specific reducer passes can be
added later as needed.

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

2 years ago[clang-tidy] Fix lint warnings in clang-tidy source code (NFC)
Salman Javed [Tue, 2 Nov 2021 07:14:25 +0000 (20:14 +1300)]
[clang-tidy] Fix lint warnings in clang-tidy source code (NFC)

Run clang-tidy on all source files under `clang-tools-extra/clang-tidy`
with `-header-filter=clang-tidy.*` and make suggested corrections.

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

2 years ago[sanitizer] Restore trivial posix_spawn init in test
Vitaly Buka [Tue, 2 Nov 2021 06:57:13 +0000 (23:57 -0700)]
[sanitizer] Restore trivial posix_spawn init in test

It's still needed on Darwin.

2 years agoCheck if an attribute is in the builtin dialect before going through all the possible...
Mehdi Amini [Tue, 2 Nov 2021 05:51:38 +0000 (05:51 +0000)]
Check if an attribute is in the builtin dialect before going through all the possible combinations (NFC)

This is just a "micro-optimization" noticed through code review.

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