platform/upstream/llvm.git
3 years ago[SLP]Allow masked gathers only if allowed by target.
Alexey Bataev [Mon, 3 May 2021 14:23:29 +0000 (07:23 -0700)]
[SLP]Allow masked gathers only if allowed by target.

Need to check if target allows/supports masked gathers before trying to
estimate its cost, otherwise we may fail to vectorize some of the
patterns because of too pessimistic cost model.

Part of D57059.

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

3 years ago[InstCombine] cttz(zext(x)) -> zext(cttz(x)) if the 'ZeroIsUndef' parameter is 'true...
Dávid Bolvanský [Mon, 3 May 2021 15:04:50 +0000 (17:04 +0200)]
[InstCombine] cttz(zext(x)) -> zext(cttz(x)) if the 'ZeroIsUndef' parameter is 'true' (PR50172)

Zext doesn't change the number of trailing zeros, so narrow cttz(zext(x)) -> zext(cttz(x)) if the 'ZeroIsUndef' parameter is 'true'.

Proofs:
https://alive2.llvm.org/ce/z/o2dnjY

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

Reviewed By: spatel

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

3 years agoPartial revert of "Use std::foo_t rather than std::foo in LLVM." in googlebench
Jon Roelofs [Thu, 29 Apr 2021 22:36:24 +0000 (15:36 -0700)]
Partial revert of "Use std::foo_t rather than std::foo in LLVM." in googlebench

Since googlebench builds as c++11, the change there is incorrect and breaks the
googlebench build when the STL implementation is strict about std::enable_if_t
not being available in lesser c++ versions.

partial revert of: 1bd6123b781120c9190b9ba58b900cdcb718cdd1 (https://reviews.llvm.org/D74384)

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

3 years ago[libc++] Acquire locks on Ranges work
Louis Dionne [Fri, 30 Apr 2021 22:03:17 +0000 (18:03 -0400)]
[libc++] Acquire locks on Ranges work

This commit acquires locks on a few elements of Ranges to make sure we don't
duplicate work.

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

3 years ago[Matrix] Remove bitcast when casting between matrices of the same size
Saurabh Jha [Mon, 3 May 2021 13:57:31 +0000 (14:57 +0100)]
[Matrix] Remove bitcast when casting between matrices of the same size

In matrix type casts, we were doing bitcast when the matrices had the same size. This was incorrect and this patch fixes that.
Also added some new CodeGen tests for signed <-> usigned conversions

Reviewed By: fhahn

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

3 years agoRevert "[SLP]Allow masked gathers only if allowed by target."
Alexey Bataev [Mon, 3 May 2021 14:20:00 +0000 (07:20 -0700)]
Revert "[SLP]Allow masked gathers only if allowed by target."

This reverts commit b5f64768cfeecca16c7c9c53cbd97ac7289c43aa to fix
a compiler crash revealed by buildbots.

3 years ago[SLP]Allow masked gathers only if allowed by target.
Alexey Bataev [Mon, 26 Apr 2021 14:37:53 +0000 (07:37 -0700)]
[SLP]Allow masked gathers only if allowed by target.

Need to check if target allows/supports masked gathers before trying to
estimate its cost, otherwise we may fail to vectorize some of the
patterns because of too pessimistic cost model.

Part of D57059.

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

3 years agoAMDGPU: XFAIL LLVM::note-amd-valid-v2.test for big endian
Konstantin Zhuravlyov [Mon, 3 May 2021 13:44:16 +0000 (09:44 -0400)]
AMDGPU: XFAIL LLVM::note-amd-valid-v2.test for big endian

3 years ago[LV] Iterate over recipes in VPlan to fix PHI (NFC).
Florian Hahn [Mon, 3 May 2021 11:13:17 +0000 (12:13 +0100)]
[LV] Iterate over recipes in VPlan to fix PHI (NFC).

As we gradually move more elements of LV to VPlan, we are trying to
reduce the number of places that still has to check IR of the original
loop.

This patch adjusts the code to fix cross iteration phis to get the PHIs
to fix directly from the VPlan that is executed. We still need the
original PHI to check for first-order recurrences, but we can get rid of
that once we model that explicitly in VPlan as well.

Reviewed By: Ayal

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

3 years ago[gn build] Port 1527a5e4b483
LLVM GN Syncbot [Mon, 3 May 2021 12:53:10 +0000 (12:53 +0000)]
[gn build] Port 1527a5e4b483

3 years ago[SystemZ][z/OS] Add the functions needed for handling EBCDIC I/O
Abhina Sreeskantharajan [Mon, 3 May 2021 12:49:35 +0000 (08:49 -0400)]
[SystemZ][z/OS] Add the functions needed for handling EBCDIC I/O

This patch adds the basic functions needed for controlling auto conversion on z/OS.
Auto conversion is enabled on untagged input file to ASCII by making the assumption that all untagged files are EBCDIC encoded. Output files are auto converted to EBCDIC IBM-1047.
This change also enables conversion for stdin/stdout/stderr.

For more information on how fcntl controls codepage https://www.ibm.com/docs/en/zos/2.4.0?topic=descriptions-fcntl-bpx1fct-bpx4fct-control-open-file-descriptors

Reviewed By: anirudhp

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

3 years ago[InstCombine] improve demanded bits analysis of left-shifted operand
Sanjay Patel [Mon, 3 May 2021 12:17:14 +0000 (08:17 -0400)]
[InstCombine] improve demanded bits analysis of left-shifted operand

If we don't demand high bits, then we also don't care about those
high bits of a left-shift operand regardless of shift amount.
I noticed the sext/trunc pattern in a motivating example.
It seems like there should be a low-bits with right-shift sibling,
but I haven't looked at that yet.

https://alive2.llvm.org/ce/z/JuS6jc
https://rise4fun.com/Alive/Trm (not sure how to use 'width' with Alive1)
https://alive2.llvm.org/ce/z/gRadbF

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

3 years ago[clang] Spell correct variable
Nathan Sidwell [Mon, 3 May 2021 12:00:26 +0000 (05:00 -0700)]
[clang] Spell correct variable

fix Trailling -> Trailing (two ll-> one l)

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

3 years agoThread safety analysis: Fix false negative on break
Aaron Puchert [Mon, 3 May 2021 11:59:47 +0000 (13:59 +0200)]
Thread safety analysis: Fix false negative on break

We weren't modifying the lock set when intersecting with one coming
from a break-terminated block. This is inconsistent, since break isn't a
back edge, and it leads to false negatives with scoped locks. We usually
don't warn for those when joining locksets aren't the same, we just
silently remove locks that are not in the intersection. But not warning
and not removing them isn't right.

Reviewed By: aaron.ballman

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

3 years agoThread safety analysis: Replace flags in FactEntry by SourceKind (NFC)
Aaron Puchert [Mon, 3 May 2021 11:57:44 +0000 (13:57 +0200)]
Thread safety analysis: Replace flags in FactEntry by SourceKind (NFC)

The motivation here is to make it available in the base class whether a
fact is managed or not. That would have meant three flags on the base
class, so I had a look whether we really have 8 possible combinations.

It turns out we don't: asserted and declared are obviously mutually
exclusive. Managed facts are only created when we acquire a capability
through a scoped capability. Adopting an asserted or declared lock will
not (in fact can not, because Facts are immutable) make them managed.

We probably don't want to allow adopting an asserted lock (because then
the function should probably have a release attribute, and then the
assertion is pointless), but we might at some point decide to replace a
declared fact on adoption.

