platform/upstream/llvm.git
2 years ago[libc++][test] Remove disable_missing_braces_warning.h from tests
Joe Loser [Wed, 22 Sep 2021 20:00:16 +0000 (16:00 -0400)]
[libc++][test] Remove disable_missing_braces_warning.h from tests

Several tests include `disable_missing_braces_warning.h` but do not need
to. Remove the include.

Inspired from discussion at https://reviews.llvm.org/D109668

Reviewed By: ldionne, #libc, Mordante

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

2 years ago[mlir][sparse] generalize reduction support in sparse compiler
Aart Bik [Tue, 21 Sep 2021 21:48:49 +0000 (14:48 -0700)]
[mlir][sparse] generalize reduction support in sparse compiler

Now not just SUM, but also PRODUCT, AND, OR, XOR. The reductions
MIN and MAX are still to be done (also depends on recognizing
these operations in cmp-select constructs).

Reviewed By: bixia

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

2 years ago[ValueTracking] fix isOnlyUsedInZeroEqualityComparison with no users
Sanjay Patel [Wed, 22 Sep 2021 19:01:53 +0000 (15:01 -0400)]
[ValueTracking] fix isOnlyUsedInZeroEqualityComparison with no users

This is another problem exposed by:
https://bugs.llvm.org/PR50836

2 years ago[Analysis] reduce code for isOnlyUsedInZeroEqualityComparison; NFC
Sanjay Patel [Wed, 22 Sep 2021 18:56:27 +0000 (14:56 -0400)]
[Analysis] reduce code for isOnlyUsedInZeroEqualityComparison; NFC

There's a bug here noted by the FIXME and visible in variations of PR50836.

2 years ago[ELF][AArch64] Refine and fix the condition when BTI/PAC PLT needs bti c
Fangrui Song [Wed, 22 Sep 2021 18:51:09 +0000 (11:51 -0700)]
[ELF][AArch64] Refine and fix the condition when BTI/PAC PLT needs bti c

(As I mentioned in https://reviews.llvm.org/D62609#1534158 ,
the condition for using bti c for executable can be loosened.)

In two cases the address of a PLT may escape:

* canonical PLT entry for a STT_FUNC
* non-preemptible STT_GNU_IFUNC which is converted to STT_FUNC

The first case can be detected with `needsPltAddr`.

The second case is not straightforward to detect because for the Relocations.cpp
created `directSym`, it's difficult to know whether the associated `sym` has
exercised the `!needsPlt(expr)` code path. Just use the conservative `isInIplt`
condition. A non-preemptible ifunc not referenced by non-GOT-generating
non-PLT-generating relocations will have an unneeded `bti c`, but the cost is acceptable.

