platform/upstream/llvm.git
2 years ago[OpenMP][FIX] Introduce and use a simple generic-mode barrier
Johannes Doerfert [Sun, 31 Oct 2021 17:23:45 +0000 (12:23 -0500)]
[OpenMP][FIX] Introduce and use a simple generic-mode barrier

Before we had aligned barriers the `__kmpc_barrier_simple_spmd` was
OK to be used in the custom state machine. Now that SPMD barriers are
assumed to be aligned we need to use a "generic" barrier in places
that are not aligned.

Reviewed By: tianshilei1992

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

2 years ago[NVVM] Update intrinsic definitions to include more attributes
Johannes Doerfert [Fri, 17 Sep 2021 18:23:42 +0000 (13:23 -0500)]
[NVVM] Update intrinsic definitions to include more attributes

A lot of NVVM intrinsics can use the default intrinsic attributes (e.g.,
nosync, nofree, ...) as well as `speculatable`. The latter is important
if we want to recompute intrinsics results instead of communicating them
via memory.

I did use default attributes for almost all `readnone` attributes but
speculatable only where I had reasonable confidence they cannot
experience UB. That said, someone should double check.

TODO: There seem to be various intrinsics marked `Commutative` which
      should not, e.g., fma and div.

Reviewed By: tra

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

2 years ago[OpenMP][FIX] Ensure guarding uses proper global name
Johannes Doerfert [Fri, 29 Oct 2021 22:34:51 +0000 (17:34 -0500)]
[OpenMP][FIX] Ensure guarding uses proper global name

Global symbols cannot have any name so we need to sanitize the string
first. Also remove an assertion that is not actually necessary nor
true in general.

Reviewed By: ggeorgakoudis

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

2 years ago[OpenMP][FIX] Avoid a race between initialization and first state reads
Johannes Doerfert [Sat, 30 Oct 2021 19:24:25 +0000 (14:24 -0500)]
[OpenMP][FIX] Avoid a race between initialization and first state reads

When we pick state 0 to initialize state but thread N is going to be the
"main thread", in generic mode, we would require extra synchronization.
Instead, we should pick the main thread to initialize state in generic
mode and any thread in SPMD mode.

Reviewed By: tianshilei1992

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

2 years ago[AMDGPU] Fix SGPR checks in S_MOV_B64_IMM_PSEUDO generation.
Abinav Puthan Purayil [Tue, 2 Nov 2021 07:33:42 +0000 (13:03 +0530)]
[AMDGPU] Fix SGPR checks in S_MOV_B64_IMM_PSEUDO generation.

The function to generate S_MOV_B64_IMM_PSEUDO was recently modified to
optimize AGPR to AGPR copy but it missed checking for the SGPR
clobbering for the S_MOV_B64_IMM_PSEUDO generation.

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

2 years ago[AArch64] Optimize add/sub with immediate
Ben Shi [Mon, 1 Nov 2021 09:47:44 +0000 (09:47 +0000)]
[AArch64] Optimize add/sub with immediate

Optimize ([add|sub] r, imm) -> ([ADD|SUB] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([add|sub] r, imm) -> ([SUB|ADD] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Reviewed By: jaykang10, dmgreen

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

2 years ago[llvm-profgen] Refactor the code of getHashCode
wlei [Tue, 2 Nov 2021 04:35:32 +0000 (21:35 -0700)]
[llvm-profgen] Refactor the code of getHashCode

Refactor to generate hash code lazily. Tested on clang self build, no observable generating time regression.

Reviewed By: hoy, wenlei

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

2 years ago[llvm-profgen] Warn on invalid range and show warning summary
wlei [Tue, 26 Oct 2021 02:20:28 +0000 (19:20 -0700)]
[llvm-profgen] Warn on invalid range and show warning summary

Two things in this diff:

1) Warn on the invalid range, currently three types of checking, see the detailed message in the code.

2) In some situation, llvm-profgen gives lots of warnings on the truncated stacks which is noisy. This change provides a switch to `--show-detailed-warning` to skip the warnings. Alternatively, we use a summary for those warning and show the percentage of cases with those issues.

Example of warning summary.
```
warning: 0.05%(1120/2428958) cases with issue: Profile context truncated due to missing probe for call instruction.
warning: 0.00%(2/178637) cases with issue: Range does not belong to any functions, likely from external function.
```

Reviewed By: hoy

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

2 years ago[ScalarEvolution] Infer loop max trip count from array accesses
Liren Peng [Wed, 3 Nov 2021 02:40:18 +0000 (10:40 +0800)]
[ScalarEvolution] Infer loop max trip count from array accesses