Reviewed By: aaron.ballman

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

3 years ago[clang-cl] Add parsing support for a bunch of new flags
Hans Wennborg [Wed, 28 Apr 2021 10:21:09 +0000 (12:21 +0200)]
[clang-cl] Add parsing support for a bunch of new flags

MSVC has added some new flags. Although they're not supported, this adds
parsing support for them so clang-cl doesn't treat them as filenames.

Except for /fsanitize=address which we do support. (clang-cl already
exposes the -fsanitize= option, but this allows using the
MSVC-spelling with a slash.)

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

3 years ago[clang] Remove libstdc++ friend template hack
Nathan Sidwell [Tue, 27 Apr 2021 19:03:40 +0000 (12:03 -0700)]
[clang] Remove libstdc++ friend template hack

this hack is for a now-unsupported version of libstdc++

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

3 years agoSupport AArch64 PAC elf-core register read
Muhammad Omair Javaid [Mon, 3 May 2021 10:59:30 +0000 (15:59 +0500)]
Support AArch64 PAC elf-core register read

This adds support for reading AArch64 Pointer Authentication regset
from elf-core file. Also includes a test-case for the same. Furthermore
there is also a slight refactoring of RegisterContextPOSIXCore_arm64
members and constructor. linux-aarch64-pac.core file is generated using
lldb/test/API/functionalities/postmortem/elf-core/main.c with following
clang arguments:
-march=armv8.5-a -mbranch-protection=pac-ret+leaf -nostdlib -static -g

Reviewed By: DavidSpickett

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

3 years ago[ARM] Memory operands for MVE gathers/scatters
David Green [Mon, 3 May 2021 10:24:59 +0000 (11:24 +0100)]
[ARM] Memory operands for MVE gathers/scatters

Similarly to D101096, this makes sure that MMO operands get propagated
through from MVE gathers/scatters to the Machine Instructions. This
allows extra scheduling freedom, not forcing the instructions to act as
scheduling barriers. We create MMO's with an unknown size, specifying
that they can load from anywhere in memory, similar to the masked_gather
or X86 intrinsics.

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

3 years ago[clang-tidy][NFC] Short circuit getting enum options suggestions.
Nathan James [Mon, 3 May 2021 10:20:20 +0000 (11:20 +0100)]
[clang-tidy][NFC] Short circuit getting enum options suggestions.

Use the MaxEditDistance to skip checking candidates we know we'll skip.

3 years ago[RISCV] Add support for fmin/fmax vector reductions
Fraser Cormack [Thu, 29 Apr 2021 10:35:33 +0000 (11:35 +0100)]
[RISCV] Add support for fmin/fmax vector reductions

Reviewed By: craig.topper

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

3 years ago[mlir] Allow lowering cmpi/cmpf with multidimensional vectors to LLVM
Benjamin Kramer [Thu, 29 Apr 2021 13:53:12 +0000 (15:53 +0200)]
[mlir] Allow lowering cmpi/cmpf with multidimensional vectors to LLVM

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

3 years ago[doc] typo fixes
Christian Kühnel [Mon, 3 May 2021 08:59:51 +0000 (10:59 +0200)]
[doc] typo fixes

as proposed by @FlashSheridan in
https://reviews.llvm.org/rG7f9717b922d4

3 years ago[libc] warns about missing linting only in full build mode
Guillaume Chatelet [Mon, 3 May 2021 08:39:26 +0000 (08:39 +0000)]
[libc] warns about missing linting only in full build mode

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

3 years ago[AMDGPU] Do not annotate features for graphics
Sebastian Neubauer [Mon, 3 May 2021 08:33:11 +0000 (10:33 +0200)]
[AMDGPU] Do not annotate features for graphics

SITargetLowering::LowerFormalArguments asserts that none of these
features are used for graphics calling conventions, so
AnnotateKernelFeatures should not add them.

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