The second case fixes a bug as well: a -shared link may have non-preemptible ifunc.
Before the patch we did not emit `bti c` and could be wrong if the PLT address escaped.
GNU ld doesn't handle the case: `relocation R_AARCH64_ADR_PREL_PG_HI21 against STT_GNU_IFUNC symbol 'ifunc2' isn't handled by elf64_aarch64_final_link_relocate` (https://sourceware.org/bugzilla/show_bug.cgi?id=28370)

For -shared, if BTI is enabled but PAC is disabled, the PLT entry size increases
from 16 to 24 because we have to select the PLT scheme early, but the cost is
acceptable.

Reviewed By: peter.smith

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

2 years ago[OpenMP] Fix KeepAlive usage
Joseph Huber [Wed, 22 Sep 2021 18:37:33 +0000 (14:37 -0400)]
[OpenMP] Fix KeepAlive usage

Summary:
Functions were called the wrong way around, this didn't keep the symbol
alive.

2 years agoDebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}
David Blaikie [Wed, 22 Sep 2021 03:25:13 +0000 (20:25 -0700)]
DebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}

This is to build the foundation of a new debug info feature to use only
the base name of template as its debug info name (eg: "t1" instead of
the full "t1<int>"). The intent being that a consumer can still retrieve
all that information from the DW_TAG_template_*_parameters.

So gno-simple-template-names is business as usual/previously ("t1<int>")
   =simple is the simplified name ("t1")
   =mangled is a special mode to communicate the full information, but
   also indicate that the name should be able to be simplified. The data
   is encoded as "_STNt1|<int>" which will be matched with an
   llvm-dwarfdump --verify feature to deconstruct this name, rebuild the
   original name, and then try to rebuild the simple name via the DWARF
   tags - then compare the latter and the former to ensure that all the
   data necessary to fully rebuild the name is present.

2 years ago[lldb] Remove IRExecutionUnit::CollectFallbackNames
Alex Langford [Wed, 15 Sep 2021 21:36:49 +0000 (14:36 -0700)]
[lldb] Remove IRExecutionUnit::CollectFallbackNames

The work that IRExecutionUnit::CollectFallbackNames is basically the
work that `CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments`
does already. It's also (at time or writing) specific to C++, so it can
be folded into `IRExecutionUnit::CollectCandidateCPlusPlusNames`.

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

2 years agoMark CFG as preserved in TypePromotion and InterleaveAccess passes
David Green [Wed, 22 Sep 2021 17:58:00 +0000 (18:58 +0100)]
Mark CFG as preserved in TypePromotion and InterleaveAccess passes

Neither of these passes modify the CFG, allowing us to preserve DomTree
and LoopInfo across them by using setPreservesCFG.

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

2 years agoChange error for storage-class to mean linkage, fix lang-linkage diag
Erich Keane [Wed, 22 Sep 2021 14:25:50 +0000 (07:25 -0700)]
Change error for storage-class to mean linkage, fix lang-linkage diag

Allow multiversioning declarations to match when the actual formal
linkage matches, not just when the storage class is identical.
Additionally, change the ambiguous 'linkage' mismatch to be more
specific and say 'language linkage'.

2 years ago[Analysis] improve function matching for strlen libcall
Sanjay Patel [Wed, 22 Sep 2021 17:24:51 +0000 (13:24 -0400)]
[Analysis] improve function matching for strlen libcall

The return type of strlen is size_t, not just any integer.

This is a partial fix for an example based on:
https://llvm.org/PR50836

There's another bug here because we can still crash
processing a real strlen or something that looks like it.

2 years agoDon't diagnose unused but set when the Cleanup attribute is used.
Michael Benfield [Wed, 15 Sep 2021 22:57:41 +0000 (22:57 +0000)]
Don't diagnose unused but set when the Cleanup attribute is used.

This applies to -Wunused-but-set-variable and
-Wunused-but-set-parameter.

This addresses bug 51865.

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

2 years ago[mlir][linalg] Fix interchange initialization in fusion on tensors.
Tobias Gysi [Wed, 22 Sep 2021 17:27:10 +0000 (17:27 +0000)]
[mlir][linalg] Fix interchange initialization in fusion on tensors.

If no interchange vector is given initialize it with the identity permutation from 0 to number of loops.

Reviewed By: mravishankar

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

2 years ago[llvm-profgen] An option to dump disasm of specified symbols
Hongtao Yu [Wed, 22 Sep 2021 16:11:53 +0000 (09:11 -0700)]
[llvm-profgen] An option to dump disasm of specified symbols

For large app, dumping disasm of the whole program can be slow and result in gianant output. Adding a switch to dump specific symbols only.

Reviewed By: wlei

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

2 years ago[NFCI][CodeGen, AArch64] Fix inconsistent TargetCostKind types.
Daniil Fukalov [Mon, 20 Sep 2021 19:33:38 +0000 (22:33 +0300)]
[NFCI][CodeGen, AArch64] Fix inconsistent TargetCostKind types.

The pass uses different cost kinds to estimate "old" and "interleaved" costs:
default cost kind for all targets override `getInterleavedMemoryOpCost()` is
`TCK_SizeAndLatency`. Although at the moment estimated `TCK_Latency` costs are
equal to `TCK_SizeAndLatency`, (so the change is NFC) it may change in future.

Reviewed By: RKSimon

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

2 years agoAdd document numbers for the C99 status page.
Aaron Ballman [Wed, 22 Sep 2021 17:00:13 +0000 (13:00 -0400)]
Add document numbers for the C99 status page.

This doesn't add all of the document numbers, but it adds a bunch of
them. Not all of the documents are available on the committee page
(they're old enough that they come from a time when the mailing was
comprised of physical pieces of paper), so some of the documents listed
are assumed to be correct based on my reading of editor's reports.

2 years ago[SimplifyCFG] Ignore free instructions when computing cost for folding branch to...
Arthur Eubanks [Fri, 27 Aug 2021 19:32:59 +0000 (12:32 -0700)]
[SimplifyCFG] Ignore free instructions when computing cost for folding branch to common dest

When determining whether to fold branches to a common destination by
merging two blocks, SimplifyCFG will count the number of instructions to
be moved into the first basic block. However, there's no reason to count
free instructions like bitcasts and other similar instructions.

This resolves missed branch foldings with -fstrict-vtable-pointers in
llvm-test-suite's lambda benchmark.

Reviewed By: spatel

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

2 years ago[libc] Add an implementation of bsearch.
Siva Chandra Reddy [Tue, 21 Sep 2021 23:53:30 +0000 (23:53 +0000)]
[libc] Add an implementation of bsearch.

Reviewed By: michaelrj

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

2 years ago[HWASan] Use a single .weak binding in asm.
Matt Morehouse [Wed, 22 Sep 2021 16:34:49 +0000 (09:34 -0700)]
[HWASan] Use a single .weak binding in asm.

Specifying .global and .weak causes a compiler warning:

  warning: __sigsetjmp changed binding to STB_WEAK

Specifying only .weak should have the same effect without causing a
warning.

Reviewed By: eugenis

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

2 years ago[ORC] DebugObjectManagerPlugin tests can use lli in ORC greedy mode
Stefan Gränitz [Wed, 22 Sep 2021 15:46:08 +0000 (17:46 +0200)]
[ORC] DebugObjectManagerPlugin tests can use lli in ORC greedy mode

Initially, lli only supported lazy mode for ORC. Greedy mode was added with e1579894d205 and it's the default setting now. DebugObjectManagerPlugin tests don't rely on laziness, so we can switch them to greedy in order to avoid some unnecessary complexity.

2 years ago[OpenMP] Add function tracing debugging to device RTL
Joseph Huber [Tue, 21 Sep 2021 21:34:11 +0000 (17:34 -0400)]
[OpenMP] Add function tracing debugging to device RTL

This patch adds support for an RAII struct that will print function
traces when placed inside of a function declaration. Each successive
call will increase the indentation to make it easier to visually
inspect.

Reviewed By: jdoerfert

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

2 years ago[mlir][sparse] replace ad-hoc MemRef struct with CRunnerUtils definition
Aart Bik [Wed, 22 Sep 2021 05:56:00 +0000 (22:56 -0700)]
[mlir][sparse] replace ad-hoc MemRef struct with CRunnerUtils definition

This revision removes the ad-hoc MemRefs that were needed using the old
ABI (when we still passed by value) and replaces them with the shared
StridedMemRef definitions of CRunnerUtils (possible now that we pass by
pointer). This avoids code duplication and makes sure we have a consistent
view of strided memory references in all our support libraries.

Reviewed By: jsetoain

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

2 years ago[RISCV] Optimize vp.store with an all ones mask to avoid a vmset.
Craig Topper [Wed, 22 Sep 2021 16:12:45 +0000 (09:12 -0700)]
[RISCV] Optimize vp.store with an all ones mask to avoid a vmset.

We can use riscv_vse intrinsic instead of riscv_vse_mask. The code here
is based on similar code for handling masked.scatter and vp.scatter.

Reviewed By: frasercrmck

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

2 years ago[NFC] clang-format -i llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Shilei Tian [Wed, 22 Sep 2021 16:10:02 +0000 (12:10 -0400)]
[NFC] clang-format -i llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

2 years ago[CSSPGO] Set PseudoProbeInserter as a default pass.
Hongtao Yu [Wed, 22 Sep 2021 00:16:45 +0000 (17:16 -0700)]
[CSSPGO] Set PseudoProbeInserter as a default pass.

Currenlty PseudoProbeInserter is a pass conditioned on a target switch. It works well with a single clang invocation. It doesn't work so well when the backend is called separately (i.e, through the linker or llc), where user has always to pass -pseudo-probe-for-profiling explictly. I'm making the pass a default pass that requires no command line arg to trigger, but will be actually run depending on whether the CU comes with `llvm.pseudo_probe_desc` metadata.

Reviewed By: wenlei

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

2 years ago[SLP][NFC]Add a test to show an issue with incorrectly extracted
Alexey Bataev [Wed, 22 Sep 2021 15:08:40 +0000 (08:08 -0700)]
[SLP][NFC]Add a test to show an issue with incorrectly extracted
pointers.

2 years ago[CodeGen] Remove redundant declaration MIRCanonicalizerID (NFC)
Kazu Hirata [Wed, 22 Sep 2021 15:58:26 +0000 (08:58 -0700)]
[CodeGen] Remove redundant declaration MIRCanonicalizerID (NFC)

Note that MIRCanonicalizerID is declared in
llvm/include/llvm/CodeGen/Passes.h, which MIRCanonicalizerPass.cpp
includes.

Identified with readability-redundant-declaration.

2 years ago[ORC] Re-enable ELF DebugObjectManagerPlugin tests
Stefan Gränitz [Wed, 22 Sep 2021 15:35:26 +0000 (17:35 +0200)]
[ORC] Re-enable ELF DebugObjectManagerPlugin tests

These tests were disabled by accident after D107640. Actually, REQUIRES lines don't support `x86_64` and so these tests stopped running on all targets.
`native && target-x86_64` should be the correct term to express "x86_64 host targeting native arch".

2 years ago[SLP] getReductionCost - use explicit TTI::TCK_RecipThroughput CostKind. NFCI.
Simon Pilgrim [Wed, 22 Sep 2021 15:48:01 +0000 (16:48 +0100)]
[SLP] getReductionCost - use explicit TTI::TCK_RecipThroughput CostKind. NFCI.

Avoid relying on the default cost kinds in TTI calls (we already do this in other places in SLP) - noticed while trying to see how much work it'd be to extend D110242 and remove all remaining uses of default CostKind arguments.

2 years ago[InstCombine] Update InstCombine to use poison instead of undef for shufflevector...
hyeongyu kim [Wed, 22 Sep 2021 15:23:31 +0000 (00:23 +0900)]
[InstCombine] Update InstCombine to use poison instead of undef for shufflevector's placeholder (3/3)

This patch is for fixing potential shufflevector-related bugs like D93818.
As D93818, this patch change shufflevector's default placeholder to poison.
To reduce risk, it was divided into several patches, and this patch is for InstCombineVectorOps.

Reviewed By: spatel

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

2 years ago[libc++] Disallow volatile types in std::allocator
Joe Loser [Wed, 22 Sep 2021 15:46:21 +0000 (11:46 -0400)]
[libc++] Disallow volatile types in std::allocator

LWG 2447 is marked as `Complete`, but there is no `static_assert` to
reject volatile types in `std::allocator`. See the discussion at
https://reviews.llvm.org/D108856.

Add `static_assert` in `std::allocator` to disallow volatile types. Since this
is an implementation choice, mark the binding test as `libc++` only.

Remove tests that use containers backed by `std::allocator` that test
the container when used with a volatile type.

Reviewed By: ldionne, #libc

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

2 years ago[OpenMP][Offloading] Use bitset to indicate execution mode instead of value
Shilei Tian [Wed, 22 Sep 2021 15:40:37 +0000 (11:40 -0400)]
[OpenMP][Offloading] Use bitset to indicate execution mode instead of value

The execution mode of a kernel is stored in a global variable, whose value means:
- 0 - SPMD mode
- 1 - indicates generic mode
- 2 - SPMD mode execution with generic mode semantics

We are going to add support for SIMD execution mode. It will be come with another
execution mode, such as SIMD-generic mode. As a result, this value-based indicator
is not flexible.

This patch changes to bitset based solution to encode execution mode. Each
position is:
[0] - generic mode
[1] - SPMD mode
[2] - SIMD mode (will be added later)

In this way, `0x1` is generic mode, `0x2` is SPMD mode, and `0x3` is SPMD mode
execution with generic mode semantics. In the future after we add the support for
SIMD mode, `0b1xx` will be in SIMD mode.

Reviewed By: jdoerfert

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

2 years ago[InstCombine] Update InstCombine to use poison instead of undef for shufflevector...
hyeongyu kim [Wed, 22 Sep 2021 14:30:33 +0000 (23:30 +0900)]
[InstCombine] Update InstCombine to use poison instead of undef for shufflevector's placeholder (2/3)

This patch is for fixing potential shufflevector-related bugs like D93818.
As D93818, this patch change shufflevector's default placeholder to poison.
To reduce risk, it was divided into several patches, and this patch is for InstCombineCompares and InstructionCombining.

Reviewed By: spatel

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

2 years ago[libc++][NFC] Add link to Discord channel from documentation
Louis Dionne [Wed, 22 Sep 2021 15:13:47 +0000 (11:13 -0400)]
[libc++][NFC] Add link to Discord channel from documentation

2 years ago[Sanitizer] Add Windows header for _mkdir
Teresa Johnson [Wed, 22 Sep 2021 15:04:08 +0000 (08:04 -0700)]
[Sanitizer] Add Windows header for _mkdir

This will hopefully fix the sanitizer_windows bot failure after D109794:
https://lab.llvm.org/buildbot/#/builders/127/builds/17222

2 years ago[Target][CodeGen] Remove default CostKind arguments on inner/impl TTI overrides
Simon Pilgrim [Wed, 22 Sep 2021 13:40:29 +0000 (14:40 +0100)]
[Target][CodeGen] Remove default CostKind arguments on inner/impl TTI overrides

Based off a discussion on D110100, we should be avoiding default CostKinds whenever possible.

This initial patch removes them from the 'inner' target implementation callbacks - these should only be used by the main TTI calls, so this should guarantee that we don't cause changes in CostKind by missing it in an inner call. This exposed a few missing arguments in getGEPCost and reduction cost calls that I've cleaned up.

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

2 years ago[InstCombine] Update InstCombine to use poison instead of undef for shufflevector...
hyeongyu kim [Wed, 22 Sep 2021 13:39:54 +0000 (22:39 +0900)]
[InstCombine] Update InstCombine to use poison instead of undef for shufflevector's placeholder (1/3)

This patch is for fixing potential shufflevector-related bugs like D93818.
As D93818, this patch change shufflevector's default placeholder to poison.
To reduce risk, it was divided into several patches, and this patch is for InstCombineCasts.

Reviewed By: spatel

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

2 years ago[AArch64][SVE] NFC: Move extract_subvector tests around.
Sander de Smalen [Fri, 17 Sep 2021 14:14:24 +0000 (15:14 +0100)]
[AArch64][SVE] NFC: Move extract_subvector tests around.

This patch splits up sve-extract-vector.ll into
  * sve-extract-fixed-vector.ll
  * sve-extract-scalable-vector.ll

For testing extracts of a fixed-width or scalable sub-vector from a
scalable source vector, respectively.

2 years ago[OpenMP] Make sure the Thread ID function is not removed
Joseph Huber [Wed, 22 Sep 2021 13:20:49 +0000 (09:20 -0400)]
[OpenMP] Make sure the Thread ID function is not removed

Summary:
The thread ID function was reintroduced in D110195, but could
potentially be removed by the optimizer. Make the function noinline to
preserve the call sites and add it to the externalization RAII so its
definition is not removed by the attributor.

2 years ago[mailmap] Add entry for myself
Joseph Tremoulet [Wed, 22 Sep 2021 14:12:16 +0000 (10:12 -0400)]
[mailmap] Add entry for myself

2 years ago[AArch64][SVE] Add extract_subvector patterns for unpacked fp16 and bfloat types.
Sander de Smalen [Wed, 22 Sep 2021 13:25:14 +0000 (14:25 +0100)]
[AArch64][SVE] Add extract_subvector patterns for unpacked fp16 and bfloat types.

Reviewed By: david-arm

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

2 years ago[SelectionDAG] Remove PromoteIntOp_EXTRACT_SUBVECTOR.
Sander de Smalen [Wed, 22 Sep 2021 12:34:00 +0000 (13:34 +0100)]
[SelectionDAG] Remove PromoteIntOp_EXTRACT_SUBVECTOR.

This code seems untested and is likely obsolete, because this case
should already be handled by the code that legalizes the result type
of EXTRACT_SUBVECTOR.

Reviewed By: craig.topper

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

2 years agoAArch64: use indivisible cmpxchg for 128-bit atomic loads at O0
Tim Northover [Wed, 22 Sep 2021 12:06:55 +0000 (13:06 +0100)]
AArch64: use indivisible cmpxchg for 128-bit atomic loads at O0

Like normal atomicrmw operations, at -O0 the simple register-allocator can
insert spills into the LL/SC loop if it's expanded and visible when regalloc
runs. This can cause the operation to never succeed by repeatedly clearing the
monitor. Instead expand to a cmpxchg, which has a pseudo-instruction for -O0.

2 years ago[ELF][test] Restore important part of ICF alignment test
Andrew Ng [Mon, 20 Sep 2021 18:13:30 +0000 (19:13 +0100)]
[ELF][test] Restore important part of ICF alignment test

Restore the checking of addresses in ICF test which was testing the
behaviour of ICF with regards to different alignments of otherwise
identical sections. Also make the test more robust to layout changes.

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

2 years ago[SLP][NFC]Rename function in the test for better matching of the
Alexey Bataev [Wed, 22 Sep 2021 12:50:14 +0000 (05:50 -0700)]
[SLP][NFC]Rename function in the test for better matching of the
transformation.

2 years ago[lldb] JITLoaderGDB tests can use lli in ORC greedy mode
Stefan Gränitz [Wed, 22 Sep 2021 11:54:26 +0000 (13:54 +0200)]
[lldb] JITLoaderGDB tests can use lli in ORC greedy mode

At first, lli only supported lazy mode for ORC. Greedy mode was added with e1579894d205 and is the default settings now. JITLoaderGDB tests don't rely on laziness, so we can switch them to greedy and remove some complexity.

2 years ago[SelectionDAG] Add PromoteIntOp_INSERT_SUBVECTOR.
Sander de Smalen [Wed, 22 Sep 2021 09:59:21 +0000 (10:59 +0100)]
[SelectionDAG] Add PromoteIntOp_INSERT_SUBVECTOR.

This is required to codegen something like:
  <vscale x 8 x i16> @llvm.experimental.vector.insert(<vscale x 8 x i16> %vec,
                                                      <vscale x 2 x i16> %subvec,
                                                      i64 %idx)
where the output vector is legal, but the input vector needs promoting.

It implements this by performing the whole operation on the promoted type,
and then truncating the result.

Reviewed By: david-arm, craig.topper

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

2 years ago[gn build] Port 7a320b279d07
LLVM GN Syncbot [Wed, 22 Sep 2021 12:20:22 +0000 (12:20 +0000)]
[gn build] Port 7a320b279d07

2 years ago[gn build] (manually) port f8b1cc365786
Nico Weber [Wed, 22 Sep 2021 12:20:12 +0000 (08:20 -0400)]
[gn build] (manually) port f8b1cc365786

2 years ago[Passes] Run vector-combine early with -fenable-matrix.
Florian Hahn [Wed, 22 Sep 2021 11:29:48 +0000 (12:29 +0100)]
[Passes] Run vector-combine early with -fenable-matrix.

IR with matrix intrinsics is likely to also contain large vector
operations, which can benefit from early simplifications.

This is the last step in a series of changes to improve code-gen for
code using matrix subscript operators with the C/C++ matrix extension in
CLang, like

    using matrix_t = double __attribute__((matrix_type(15, 15)));

    void foo(unsigned i, matrix_t &A, matrix_t &B) {
      for (unsigned j = 0; j < 4; ++j)
        for (unsigned k = 0; k < i; k++)
          B[k][j] -= A[k][j] * B[i][j];
    }

https://clang.godbolt.org/z/6dKxK1Ed7

Reviewed By: spatel

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

2 years agoRevert "[InstCombine] fold cast of right-shift if high bits are not demanded"
Sanjay Patel [Wed, 22 Sep 2021 11:44:17 +0000 (07:44 -0400)]
Revert "[InstCombine] fold cast of right-shift if high bits are not demanded"

This reverts commit 2f6b07316f560a1f6d225919019dff2e5d6346e5.

This caused several bots to hit an infinite loop at stage 2,
so it needs to be reverted while figuring out how to fix that.

2 years agoRevert "[CodeGen] regenerate test checks; NFC"
Sanjay Patel [Wed, 22 Sep 2021 11:42:12 +0000 (07:42 -0400)]
Revert "[CodeGen] regenerate test checks; NFC"

This reverts commit 52832cd917af00e2b9c6a9d1476ba79754dcabff.
The motivating commit 2f6b07316f5 caused several bots to hit
an infinite loop at stage 2, so that needs to be reverted too
while figuring out how to fix that.

2 years ago[Matrix] Emit assumption that matrix indices are valid.
Florian Hahn [Wed, 22 Sep 2021 09:28:36 +0000 (10:28 +0100)]
[Matrix] Emit assumption that matrix indices are valid.

The matrix extension requires the indices for matrix subscript
expression to be valid and it is UB otherwise.

extract/insertelement produce poison if the index is invalid, which
limits the optimizer to not be bale to scalarize load/extract pairs for
example, which causes very suboptimal code to be generated when using
matrix subscript expressions with variable indices for large matrixes.

This patch updates IRGen to emit assumes to for index expression to
convey the information that the index must be valid.

This also adjusts the order in which operations are emitted slightly, so
indices & assumes are added before the load of the matrix value.

Reviewed By: erichkeane

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

2 years ago[lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64
Martin Storsjö [Tue, 14 Sep 2021 10:50:41 +0000 (13:50 +0300)]
[lldb] [Windows] Fix continuing from breakpoints and singlestepping on ARM/AArch64

Based on suggestions by Eric Youngdale.

This fixes https://llvm.org/PR51673.

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

2 years ago[ARM] Allow smaller VMOVL in tail predicated loops
David Green [Wed, 22 Sep 2021 11:07:52 +0000 (12:07 +0100)]
[ARM] Allow smaller VMOVL in tail predicated loops

This allows VMOVL in tail predicated loops so long as the the vector
size the VMOVL is extending into is less than or equal to the size of
the VCTP in the tail predicated loop. These cases represent a
sign-extend-inreg (or zero-extend-inreg), which needn't block tail
predication as in https://godbolt.org/z/hdTsEbx8Y.

For this a vecsize has been added to the TSFlag bits of MVE
instructions, which stores the size of the elements that the MVE
instruction operates on. In the case of multiple size (such as a
MVE_VMOVLs8bh that extends from i8 to i16, the largest size was be
chosen). The sizes are encoded as 00 = i8, 01 = i16, 10 = i32 and 11 =
i64, which often (but not always) comes from the instruction encoding
directly. A unit test was added, and although only a subset of the
vecsizes are currently used, the rest should be useful for other cases.

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

2 years agoUnbreak module builds by making InstructionWorklist.h non-modular
Raphael Isemann [Wed, 22 Sep 2021 10:14:50 +0000 (12:14 +0200)]
Unbreak module builds by making InstructionWorklist.h non-modular

This regressed in D110181 and apparently the header intentionally requires
DEBUG_TYPE to be defined by the including file. Just exclude the header from
the module to unbreak the build.

2 years agoDon't fold (select C, (gep Ptr, Idx), Ptr) if C is vector but Idx is scalar
Yi Kong [Wed, 22 Sep 2021 07:50:12 +0000 (15:50 +0800)]
Don't fold (select C, (gep Ptr, Idx), Ptr) if C is vector but Idx is scalar

The folding rule (select C, (gep Ptr, Idx), Ptr) -> (gep Ptr, (select C,
Idx, 0)) creates a malformed SELECT IR if C is a vector while Idx is scalar.

  SELECT VecC, ScalarIdx, 0

We could splat Idx to a vector but it defeats the purpose of
optimisation. Don't apply the folding rule in this case.

This fixes a regression from commit d561b6fbdbe6d1da05fd92003a4ac1e37bf4b8bc.

2 years ago[hwasan] also omit safe mem[cpy|mov|set].
Florian Mayer [Wed, 15 Sep 2021 09:10:11 +0000 (10:10 +0100)]
[hwasan] also omit safe mem[cpy|mov|set].

Reviewed By: eugenis

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

2 years ago[SelectionDAG] Make WidenVecRes_Convert work for scalable vectors.
Sander de Smalen [Wed, 22 Sep 2021 08:47:16 +0000 (09:47 +0100)]
[SelectionDAG] Make WidenVecRes_Convert work for scalable vectors.

Most of the code wasn't yet scalable safe, although most of the
code conceptually just works for scalable vectors. This change
makes the algorithm work on ElementCount, where appropriate,
and leaves the fixed-width only code to use `getFixedNumElements`.

Reviewed By: david-arm

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

2 years ago[LoopVectorize][X86] Add operands to make it more obvious what line the CHECK concerns
Simon Pilgrim [Wed, 22 Sep 2021 09:08:14 +0000 (10:08 +0100)]
[LoopVectorize][X86] Add operands to make it more obvious what line the CHECK concerns

As we're checking the cost debug analysis these should match the original IR line - so we shouldn't have any variable naming issues.

I'm investigating v4i32 mul -> PMADDDW costs handling (for PR47437) and these CHECK lines were proving tricky to keep track of

2 years ago[VectorCombine] Switch to using a worklist.
Florian Hahn [Wed, 22 Sep 2021 08:30:53 +0000 (09:30 +0100)]
[VectorCombine] Switch to using a worklist.

This patch updates VectorCombine to use a worklist to allow iterative
simplifications where a combine enables other combines.

Suggested in D100302.

The main use case at the moment is foldSingleElementStore and
scalarizeLoadExtract working together to improve scalarization.

Note that we now also do not run SimplifyInstructionsInBlock on the
whole function if there have been changes. This means we fail to
remove/simplify instructions not related to any of the vector combines.
IMO this is fine, as simplifying the whole function seems more like a
workaround for not tracking the changed instructions.

Compile-time impact looks neutral:
NewPM-O3: +0.02%
NewPM-ReleaseThinLTO: -0.00%
NewPM-ReleaseLTO-g: -0.02%

http://llvm-compile-time-tracker.com/compare.php?from=52832cd917af00e2b9c6a9d1476ba79754dcabff&to=e66520a4637290550a945d528e3e59573485dd40&stat=instructions

Reviewed By: spatel, lebedev.ri

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

2 years ago[AArch64][SVE] Add missing load/store patterns for unpacked bfloat vectors.
Sander de Smalen [Tue, 21 Sep 2021 11:44:02 +0000 (12:44 +0100)]
[AArch64][SVE] Add missing load/store patterns for unpacked bfloat vectors.

Reviewed By: c-rhodes

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

2 years ago[AMDGPU] Convert mac/fmac to mad/fma when folding output modifiers
Jay Foad [Tue, 21 Sep 2021 12:03:23 +0000 (13:03 +0100)]
[AMDGPU] Convert mac/fmac to mad/fma when folding output modifiers

Use of output modifiers forces VOP3 encoding for a VOP2 mac/fmac
instruction, so we might as well convert it to the more flexible VOP3-
only mad/fma form.

With this change, the only way we should emit VOP3-encoded mac/fmac is
if regalloc chooses registers that require the VOP3 encoding, e.g. sgprs
for both src0 and src1. In all other cases the mac/fmac should either be
converted to mad/fma or shrunk to VOP2 encoding.

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

2 years ago[AMDGPU] Divergence-driven instruction selection for mul i32
Jay Foad [Thu, 16 Sep 2021 13:36:51 +0000 (14:36 +0100)]
[AMDGPU] Divergence-driven instruction selection for mul i32

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

2 years ago[ARM] Add additional tests for VMOVL in tail predicated loops.
David Green [Wed, 22 Sep 2021 08:33:36 +0000 (09:33 +0100)]
[ARM] Add additional tests for VMOVL in tail predicated loops.

2 years agotsan: write uptime in mem profile
Dmitry Vyukov [Tue, 21 Sep 2021 11:09:31 +0000 (13:09 +0200)]
tsan: write uptime in mem profile

Write uptime in real time seconds for every mem profile record.
Uptime is useful to make more sense out of the profile,
compare random lines, etc.

Depends on D110153.

Reviewed By: melver, vitalybuka

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

2 years agotsan: remove stale comment
Dmitry Vyukov [Tue, 21 Sep 2021 09:54:03 +0000 (11:54 +0200)]
tsan: remove stale comment

We do query it every 100ms now.
(GetRSS was fixed to not be dead slow IIRC)

Depends on D110152.

Reviewed By: melver, vitalybuka

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

2 years agotsan: move mem profile initialization into separate function
Dmitry Vyukov [Tue, 21 Sep 2021 09:50:09 +0000 (11:50 +0200)]
tsan: move mem profile initialization into separate function

BackgroundThread function is quite large,
move mem profile initialization into a separate function.

Depends on D110151.

Reviewed By: melver, vitalybuka

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

2 years agotsan: include internal allocator info in mem profile
Dmitry Vyukov [Tue, 21 Sep 2021 09:38:52 +0000 (11:38 +0200)]
tsan: include internal allocator info in mem profile

We allocate things from the internal allocator,
it's useful to know how much it consumes.

Depends on D110150.

Reviewed By: melver, vitalybuka

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

2 years agotsan: make mem profile data more consistent
Dmitry Vyukov [Tue, 21 Sep 2021 09:31:18 +0000 (11:31 +0200)]
tsan: make mem profile data more consistent

We currently query number of threads before reading /proc/self/smaps.
But reading /proc/self/smaps can take lots of time for huge processes
and it's retries several times with different buffer sizes.
Overall it can take tens of seconds. This can make number of threads
significantly inconsistent with the rest of the stats.
So query it after reading /proc/self/smaps.

Depends on D110149.

Reviewed By: melver, vitalybuka

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

2 years agotsan: include MBlock/SyncObj stats into mem profile
Dmitry Vyukov [Tue, 21 Sep 2021 08:49:32 +0000 (10:49 +0200)]
tsan: include MBlock/SyncObj stats into mem profile

Include info about MBlock/SyncObj memory consumption in the memory profile.

Depends on D110148.

Reviewed By: melver, vitalybuka

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

2 years agotsan: account for mid app range in mem profile
Dmitry Vyukov [Tue, 21 Sep 2021 08:37:33 +0000 (10:37 +0200)]
tsan: account for mid app range in mem profile

We account low and high ranges, but forgot abount the mid range.
Account mid range as well.

Reviewed By: melver

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

2 years ago[Utils] Replace llc with cat for tests
Sebastian Neubauer [Tue, 21 Sep 2021 14:31:00 +0000 (16:31 +0200)]
[Utils] Replace llc with cat for tests

Make the update_llc_test_checks script test independant of llc behavior
by using cat with static files to simulate llc output.

This allows changing llc without breaking the script test case.

The update script is executed in a temporary directory, so the
llc-generated assembly files are copied there. %T is deprecated, but it
allows copying a file with a predictable filename.

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

2 years ago[clang][ASTImporter] Generic attribute import handling (first step).
Balázs Kéri [Wed, 22 Sep 2021 07:15:29 +0000 (09:15 +0200)]
[clang][ASTImporter] Generic attribute import handling (first step).

Import of Attr objects was incomplete in ASTImporter.
This change introduces support for a generic way of importing an attribute.
For an usage example import of the attribute AssertCapability is
added to ASTImporter.
Updating the old attribute import code and adding new attributes or extending
the generic functions (if needed) is future work.

Reviewed By: steakhal, martong

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

2 years ago[InstCombine] Move InstCombineWorklist to Utils to allow reuse (NFC).
Florian Hahn [Wed, 22 Sep 2021 07:19:01 +0000 (08:19 +0100)]
[InstCombine] Move InstCombineWorklist to Utils to allow reuse (NFC).

InstCombine's worklist can be re-used by other passes like
VectorCombine. Move it to llvm/Transform/Utils and rename it to
InstructionWorklist.

Reviewed By: lebedev.ri

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

2 years ago[flang] Change complex type define in runtime for clang-cl
Diana Picus [Tue, 21 Sep 2021 08:57:38 +0000 (08:57 +0000)]
[flang] Change complex type define in runtime for clang-cl

When compiling the runtime with a version of clang-cl newer than 12, we
define CMPLXF as __builtin_complex, which returns a float _Complex type.
This errors out in contexts where the result of CMPLXF is expected to be
a float_Complex_t. This is defined as _Fcomplex whenever _MSC_VER is
defined (and as float _Complex otherwise).

This patch defines float_Complex_t & friends as _Fcomplex only when
we're using "true" MSVC, and not just clang-pretending-to-be-MSVC. This
should only affect clang-cl >= 12.

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

2 years ago[lldb] Add --stack option to `target symbols add` command
Jonas Devlieghere [Wed, 22 Sep 2021 05:08:48 +0000 (22:08 -0700)]
[lldb] Add --stack option to `target symbols add` command

Currently you can ask the target symbols add command to locate the debug
symbols for the current frame. This patch add an options to do that for
the whole call stack.

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

2 years agotsan: prepare for trace mapping removal
Dmitry Vyukov [Tue, 21 Sep 2021 19:26:13 +0000 (21:26 +0200)]
tsan: prepare for trace mapping removal

Don't test for presence of the trace mapping,
it will be removed soon.

Reviewed By: vitalybuka

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

2 years agotsan: uninline Enable/DisableIgnores
Dmitry Vyukov [Tue, 21 Sep 2021 12:13:12 +0000 (14:13 +0200)]
tsan: uninline Enable/DisableIgnores

ScopedInterceptor::Enable/DisableIgnores is only used for some special cases.
Unline them from the common interceptor handling.

Reviewed By: vitalybuka

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

2 years agotsan: reset destination range in Java heap move
Dmitry Vyukov [Tue, 21 Sep 2021 19:07:43 +0000 (21:07 +0200)]
tsan: reset destination range in Java heap move

Switch Java heap move to the new scheme required for the new tsan runtime.
Instead of copying the shadow we reset the destination range.
The new v3 trace contains addresses of accesses, so we cannot simply copy the shadow.
This can lead to false negatives, but cannot lead to false positives.

Depends on D110159.

Reviewed By: vitalybuka

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

2 years ago[Polly] Add -polly-reschedule and -polly-postopts options.
Michael Kruse [Wed, 22 Sep 2021 04:56:24 +0000 (23:56 -0500)]
[Polly] Add -polly-reschedule and -polly-postopts options.

This command line options allow to off parts of the schedule tree optimization pipeline.

2 years agotsan: enable sse4.2 in tests
Dmitry Vyukov [Tue, 21 Sep 2021 19:17:28 +0000 (21:17 +0200)]
tsan: enable sse4.2 in tests

Pass -msse4.2 flag to the tests the same way we do for the runtime.
Layout of some structs in the runtime headers depends on the flag
(TSAN_VECTORIZE), so we need it to be consistent across the runtime
and tests.

Reviewed By: vitalybuka

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

2 years agotsan: move errno spoiling reporting into a separate function (NFC)
Dmitry Vyukov [Tue, 21 Sep 2021 12:18:44 +0000 (14:18 +0200)]
tsan: move errno spoiling reporting into a separate function (NFC)

CallUserSignalHandler function is quite large and complex.
Move errno spoiling reporting into a separate function.
No logical changes.

Reviewed By: vitalybuka

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

2 years agotsan: don't call dlsym during exit
Dmitry Vyukov [Tue, 21 Sep 2021 13:22:35 +0000 (15:22 +0200)]
tsan: don't call dlsym during exit

dlsym calls into dynamic linker which calls malloc and other things.
It's problematic to do it during the actual exit, because
it can happen from a singal handler or from within the runtime
after we reported the first bug, etc.
See https://github.com/google/sanitizers/issues/1440 for an example
(captured in the added test).
Initialize the callbacks during startup instead.

Depends on D110159.

Reviewed By: vitalybuka

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

2 years ago[PowerPC] add testcase for chain commoning; nfc
Chen Zheng [Wed, 22 Sep 2021 05:02:12 +0000 (05:02 +0000)]
[PowerPC] add testcase for chain commoning; nfc

2 years ago[mlir][sparse] cleanup ABI issues in C interface with memrefs
Aart Bik [Wed, 22 Sep 2021 04:00:26 +0000 (21:00 -0700)]
[mlir][sparse] cleanup ABI issues in C interface with memrefs

This change adds automatic wrapper functoins with emit_c_interface
to all methods in the sparse support library that deal with MEMREFs.
The wrappers will take care of passing MEMREFs by value internally
and by pointer externally, thereby avoiding ABI issues across platforms.

Reviewed By: mehdi_amini

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

2 years ago[RISCV][NFC] Fix clang test for vloxei/vluxei
Shao-Ce SUN [Wed, 22 Sep 2021 03:27:41 +0000 (11:27 +0800)]
[RISCV][NFC] Fix clang test for vloxei/vluxei

2 years ago[libc++] Add some missing _LIBCPP_HIDE_FROM_ABI markup
Louis Dionne [Tue, 21 Sep 2021 22:57:21 +0000 (18:57 -0400)]
[libc++] Add some missing _LIBCPP_HIDE_FROM_ABI markup

Also, as a fly-by fix, use `inline` directly to define inline variables
(all compilers support it).

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

2 years agoDebugInfo: Don't use preferred template names in debug info
David Blaikie [Mon, 20 Sep 2021 03:34:45 +0000 (20:34 -0700)]
DebugInfo: Don't use preferred template names in debug info

Using the preferred name creates a mismatch between the textual name of
a type and the DWARF tags describing the parameters as well as possible
inconsistency between DWARF producers (like Clang and GCC, or
older/newer Clang versions, etc).

2 years ago[RISCV] add Half-precision test for clang
Shao-Ce SUN [Fri, 17 Sep 2021 02:11:08 +0000 (10:11 +0800)]
[RISCV] add Half-precision test for clang

and deleted useless lines.

Reviewed By: craig.topper

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

2 years agoAMDGPU: Refactor getWavesPerEU to separate flat workgroup size query
Matt Arsenault [Thu, 16 Sep 2021 21:49:50 +0000 (17:49 -0400)]
AMDGPU: Refactor getWavesPerEU to separate flat workgroup size query

Add an overload to pass the flat workgroup range in separately. This
will allow the attributor to use the assumed value for
amdgpu-flat-workgroup-sizes when inferring amdgpu-waves-per-eu.

2 years ago[PowerPC] prepare for udpate form with non-const increment.
Chen Zheng [Wed, 22 Sep 2021 01:54:12 +0000 (01:54 +0000)]
[PowerPC] prepare for udpate form with non-const increment.

This is a follow-up of D105872. Now we are able to prepare for update
form with non-const increment.

Reviewed By: jsji

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

2 years ago[libc++][test] Fix iterator assertion in span.cons/deduct.pass.cpp
Joe Loser [Wed, 22 Sep 2021 02:45:32 +0000 (22:45 -0400)]
[libc++][test] Fix iterator assertion in span.cons/deduct.pass.cpp

Two tests in span.cons/deduct.pass.cpp accidentally check whether the
iterator range from member begin and member end are equivalent to the
ones from free begin and free end. This is obviously true and not
intended. Correct the intent by comparing the size/data from the span
with the source input.

While in the neighborhood, add test for const int arr[N], remove extraneous
type aliases, unused <type_traits> header, and the
disable_missing_braces_warning.h include.

Reviewed By: Quuxplusone, ldionne, #libc

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

2 years agoAMDGPU: Fix test relying on incompatible attributes
Matt Arsenault [Mon, 13 Sep 2021 16:49:45 +0000 (12:49 -0400)]
AMDGPU: Fix test relying on incompatible attributes

This combination of amdgpu-waves-per-eu and
amdgpu-flat-work-group-size cannot be satisfied at the same time, so
this was using the default.

2 years agoDebugInfo: Don't suppress inline namespaces when printing template template parameter...
David Blaikie [Wed, 22 Sep 2021 02:25:33 +0000 (19:25 -0700)]
DebugInfo: Don't suppress inline namespaces when printing template template parameter names

2 years agoDebugInfo: Unify some printing policy adjustments
David Blaikie [Wed, 22 Sep 2021 02:29:07 +0000 (19:29 -0700)]
DebugInfo: Unify some printing policy adjustments

2 years ago[NFC] Fix typo.
Shao-Ce SUN [Wed, 22 Sep 2021 02:27:11 +0000 (10:27 +0800)]
[NFC] Fix typo.

2 years ago[RISCV][NFC] Deleted useless lines in clang tests.
Shao-Ce SUN [Wed, 22 Sep 2021 02:25:57 +0000 (10:25 +0800)]
[RISCV][NFC] Deleted useless lines in clang tests.

2 years ago[Sanitizer] Modify test to avoid bot timeouts
Teresa Johnson [Wed, 22 Sep 2021 01:32:26 +0000 (18:32 -0700)]
[Sanitizer] Modify test to avoid bot timeouts

Change the mutex type to one that initializes on construction and
hopefully avoid what appear to be deadlock failures in the new test
on a couple bots, e.g.:

https://green.lab.llvm.org/green/job/clang-stage1-RA/24140/testReport/SanitizerCommon-Unit/__Sanitizer-x86_64-Test/SanitizerCommon_ReportFile/

2 years ago[DialectAsmPrinter] Add missing 'printAttributeWithoutType' member.
Chris Lattner [Wed, 22 Sep 2021 01:06:02 +0000 (18:06 -0700)]
[DialectAsmPrinter] Add missing 'printAttributeWithoutType' member.

DialectAsmParser has a `parseAttribute` member that takes a
contextual type, but DialectAsmPrinter doesn't have the corresponding
member to take advantage of it.  As such, custom attribute
implementations can't really use it.  This adds the obvious missing
method which fills this hole.

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