Data references in a loop should not access elements over the
statically allocated size. So we can infer a loop max trip count
from this undefined behavior.

Reviewed By: reames, mkazantsev, nikic

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

2 years ago[X86][VARARG] Assign MMO earlier to avoid prolog insert point been sunk across VASTAR...
Phoebe Wang [Wed, 3 Nov 2021 01:29:52 +0000 (09:29 +0800)]
[X86][VARARG] Assign MMO earlier to avoid prolog insert point been sunk across VASTART_SAVE_XMM_REGS

The changes in D80163 defered the assignment of MachineMemOperand (MMO)
until the X86ExpandPseudo pass. This will result in crash due to prolog
insert point been sunk across the pseudo instruction VASTART_SAVE_XMM_REGS.

Moving the assignment to the creation of the node can avoid the problem.

Reviewed By: rnk

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

2 years ago[ELF] Try appeasing --target=armv7-linux-androideabi24 sanitizer symbolization tests
Fangrui Song [Wed, 3 Nov 2021 01:57:04 +0000 (18:57 -0700)]
[ELF] Try appeasing --target=armv7-linux-androideabi24 sanitizer symbolization tests

2 years ago[NFC][Regalloc] Ensure Query::interferingVRegs is accurate.
Mircea Trofin [Sun, 31 Oct 2021 03:47:22 +0000 (20:47 -0700)]
[NFC][Regalloc] Ensure Query::interferingVRegs is accurate.

To correctly use Query, one had to first call collectInterferingVRegs to
pre-cache the query result, then call interferingVRegs. Failing the
former, interferingVRegs could be stale. This did cause a bug which was
addressed in D98232, but the underlying usability issue of the Query API
wasn't.

This patch addresses the latter by making collectInterferingVRegs an
implementation detail, and having interferingVRegs play both roles. One
side-effect of this is that interferingVRegs is not const anymore.

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

2 years ago[Transforms] Use make_early_inc_range (NFC)
Kazu Hirata [Wed, 3 Nov 2021 01:13:23 +0000 (18:13 -0700)]
[Transforms] Use make_early_inc_range (NFC)

2 years ago[llvm-profdata] Print out section flags for FunctionMetadata section
Hongtao Yu [Tue, 2 Nov 2021 22:11:33 +0000 (15:11 -0700)]
[llvm-profdata] Print out section flags for  FunctionMetadata section

As titled.

Reviewed By: wenlei, wlei

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

2 years ago[ARM] Make empty name symbols SF_FormatSpecific to try appeasing --target=armv7-linux...
Fangrui Song [Wed, 3 Nov 2021 00:10:42 +0000 (17:10 -0700)]
[ARM] Make empty name symbols SF_FormatSpecific to try appeasing --target=armv7-linux-androideabi24 sanitizer symbolization tests

This is similar to D98669 but I don't know whether and why ARM needs it.

I suspect this may fix the sanitizer-x86_64-linux-android bot which runs
--target=armv7-linux-androideabi24 tests
(https://lab.llvm.org/buildbot/#/builders/77)

Someone needs to investigate the root cause and I am not sure this hack
fixes the bot.

2 years agoRevert "[gn build] Manually port 6fd2db04"
Arthur Eubanks [Tue, 2 Nov 2021 23:51:56 +0000 (16:51 -0700)]
Revert "[gn build] Manually port 6fd2db04"

This reverts commit 43390d38f0dfdda61e1d8a04277a1b5937122c31.

Corresponding commit was reverted.

2 years ago[NFC][asan] Fix confusing variable name
Vitaly Buka [Tue, 2 Nov 2021 23:05:14 +0000 (16:05 -0700)]
[NFC][asan] Fix confusing variable name

There is no such thing as ModuleUseAfterScope.

2 years ago[NFC][asan] Simplify AddressSanitizerOptions
Vitaly Buka [Tue, 2 Nov 2021 22:50:11 +0000 (15:50 -0700)]
[NFC][asan] Simplify AddressSanitizerOptions

2 years ago[mlir][Linalg] Allow transformation filter to match by default.
MaheshRavishankar [Tue, 2 Nov 2021 22:58:38 +0000 (15:58 -0700)]
[mlir][Linalg] Allow transformation filter to match by default.

The current setup of LinalgTransformationFilter allows a
transformation to trigger when either
1) The StringAttr is not set and no filter identifier is specified.
2) The StringAttr is set and its value matches (one of) the provided
identifier.
This misses the case where the transformation should trigger either
when the attribute is not set or its value matches (one of) the
provided identifier. Since `Identifier` does not allow empty strings,
add a boolean option to match when the attribute is not set. This
option is by default off.

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