3 years ago[flang] Fix a bug in the character runtime
Diana Picus [Tue, 27 Apr 2021 08:56:14 +0000 (08:56 +0000)]
[flang] Fix a bug in the character runtime

The number of bytes copied in CopyAndPad should depend on the size of
the type being copied, not on its shift value (which in the case of char
is 0, leading to no bytes at all being copied).

Add unit tests for CharacterMin and CharacterMax, which exercise this
code path.

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

3 years ago[flang] Fix handling of elem_len in CFI_establish
Diana Picus [Fri, 30 Apr 2021 18:22:01 +0000 (18:22 +0000)]
[flang] Fix handling of elem_len in CFI_establish

The current code computes the minimum element length based on the `type`
used to create the descriptor and uses that as the element length
whenever it is greater than 0. This means that the `elem_len` parameter
is essentially ignored for any type where we can compute a minimum
element length (which includes `CFI_type_char[16|32]_t`), and we may
therefore end up with descriptors with a lower element length than
expected.

This patch fixes the issue by explicitly doing what the standard says,
i.e. it uses the given `elem_len` for character types, `CFI_type_struct`
and `CFI_type_other`, and ignores it (falls back to the minimum element
length) for everything else.

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

3 years ago[flang] Use CFI_TYPE_LAST instead of CFI_type_struct
Diana Picus [Fri, 30 Apr 2021 17:21:56 +0000 (17:21 +0000)]
[flang] Use CFI_TYPE_LAST instead of CFI_type_struct

It looks like CFI_type_struct was once used as the last valid CFI_type
value, but in the meantime CFI_type_char16_t and CFI_type_char32_t were
added, making that assumption no longer true. Luckily, in the meantime
we also got a define for CFI_TYPE_LAST, which we can now use to allow
CFI_establish and CFI_allocate to work with descriptors of
CFI_type_char16_t, CFI_type_char32_t and any other future types.

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

3 years ago[clangd] Parameter hints for dependent calls
Nathan Ridge [Mon, 19 Apr 2021 07:25:57 +0000 (03:25 -0400)]
[clangd] Parameter hints for dependent calls

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

3 years ago[AMDGPU][OpenMP] Enable Libomptarget runtime tests
Pushpinder Singh [Wed, 28 Apr 2021 06:53:46 +0000 (06:53 +0000)]
[AMDGPU][OpenMP] Enable Libomptarget runtime tests

This enables the runtime tests on amdgpu targets.
10 tests have been marked as XFAIL on amdgcn currently mostly due to
missing printf.

Reviewed By: protze.joachim

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

3 years ago[clangd] Fix test failure in initialize-params.test
Nathan Ridge [Mon, 3 May 2021 05:36:08 +0000 (01:36 -0400)]
[clangd] Fix test failure in initialize-params.test

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

3 years ago[clangd] Fix build error in SemanticHighlighting.cpp
Nathan Ridge [Mon, 3 May 2021 05:18:49 +0000 (01:18 -0400)]
[clangd] Fix build error in SemanticHighlighting.cpp

3 years ago[clangd] Hide inlay hints capability behind a command-line flag
Nathan Ridge [Mon, 26 Apr 2021 03:46:51 +0000 (23:46 -0400)]
[clangd] Hide inlay hints capability behind a command-line flag

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

3 years ago[clangd] Avoid including HeuristicResolver.h from ParsedAST.h
Nathan Ridge [Mon, 26 Apr 2021 00:01:32 +0000 (20:01 -0400)]
[clangd] Avoid including HeuristicResolver.h from ParsedAST.h

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

3 years ago[ASAN][AMDGPU] Add support for accesses to global and constant addrspaces
Reshabh Sharma [Mon, 3 May 2021 03:31:15 +0000 (09:01 +0530)]
[ASAN][AMDGPU] Add support for accesses to global and constant addrspaces

Add address sanitizer instrumentation support for accesses to global
and constant address spaces in AMDGPU. It strictly avoids instrumenting
the stack and assumes x86 as the host.

Reviewed by: vitalybuka

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

3 years agoReland "AMDGPU/llvm-readobj: Add missing tests for note parsing/displaying"
Konstantin Zhuravlyov [Fri, 30 Apr 2021 19:20:28 +0000 (15:20 -0400)]
Reland "AMDGPU/llvm-readobj: Add missing tests for note parsing/displaying"

This reverts commit 54aad6365951247e9f18c718c14422745b3afa4c.

Includes fix for note-amd-valid-v3.s test.

3 years ago[Object] Fix e_machine description for EM_CR16 and add EM_MICROBLAZE
Sergio Perez Gonzalez [Mon, 3 May 2021 02:25:39 +0000 (19:25 -0700)]
[Object] Fix e_machine description for EM_CR16 and add EM_MICROBLAZE

Reviewed By: MaskRay

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

3 years ago[ARM] Transfer memory operands for VLDn
David Green [Sun, 2 May 2021 23:04:21 +0000 (00:04 +0100)]
[ARM] Transfer memory operands for VLDn

We create MMO's for the VLDn/VSTn intrinsics in ARMTargetLowering::
getTgtMemIntrinsic, but they do not currently make it ll the way through
ISel.  This changes that in the various places it needs changing, making
sure that the MMO is propagate through to the final instruction. This
can help in scheduling, not treating the VLD2/VST2 as a scheduling
barrier.

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

3 years ago[AArch64] Sets the preferred function alignment for Cortex-A53/A55.
Stelios Ioannou [Fri, 30 Apr 2021 16:55:35 +0000 (17:55 +0100)]
[AArch64] Sets the preferred function alignment for Cortex-A53/A55.

Setting the preffered function alignment to 16 for Cortex A53/A55
improves performance in a wide range of benchmarks. This brings it
in line with the Cortex-A53/A55 tuning that is used in GCC
(gcc/config/aarch64/aarch64.c).

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

Change-Id: I2ce47fe7ab5e3b54f49c89038d8da4e404742de2

3 years ago[TableGen] Use sign rotated VBR for OPC_EmitInteger.
Craig Topper [Sun, 2 May 2021 19:33:44 +0000 (12:33 -0700)]
[TableGen] Use sign rotated VBR for OPC_EmitInteger.

This allows for a much more efficient encoding for small negative
numbers by storing the sign bit first and negating the rest of
the bits. This was already being used for OPC_CheckInteger.

For every in tree target this affects, the table got smaller.
R600GenDAGISel.inc saw the largest reduction of 7K.

I did have to add a new opcode for StringIntegers used for
register class ids and subregister indices since we don't have the
integer value to encode. The enum name is emitted directly into
the table. Previously assumed the enum would expand to a positive
7-bit number. We might be able to just shift that right by 1 and
assume it is a positive 6 bit number, but that will need more
investigation.

3 years ago[RISCV] Store SEW in RISCV vector pseudo instructions in log2 form.
Craig Topper [Sun, 2 May 2021 19:01:18 +0000 (12:01 -0700)]
[RISCV] Store SEW in RISCV vector pseudo instructions in log2 form.

This shrinks the immediate that isel table needs to emit for these
instructions. Hoping this allows me to change OPC_EmitInteger to
use a better variable length encoding for representing negative
numbers. Similar to what was done a few months ago for OPC_CheckInteger.

The alternative encoding uses less bytes for negative numbers, but
increases the number of bytes need to encode 64 which was a very
common number in the RISCV table due to SEW=64. By using Log2 this
becomes 6 and is no longer a problem.

3 years ago[OpenMP] Fix warnings due to redundant semicolons. NFC.
Martin Storsjö [Sun, 2 May 2021 18:50:25 +0000 (21:50 +0300)]
[OpenMP] Fix warnings due to redundant semicolons. NFC.

3 years ago[NFC] Use Aliasee to determine Type and AddrSpace in GlobalAlias::create()
Arthur Eubanks [Sun, 2 May 2021 04:44:32 +0000 (21:44 -0700)]
[NFC] Use Aliasee to determine Type and AddrSpace in GlobalAlias::create()

As opposed to going through the Aliasee type.

For opaque pointers, we're trying to remove uses of PointerType::getElementType().

Reviewed By: dblaikie

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

3 years ago[VPlan] Add VPBasicBlock::phis() helper (NFC).
Florian Hahn [Sun, 2 May 2021 17:56:42 +0000 (18:56 +0100)]
[VPlan] Add VPBasicBlock::phis() helper (NFC).

This patch introduces a helper to obtain an iterator range for the
PHI-like recipes in a block.

Reviewed By: Ayal

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

3 years ago[RISCV] Reorder masked builtin operands. Use clang_builtin_alias for all overloaded...
Craig Topper [Sat, 1 May 2021 20:18:21 +0000 (13:18 -0700)]
[RISCV] Reorder masked builtin operands. Use clang_builtin_alias for all overloaded vector builtins.

This patch makes the builtin operand order match the C operand order
for all intrinsics. With this we can use clang_builtin_alias for
all overloaded intrinsics.

This should further reduce the test time for vector intrinsics.

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

3 years ago[libcxx][nfc] removes duplicate test file
Christopher Di Bella [Sun, 2 May 2021 17:43:05 +0000 (17:43 +0000)]
[libcxx][nfc] removes duplicate test file

`test/std/ranges/range.access/range.access.cbegin/incomplete.compile.verify.cpp`
was accidentally copied (and apparently the author either forgot to
delete it or forgot to commit the deletion).

TEST=`ninja cxx && ninja check-cxx` locally

3 years ago[SCEV] Add test for non-unit stride with multiple exits (NFC)
Nikita Popov [Sun, 2 May 2021 16:12:59 +0000 (18:12 +0200)]
[SCEV] Add test for non-unit stride with multiple exits (NFC)

We currently can't determine any exit counts here, because there
is no "controlling exit".

3 years ago[MLIR] Canonicalization of Integer Cast Operations
William S. Moses [Sun, 2 May 2021 04:39:45 +0000 (00:39 -0400)]
[MLIR] Canonicalization of Integer Cast Operations

1) Canonicalize IndexCast(SExt(x)) => IndexCast(x)
2) Provide constant folds of sign_extend and truncate

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

3 years ago[libc++][doc] Update the Format library status.
Mark de Wever [Sun, 2 May 2021 11:13:07 +0000 (13:13 +0200)]
[libc++][doc] Update the Format library status.

- Use the proper review for 'Fix integral conformance'.
- Mark 'Fix integral conformance' as completed.
- Move some tasks to in progress.

3 years ago[InstCombine] Add a few more patterns for folding select of select
Juneyoung Lee [Tue, 27 Apr 2021 16:13:07 +0000 (01:13 +0900)]
[InstCombine] Add a few more patterns for folding select of select

This is a patch that folds select of select to salvage some optimizations after select -> and/or folding is disabled.

```
select (select a, true, b), c, false -> select a, c, false
select c, (select a, true, b), false -> select c, a, false
  if c implies that b is false (isImpliedCondition).
```
https://alive2.llvm.org/ce/z/ANatjt, https://alive2.llvm.org/ce/z/rv8zTB