2 years agoFix iterator_adaptor_base/enumerator_iter to allow composition of llvm::enumerate...
Mehdi Amini [Tue, 2 Nov 2021 04:52:48 +0000 (04:52 +0000)]
Fix iterator_adaptor_base/enumerator_iter to allow composition of llvm::enumerate with llvm::make_filter_range

* Properly specify reference type in enumerator_iter
* Fix constness of iterator_adaptor_base::operator*

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

2 years agoRemove builder that takes SSA value instead of Attribute on ExtractValueOp, InsetValu...
Mehdi Amini [Mon, 1 Nov 2021 19:15:39 +0000 (19:15 +0000)]
Remove builder that takes SSA value instead of Attribute on ExtractValueOp, InsetValueOp, and InsertOnRangeOp

This builder exposed a somehow "unsafe" API: it pretends we can
construct an InsertOnRangeOp from a range of SSA values, even though
this will crash if these aren't the result of `arith.constant` since
the operation actually needs attribute values (a build method can't
fail gracefully).
That means that the caller must check for the producer, at which
point they can just assemble the attribute array directly and call
the existing builder.

The existing call-sites were even in a worse state here: they would
actually create a constant operation that wouldn't be used and only
serve to carry the attribute through the builder API.

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

2 years ago[mlir][Vector] Add a pattern to lower 2-D vector.transpose to shape_cast+shuffle.
Nicolas Vasilache [Tue, 2 Nov 2021 21:59:55 +0000 (21:59 +0000)]
[mlir][Vector] Add a pattern to lower 2-D vector.transpose to shape_cast+shuffle.

The 2-D case can be rewritten to generate quite fewer instructions and a single vector.shuffle which seems to provide a nice performance boost.
Add this arrow to our quiver by exposing it with a new vector transform option.

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

3 years ago[AArch64] Diagnose large adrp offset on Windows.
Eli Friedman [Tue, 2 Nov 2021 20:32:31 +0000 (13:32 -0700)]
[AArch64] Diagnose large adrp offset on Windows.

On Windows, this relocation can only encode a 21-bit offset. Make sure
we emit an error, instead of silently truncating the offset.

Found investigating https://bugs.llvm.org/show_bug.cgi?id=52378

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

3 years ago[mlir] Fixed a typo.
Kirill Stoimenov [Tue, 2 Nov 2021 21:38:47 +0000 (21:38 +0000)]
[mlir] Fixed a typo.

Reviewed By: kda

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

3 years ago[lldb] update TestEchoCommands
Lawrence D'Anna [Tue, 2 Nov 2021 21:29:55 +0000 (14:29 -0700)]
[lldb] update TestEchoCommands

Followup to https://reviews.llvm.org/D112988

Sorry, I broke this test.   The test was verifying the bad behavior
of --source-quietly that the previous change fixed -- namely that
it still echos the initial list of startup commands while
sourcing them.

Updated the test to verify that --source-quietly is quiet, rather than
loud.

Reviewed By: JDevlieghere

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

3 years ago[lldb] Improve error reporting in `lang objc tagged-pointer info`
Jonas Devlieghere [Tue, 2 Nov 2021 20:28:14 +0000 (13:28 -0700)]
[lldb] Improve error reporting in `lang objc tagged-pointer info`

Improve error handling for the lang objc tagged-pointer info. Rather
than failing silently, report an error if we couldn't convert an
argument to an address or resolve the class descriptor.

  (lldb) lang objc tagged-pointer info 0xbb6404c47a587764
  error: could not get class descriptor for 0xbb6404c47a587764

  (lldb) lang objc tagged-pointer info n1
  error: could not convert 'n1' to a valid address

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

3 years ago[LV] Add test case from PR51794 for over-eager truncation.
Florian Hahn [Tue, 2 Nov 2021 20:17:55 +0000 (21:17 +0100)]
[LV] Add test case from PR51794 for over-eager truncation.

This patch adds a test case for PR51794 where reductions are performed
on types that are too small.

3 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

3 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

3 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

3 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.

3 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

3 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.

3 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.

3 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.

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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.

3 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

3 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

3 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>
3 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.

3 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

3 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

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

3 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

3 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.

3 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

3 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

3 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.

3 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.

3 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

3 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

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

3 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

3 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

3 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

3 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>
3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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

3 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.

3 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

3 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

3 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

3 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

3 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.

3 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

3 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.

3 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.

3 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.

3 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

3 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

3 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

3 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

3 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.

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

3 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.

3 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.

3 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

3 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

3 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

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

3 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

3 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

3 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

3 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

3 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

3 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