```
sel (sel c, a, false), true, (sel !c, b, false) -> sel c, a, b
sel (sel !c, a, false), true, (sel c, b, false) -> sel c, b, a
```
https://alive2.llvm.org/ce/z/U2kp-t, https://alive2.llvm.org/ce/z/bc88EE

See D101191

Reviewed By: nikic

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

3 years ago[InstCombine] Precommit tests for D101375 (NFC)
Juneyoung Lee [Tue, 27 Apr 2021 16:10:12 +0000 (01:10 +0900)]
[InstCombine] Precommit tests for D101375 (NFC)

3 years ago[MLIR] Handle llvm.icmp of pointers
William S. Moses [Sun, 2 May 2021 04:58:06 +0000 (00:58 -0400)]
[MLIR] Handle llvm.icmp of pointers

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

3 years ago[libcxx][nfc] prefixes test type `input_iterator` with `cpp17_`
Christopher Di Bella [Sat, 24 Apr 2021 21:31:23 +0000 (21:31 +0000)]
[libcxx][nfc] prefixes test type `input_iterator` with `cpp17_`

C++20 revised the definition of what it means to be an iterator. While
all _Cpp17InputIterators_ satisfy `std::input_iterator`, the reverse
isn't true. D100271 introduces a new test adaptor to accommodate this
new definition (`cpp20_input_iterator`).

In order to help readers immediately distinguish which input iterator
adaptor is _Cpp17InputIterator_, the current `input_iterator` adaptor
has been prefixed with `cpp17_`.

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

3 years agoFix MSan crash after 1977c53b
Juneyoung Lee [Sun, 2 May 2021 04:44:43 +0000 (13:44 +0900)]
Fix MSan crash after 1977c53b

3 years ago[NFC] Use getParamByValType instead of pointee type
Arthur Eubanks [Sun, 2 May 2021 04:01:06 +0000 (21:01 -0700)]
[NFC] Use getParamByValType instead of pointee type

To reduce dependence on pointee types for opaque pointers.

Reviewed By: dblaikie

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

3 years agorun update_test_checks.py for the tests in D101191 (NFC)
Juneyoung Lee [Sun, 2 May 2021 04:10:20 +0000 (13:10 +0900)]
run update_test_checks.py for the tests in D101191 (NFC)

This is an NFC that reruns update_test_checks.py on the tests that are
going to be updated in D101191.

3 years ago[ValueTracking] ctpop propagates poison
Juneyoung Lee [Sun, 2 May 2021 04:00:33 +0000 (13:00 +0900)]
[ValueTracking] ctpop propagates poison

This is a patch that adds ctpop intrinsics to propagatesPoison.

Splitted from D101191

3 years ago[mlir] [affine] add canonicalization for affine.vector_load, vector_store
eopXD [Sun, 2 May 2021 02:59:12 +0000 (08:29 +0530)]
[mlir] [affine] add canonicalization for affine.vector_load, vector_store

Added canonicalization for vector_load and vector_store. An existing
pattern SimplifyAffineOp can be reused to compose maps that supplies
result into them. Added AffineVectorStoreOp and AffineVectorLoadOp
into static_assert of SimplifyAffineOp to allow operation to use it.

This fixes the bug filed: https://bugs.llvm.org/show_bug.cgi?id=50058

Reviewed By: bondhugula

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

3 years ago[ValueTracking] Improve impliesPoison to look into overflow intrinsics
Juneyoung Lee [Sun, 2 May 2021 03:02:02 +0000 (12:02 +0900)]
[ValueTracking] Improve impliesPoison to look into overflow intrinsics

This update supports the following transformation:

```
select(extract(mul_with_overflow(a, _), _), (a == 0), false)
=>
and(extract(mul_with_overflow(a, _), _), (a == 0))
```

which is correct because if `a` was poison the select's condition was
also poison.

This update is splitted from D101423.

3 years ago[gn build] Port 1977c53b2ae4
LLVM GN Syncbot [Sun, 2 May 2021 02:55:47 +0000 (02:55 +0000)]
[gn build] Port 1977c53b2ae4

3 years ago[InstCombine] Fold overflow bit of [u|s]mul.with.overflow in a poison-safe way
Juneyoung Lee [Wed, 28 Apr 2021 02:34:45 +0000 (11:34 +0900)]
[InstCombine] Fold overflow bit of [u|s]mul.with.overflow in a poison-safe way

As discussed in D101191, this patch adds a poison-safe folding of overflow bit check:
```
  %Op0 = icmp ne i4 %X, 0
  %Agg = call { i4, i1 } @llvm.[us]mul.with.overflow.i4(i4 %X, i4 %Y)
  %Op1 = extractvalue { i4, i1 } %Agg, 1
  %ret = select i1 %Op0, i1 %Op1, i1 false
=>
  %Y.fr = freeze %Y
  %Agg = call { i4, i1 } @llvm.[us]mul.with.overflow.i4(i4 %X, i4 %Y.fr)
  %Op1 = extractvalue { i4, i1 } %Agg, 1
  %ret = %Op1
```

https://alive2.llvm.org/ce/z/zgPUGT
https://alive2.llvm.org/ce/z/h2gZ_6

Note that there are cases where inserting freeze is not necessary: e.g. %Y is `noundef`.
In this case, LLVM is already good because `%ret` is already successfully folded into `and`,
triggering the pre-existing optimization in InstSimplify: https://godbolt.org/z/v6qena15K

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

3 years ago[InstCombine] Precommit tests for D101423 (NFC)
Juneyoung Lee [Wed, 28 Apr 2021 02:25:30 +0000 (11:25 +0900)]
[InstCombine] Precommit tests for D101423 (NFC)

3 years ago[HIP] Fix device lib selection
Yaxun (Sam) Liu [Fri, 30 Apr 2021 18:54:03 +0000 (14:54 -0400)]
[HIP] Fix device lib selection

Choose optimized device lib bitcode by fp options
for performance.

Reviewed by: Artem Belevich, Fangrui Song

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

3 years ago[Cuda] Internalize a struct and a global variable
Fangrui Song [Sat, 1 May 2021 23:24:39 +0000 (16:24 -0700)]
[Cuda] Internalize a struct and a global variable

3 years ago[X32][CET] Fix size and alignment of .note.gnu.property section
Harald van Dijk [Sat, 1 May 2021 21:17:04 +0000 (22:17 +0100)]
[X32][CET] Fix size and alignment of .note.gnu.property section

X32 uses 32-bit ELF object files with 32-bit alignment, so the
.note.gnu.property section needs to be emitted as it is for X86.

Reviewed By: MaskRay

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

3 years ago[LVI] Handle mask not equal zero conditions
Nikita Popov [Sat, 1 May 2021 20:54:51 +0000 (22:54 +0200)]
[LVI] Handle mask not equal zero conditions

If V & Mask != 0, we know that at least one of the bits in Mask
must be set, so the value must be >= the lowest bit in Mask.

3 years ago[CVP] Add tests for mask not equal zero guard (NFC)
Nikita Popov [Sat, 1 May 2021 21:01:34 +0000 (23:01 +0200)]
[CVP] Add tests for mask not equal zero guard (NFC)

3 years ago[lldb] [Process/FreeBSD] Fix arm64 build after RegisterInfoPOSIX_arm64 changes
Michał Górny [Thu, 29 Apr 2021 11:55:21 +0000 (13:55 +0200)]
[lldb] [Process/FreeBSD] Fix arm64 build after RegisterInfoPOSIX_arm64 changes

Commit 88a5b35d63f927db69ec953ff487a7ba2504a610 changed the API
of RegisterInfoPOSIX_arm64 and effectively broke the FreeBSD plugin.
Update it to work with the new API.

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

3 years ago[RISCV] Add missing frontend tests for vcompress intrinsics.
Craig Topper [Sat, 1 May 2021 20:07:28 +0000 (13:07 -0700)]
[RISCV] Add missing frontend tests for vcompress intrinsics.

3 years agoMicrooptimize dominance a bit - NFC.
Chris Lattner [Sat, 1 May 2021 19:39:01 +0000 (12:39 -0700)]
Microoptimize dominance a bit - NFC.

Don't get RegionKindInterface if we won't use it. Noticed by inspection.

3 years ago[X86] AMD Zen 3 Scheduler Model
Roman Lebedev [Sat, 1 May 2021 19:04:48 +0000 (22:04 +0300)]
[X86] AMD Zen 3 Scheduler Model

Introduce basic schedule model for AMD Zen 3 CPU's, a.k.a `znver3`.

This is fully built from scratch, from llvm-mca measurements
and documented reference materials.
Nothing was copied from `znver2`/`znver1`.

I believe this is in a reasonable state of completion for inclusion,
probably better than D52779 `bdver2` was :)

Namely:
* uops are pretty spot-on (at least what llvm-mca can measure)
  {F16422596}
* latency is also pretty spot-on (at least what llvm-mca can measure)
  {F16422601}
* throughput is within reason
  {F16422607}

I haven't run much benchmarks with this,
however RawSpeed benchmarks says this is beneficial:
{F16603978}
{F16604029}

I'll call out the obvious problems there:
* i didn't really bother with X87 instructions
* i didn't really bother with obviously-microcoded/system instructions
* There are large discrepancy in throughput for `mr` and `rm` instructions.
  I'm not really sure if it's a modelling defect that needs to be fixed,
  or it's a defect of measurments.
* Pipe distributions are probably bad :)
  I can't do much here until AMD allows that to be fixed
  by documenting the appropriate counters and updating libpfm

That being said, as @RKSimon notes:
>>! In D94395#2647381, @RKSimon wrote:
> I'll mention again that all the znver* models appear to be very inaccurate wrt SIMD/FPU instructions <...>
so how much worse this could possibly be?!

Things that aren't there:
* Various tunings: zero idioms, etc. That is follow-ups.

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

3 years agoFix type printing of array template args
Pratyush Das [Sat, 1 May 2021 18:47:27 +0000 (18:47 +0000)]
Fix type printing of array template args

The code example:
```
constexpr const char kEta[] = "Eta";
template <const char*, typename T> class Column {};
using quick = Column<kEta,double>;

void lookup() {
  quick c1;
  c1.ls();
}
```

emits error: no member named 'ls' in 'Column<&kEta, double>'. The patch fixes
the printed type name by not printing the ampersand for array types.

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

3 years ago[Verifier] Slightly refactor code to reduce duplication, NFC.
Chris Lattner [Sat, 1 May 2021 18:42:28 +0000 (11:42 -0700)]
[Verifier] Slightly refactor code to reduce duplication, NFC.

3 years ago[SCEV] Simplify backedge count clearing (NFC)
Nikita Popov [Sat, 1 May 2021 15:40:26 +0000 (17:40 +0200)]
[SCEV] Simplify backedge count clearing (NFC)

This seems to be a leftover from when the BackedgeTakenInfo
stored multiple exit counts with manual memory management. At
some point this was switchted to a simple vector, and there should
be no need to micro-manage the clearing anymore. We can simply
drop the loop from the map and the the destructor do its job.

3 years ago[IndVars] Remove redundant loop invariance check (NFC)
Nikita Popov [Sat, 1 May 2021 15:21:20 +0000 (17:21 +0200)]
[IndVars] Remove redundant loop invariance check (NFC)

This is checked again directly below this condition.

3 years ago[AArch64] Prevent spilling between ldxr/stxr pairs
LemonBoy [Sat, 1 May 2021 15:13:50 +0000 (17:13 +0200)]
[AArch64] Prevent spilling between ldxr/stxr pairs

Apply the same logic used to check if CMPXCHG nodes should be expanded
at -O0: the register allocator may end up spilling some register in
between the atomic load/store pairs, breaking the atomicity and possibly
stalling the execution.

Fixes PR48017

Reviewed By: efriedman

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

3 years ago[SCEV] Add tests for and/or loop guards (NFC)
Nikita Popov [Sat, 1 May 2021 14:45:28 +0000 (16:45 +0200)]
[SCEV] Add tests for and/or loop guards (NFC)

3 years ago[NFC][ARM] Regenerate arm64-atomic.ll test
LemonBoy [Sat, 1 May 2021 14:29:03 +0000 (16:29 +0200)]
[NFC][ARM] Regenerate arm64-atomic.ll test

Pre-requisite for D101163, the `NOLSE-0O` case shows registers being
spilled inside the rmw loop.

Use two separate prefixes for the `LSE-O0` case as some outputs differ
only by a comment that update_llc_test_checks.py ignores but lit does
not, causing the test to fail unexpectedly when run.

3 years ago[libc++] [test] Don't nasty-macro `__opt` yet; we actually use that one.
Arthur O'Dwyer [Sat, 1 May 2021 14:11:46 +0000 (10:11 -0400)]
[libc++] [test] Don't nasty-macro `__opt` yet; we actually use that one.

This reverts another of the macros just added in D101613, because it turns out
that the <optional> and <filesystem> headers use the identifier __opt.

3 years ago[libc++] [test] Don't nasty-macro `__z` yet; we actually use that one.
Arthur O'Dwyer [Sat, 1 May 2021 13:09:06 +0000 (09:09 -0400)]
[libc++] [test] Don't nasty-macro `__z` yet; we actually use that one.

This reverts one of the macros just added in D101613, because it turns out
that the <utility> header actually uses the identifiers __x, __y, __z.
We probably *shouldn't* use __z if it's reserved on Windows; but since
it's not causing us any active problem even on Windows, I think this is
the safest way to unbreak the test.

3 years ago[AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee
Yaxun (Sam) Liu [Sun, 29 Mar 2020 14:32:03 +0000 (10:32 -0400)]
[AMDGPU] Add options -mamdgpu-ieee -mno-amdgpu-ieee

AMDGPU backend need to know whether floating point opcodes that support exception
flag gathering quiet and propagate signaling NaN inputs per IEEE754-2008, which is
conveyed by a function attribute "amdgpu-ieee". "amdgpu-ieee"="false" turns this off.
Without this function attribute backend assumes it is on for compute functions.

-mamdgpu-ieee and -mno-amdgpu-ieee are added to Clang to control this function attribute.
By default it is on. -mno-amdgpu-ieee requires -fno-honor-nans or equivalent.

Reviewed by: Matt Arsenault

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

3 years agoRevert "[NFC][ARM] Regenerate arm64-atomic.ll test"
LemonBoy [Sat, 1 May 2021 11:00:45 +0000 (13:00 +0200)]
Revert "[NFC][ARM] Regenerate arm64-atomic.ll test"

This reverts commit d9856b12f2be257f1b7aaccde71eb0421a1aaaf3.

3 years ago[NFC][ARM] Regenerate arm64-atomic.ll test
LemonBoy [Sat, 1 May 2021 10:09:14 +0000 (12:09 +0200)]
[NFC][ARM] Regenerate arm64-atomic.ll test

Pre-requisite for D101163, the NOLSE-0O case shows registers being
spilled inside the rmw loop.

3 years ago[InstCombine] Add eq-of-parts tests using or (NFC)
Nikita Popov [Sat, 1 May 2021 09:47:07 +0000 (11:47 +0200)]
[InstCombine] Add eq-of-parts tests using or (NFC)

or-ne is the conjugated pattern for and-eq.

3 years ago[scudo][NFC] Fix clang-tidy warnings
Vitaly Buka [Sat, 1 May 2021 08:55:21 +0000 (01:55 -0700)]
[scudo][NFC] Fix clang-tidy warnings

3 years ago[scudo] Use require_constant_initialization
Vitaly Buka [Thu, 29 Apr 2021 08:19:51 +0000 (01:19 -0700)]
[scudo] Use require_constant_initialization

Attribute guaranties safe static initialization of globals.

Reviewed By: hctim

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

3 years ago[libcxx] Reenable ranges for clang-cl
Martin Storsjö [Fri, 30 Apr 2021 10:57:37 +0000 (13:57 +0300)]
[libcxx] Reenable ranges for clang-cl

This reverts a224bf8ec423b42eea251407e7a6cc8398a5edf4 and fixes the
underlying issue.

The underlying issue is simply that MSVC headers contains a define
like "#define __in", where __in is one macro in the MSVC Source
Code Annotation Language, defined in sal.h

Just use a different variable name than "__in"
__indirectly_readable_impl, and add "__in" to nasty_macros.h just
like the existing __out. (Also adding a couple more potentially
conflicting ones.)

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

3 years ago[clang-tidy][NFC] Remove redudnant expr and qualType matchers from bugprone-sizeof...
Nathan James [Sat, 1 May 2021 07:53:29 +0000 (08:53 +0100)]
[clang-tidy][NFC] Remove redudnant expr and qualType matchers from bugprone-sizeof-expression.

3 years ago[libcxx] [test] Skip alloc counter checks for operations within the libc++ DLL
Martin Storsjö [Fri, 26 Feb 2021 14:34:29 +0000 (16:34 +0200)]
[libcxx] [test] Skip alloc counter checks for operations within the libc++ DLL

If libc++ is built as a DLL, calls to operator new within the DLL aren't
overridden if a user provides their own operator in calling code.
Therefore, the alloc counter doesn't pick up on allocations done within
std::string, so skip that check if running on windows. (Technically,
we could keep the checks if running on windows when not built as a DLL,
but trying to keep the conditionals simple.)

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

3 years agoRevert "Re-reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP...
Nathan Chancellor [Sat, 1 May 2021 03:23:21 +0000 (20:23 -0700)]
Revert "Re-reapply "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands""

This reverts commit 791930d74087b8ae8901172861a0fd21a211e436, as per
https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy.

I observed breakage with the Linux kernel, as reported at
https://reviews.llvm.org/D91722#2724321

Fixes exist at
https://reviews.llvm.org/D101523
https://reviews.llvm.org/D101540

but they have not landed so to unbreak the tree for the weekend, revert
this commit.

Commit b11e4c990771 ("Revert "[DebugInfo] Drop DBG_VALUE_LISTs with an
excessive number of debug operands"") only reverted one follow-up fix,
not the original patch that broke the kernel.

e

3 years ago[libc++] [LIBCXX-DEBUG-FIXME] <span>, like <string_view>, has no use for debug iterators.
Arthur O'Dwyer [Wed, 21 Apr 2021 02:08:00 +0000 (22:08 -0400)]
[libc++] [LIBCXX-DEBUG-FIXME] <span>, like <string_view>, has no use for debug iterators.

A span has no idea what container (if any) "owns" its iterators, nor
under what circumstances they might become invalidated.

However, continue to use `__wrap_iter<T*>` instead of raw `T*` outside
of debug mode, because we've been shipping `std::span` since Clang 7
and ldionne doesn't want to break ABI. (Namely, the mangling of functions
taking `span::iterator` as a parameter.) Permit using raw `T*` there,
but only under an ABI macro: `_LIBCPP_ABI_SPAN_POINTER_ITERATORS`.

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

3 years ago[mlir][sparse] sparse tensor type encoding migration (new home, new builders)
Aart Bik [Sat, 1 May 2021 01:07:28 +0000 (18:07 -0700)]
[mlir][sparse] sparse tensor type encoding migration (new home, new builders)

(1) migrates the encoding from TensorDialect into the new SparseTensorDialect
(2) replaces dictionary-based storage and builders with struct-like data

Reviewed By: mehdi_amini

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

3 years ago[clang][driver][darwin] use the deployment target version as the SDK version
Alex Lorenz [Sat, 1 May 2021 01:50:07 +0000 (18:50 -0700)]
[clang][driver][darwin] use the deployment target version as the SDK version
when passing -platform_version to the linker

The use of a valid SDK version is preferred over an empty SDK version
(0.0.0) as the system's runtime might expect the linked binary to contain
a valid SDK version in order for the binary to work correctly

rdar://66795188

3 years ago[PowerPC] Add floating point overloads for vec_sldw
Nemanja Ivanovic [Sat, 1 May 2021 01:29:03 +0000 (20:29 -0500)]
[PowerPC] Add floating point overloads for vec_sldw

These are added for compatibility with XLC.

3 years ago[PowerPC] Add missing requirement to test case
Nemanja Ivanovic [Sat, 1 May 2021 00:34:56 +0000 (19:34 -0500)]
[PowerPC] Add missing requirement to test case

Commit 70c433a184a54819835e54c62c3e6891e7069861 added this
test case that has -stop-before that mentions a pass that is
only added for non-release builds. Add the requirement for asserts.

3 years agoCorrect tiny misspelling (readlef -> readelf).
Kevin Athey [Thu, 29 Apr 2021 16:58:19 +0000 (09:58 -0700)]
Correct tiny misspelling (readlef -> readelf).
Getting my feet wet here as a new committer.

Correct misspelling in check-depends.pl.

Reviewed By: vitalybuka

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

3 years ago[ELF] Simplify the condition adding .got header
Fangrui Song [Sat, 1 May 2021 00:19:45 +0000 (17:19 -0700)]
[ELF] Simplify the condition adding .got header

Adopt my suggestion in https://reviews.llvm.org/D91426#2653926 ,
generalizing the ppc64 specific code.

GNU ld and glibc ld.so has a contract about the first few entries of .got .
There are somewhat complex conditions when the header is needed. This patch
switches to a simpler approach: add a header unconditionally if
_GLOBAL_OFFSET_TABLE_ is used or the number of entries is more than just the
header.

3 years ago[PowerPC] Provide fastmath sqrt and div functions in altivec.h
Nemanja Ivanovic [Fri, 30 Apr 2021 23:54:44 +0000 (18:54 -0500)]
[PowerPC] Provide fastmath sqrt and div functions in altivec.h

This adds the long overdue implementations of these functions
that have been part of the ABI document and are now part of
the "Power Vector Intrinsic Programming Reference" (PVIPR).

The approach is to add new builtins and to emit code with
the fast flag regardless of whether fastmath was specified
on the command line.

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

3 years ago[gn build] Port 02c5ba867987
LLVM GN Syncbot [Sat, 1 May 2021 00:09:37 +0000 (00:09 +0000)]
[gn build] Port 02c5ba867987

3 years ago[libc++] s/begin.h/access.h/ in comments. NFCI.
Arthur O'Dwyer [Sat, 1 May 2021 00:07:00 +0000 (20:07 -0400)]
[libc++] s/begin.h/access.h/ in comments. NFCI.