platform/upstream/llvm.git
4 years agoCleanup CodeGen/CallingConvLower.cpp
Fangrui Song [Mon, 5 Oct 2020 21:47:46 +0000 (14:47 -0700)]
Cleanup CodeGen/CallingConvLower.cpp

Patch by pi1024e (email unavailable)

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

4 years agoRevert "Outline non returning functions unless a longjmp"
Vedant Kumar [Mon, 5 Oct 2020 20:41:12 +0000 (13:41 -0700)]
Revert "Outline non returning functions unless a longjmp"

This reverts commit 20797989ea190f2ef22d13c5a7a0535fe9afa58b.

This patch (https://reviews.llvm.org/D69257) cannot complete a stage2
build due to the change:

```
CI->getCalledFunction()->getName().contains("longjmp")
```

There are several concrete issues here:

  - The callee may not be a function, so `getCalledFunction` can assert.
  - The called value may not have a name, so `getName` can assert.
  - There's no distinction made between "my_longjmp_test_helper" and the
    actual longjmp libcall.

At a higher level, there's a serious layering problem here. The
splitting pass makes policy decisions in a general way (e.g. based on
attributes or profile data). Special-casing certain names breaks the
layering. It subverts the work of library maintainers (who may now need
to opt-out of unexpected optimization behavior for any affected
functions) and can lead to inconsistent optimization behavior (as not
all llvm passes special-case ".*longjmp.*" in the same way).

The patch may need significant revision to address these issues.

But the immediate issue is that this crashes while compiling llvm's unit
tests in a stage2 build (due to the `getName` problem).

4 years ago[SVE] Add legalisation tests to sve-fixed-length-int-reduce.ll
Cameron McInally [Mon, 5 Oct 2020 21:05:14 +0000 (16:05 -0500)]
[SVE] Add legalisation tests to sve-fixed-length-int-reduce.ll

4 years ago[MLIR][SPIRV] Extend _reference_of to support SpecConstantCompositeOp.
ergawy [Mon, 5 Oct 2020 20:39:39 +0000 (16:39 -0400)]
[MLIR][SPIRV] Extend _reference_of to support SpecConstantCompositeOp.

Adds support for SPIR-V composite speciailization constants to spv._reference_of.

Reviewed By: antiagainst

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

4 years ago[InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are...
Roman Lebedev [Mon, 5 Oct 2020 19:35:59 +0000 (22:35 +0300)]
[InstCombine] Revert rL226781 "Teach InstCombine to canonicalize loads which are only ever stored to always use a legal integer type if one is available." (PR47592)

(it was introduced in https://lists.llvm.org/pipermail/llvm-dev/2015-January/080956.html)

This canonicalization seems dubious.

Most importantly, while it does not create `inttoptr` casts by itself,
it may cause them to appear later, see e.g. D88788.

I think it's pretty obvious that it is an undesirable outcome,
by now we've established that seemingly no-op `inttoptr`/`ptrtoint` casts
are not no-op, and are no longer eager to look past them.
Which e.g. means that given
```
%a = load i32
%b = inttoptr %a
%c = inttoptr %a
```
we likely won't be able to tell that `%b` and `%c` is the same thing.

As we can see in D88789 / D88788 / D88806 / D75505,
we can't really teach SCEV about this (not without the https://bugs.llvm.org/show_bug.cgi?id=47592 at least)
And we can't recover the situation post-inlining in instcombine.

So it really does look like this fold is actively breaking
otherwise-good IR, in a way that is not recoverable.
And that means, this fold isn't helpful in exposing the passes
that are otherwise unaware of these patterns it produces.

Thusly, i propose to simply not perform such a canonicalization.
The original motivational RFC does not state what larger problem
that canonicalization was trying to solve, so i'm not sure
how this plays out in the larger picture.

On vanilla llvm test-suite + RawSpeed, this results in
increase of asm instructions and final object size by ~+0.05%
decreases final count of bitcasts by -4.79% (-28990),
ptrtoint casts by -15.41% (-3423),
and of inttoptr casts by -25.59% (-6919, *sic*).
Overall, there's -0.04% less IR blocks, -0.39% instructions.

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

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

4 years ago[flang] Correct kP scaling on F output
peter klausler [Wed, 30 Sep 2020 20:04:44 +0000 (13:04 -0700)]
[flang] Correct kP scaling on F output

The sign of the scaling factor was misinterpreted for output
as meaning what it does for input.  To be correct, they
should cancel each other out.

print '(1P,F4.3)', 1. ! printed 0.1 but should print 10.0

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

4 years ago[RISCV] Add SiFive cores to the CPU option
Evandro Menezes [Fri, 2 Oct 2020 21:44:32 +0000 (16:44 -0500)]
[RISCV] Add SiFive cores to the CPU option

Add the SiFive cores E76 and U74 using the SiFive 7 series microarchitecture.

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

4 years ago[RISCV] Use the extensions in the canonical order (NFC)
Evandro Menezes [Fri, 2 Oct 2020 21:26:49 +0000 (16:26 -0500)]
[RISCV] Use the extensions in the canonical order (NFC)

Fix a mistake in the ordering.

4 years ago[libc++] Use __has_include instead of complex logic in thread.cpp
Louis Dionne [Mon, 5 Oct 2020 20:39:33 +0000 (16:39 -0400)]
[libc++] Use __has_include instead of complex logic in thread.cpp

We might end up including more headers than strictly necessary this way,
but it's much simpler and it makes it easier to port thread.cpp to systems
not handled by the existing conditionals.

4 years ago[libc++] NFC: Rename variant helpers to avoid name clashes
Louis Dionne [Mon, 5 Oct 2020 20:30:23 +0000 (16:30 -0400)]
[libc++] NFC: Rename variant helpers to avoid name clashes

Some system headers define __constructor and __destructor macros (for
Clang attributes constructor and destructor). While this is badly
behaved, it is easy for libc++ to work around this issue.

4 years ago[libc++] NFC: Remove unused <iostream> include in atomic.cpp
Louis Dionne [Mon, 5 Oct 2020 20:24:41 +0000 (16:24 -0400)]
[libc++] NFC: Remove unused <iostream> include in atomic.cpp

4 years agoRevert "[SLC] Optimize mempcpy_chk to mempcpy"
Dávid Bolvanský [Mon, 5 Oct 2020 20:27:14 +0000 (22:27 +0200)]
Revert "[SLC] Optimize mempcpy_chk to mempcpy"

This reverts commit 3f1fd59de3002e3d5a4eca98cd49c45755ab0110.

4 years ago[SLC] Optimize mempcpy_chk to mempcpy
Dávid Bolvanský [Mon, 5 Oct 2020 20:16:59 +0000 (22:16 +0200)]
[SLC] Optimize mempcpy_chk to mempcpy

As reported in PR46735:

void* f(void *d, const void *s, size_t l)
{
    return __builtin___mempcpy_chk(d, s, l, __builtin_object_size(d, 0));
}

This can be optimized to `return mempcpy(d, s, l);`.

Reviewed By: efriedma

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

4 years ago[libc++] Fix several debug mode tests
Louis Dionne [Fri, 2 Oct 2020 19:50:55 +0000 (15:50 -0400)]
[libc++] Fix several debug mode tests

These tests were only being run when _LIBCPP_DEBUG was defined, which
isn't the case by default when we run the test suite. In other words,
all these debug mode tests were never being run. This commit makes sure
they are run, and in some cases, extracts them into a file under test/libcxx
to separate them from the Standard tests.

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

4 years ago[flang] Make binary->decimal conversion buffer sizes accurate
peter klausler [Thu, 1 Oct 2020 18:19:38 +0000 (11:19 -0700)]
[flang] Make binary->decimal conversion buffer sizes accurate

The binary values that produce the most significant decimal
digits in an exact conversion are those with the least normal
biased exponent (1) and all fractional bits set, not the
least-valued subnormals.  So the binary->decimal conversion
buffer sizes were a little short, and could cause a overrun crash.

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

4 years ago[LLD] [MinGW] Support setting the subsystem version via the subsystem argument
Martin Storsjö [Sun, 4 Oct 2020 14:59:33 +0000 (17:59 +0300)]
[LLD] [MinGW] Support setting the subsystem version via the subsystem argument

If a version is specified both with --{major,minor}-subsystem-version and
with --subsystem <name>:<version>, the one specified last (that actually
sets a version) takes precedance in GNU ld; thus doing the same here.

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

4 years ago[LLD] [MinGW] Simplify handling of os/subsystem version
Martin Storsjö [Sun, 4 Oct 2020 08:52:36 +0000 (11:52 +0300)]
[LLD] [MinGW] Simplify handling of os/subsystem version

As they can be set independently after D88802, we can get rid of a bit
of extra code - simplifying the logic here before adding more
complication to it later.

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

4 years ago[LLD] [COFF] Add a private option for setting the os version separately from subsyste...
Martin Storsjö [Sat, 3 Oct 2020 22:29:45 +0000 (01:29 +0300)]
[LLD] [COFF] Add a private option for setting the os version separately from subsystem version

The MinGW driver has separate options for OS and subsystem version.
Having this available in lld-link allows the MinGW driver to both match
GNU ld better and simplifies the code for merging two (potentially
mismatching) arguments into one.

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

4 years ago[LLD] [COFF] Fix parsing version numbers with leading zeros
Martin Storsjö [Sat, 3 Oct 2020 22:19:41 +0000 (01:19 +0300)]
[LLD] [COFF] Fix parsing version numbers with leading zeros

Parse the components as decimal, instead of decuding the base from
the string. This avoids ambiguity if the second number contains leading
zeros, which previously were parsed as indicating an octal number.

MS link.exe doesn't support hexadecimal numbers in the version numbers,
neither in /version nor in /subsystem.

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

4 years ago[CUDA] Don't call __cudaRegisterVariable on C++17 inline variables
Fangrui Song [Sat, 3 Oct 2020 21:50:20 +0000 (14:50 -0700)]
[CUDA] Don't call __cudaRegisterVariable on C++17 inline variables

D17779: host-side shadow variables of external declarations of device-side
global variables have internal linkage and are referenced by
`__cuda_register_globals`.

nvcc from CUDA 11 does not allow `__device__ inline` or `__device__ constexpr`
(C++17 inline variables) but clang has incorrectly supported them for a while:

```
error: A __device__ variable cannot be marked constexpr
error: An inline __device__/__constant__/__managed__ variable must have internal linkage when the program is compiled in whole program mode (-rdc=false)
```

If such a variable (which has a comdat group) is discarded (a copy from another
translation unit is prevailing and selected), accessing the variable from
outside the section group (`__cuda_register_globals`) is a violation of the ELF
specification and will be rejected by linkers:

> A symbol table entry with STB_LOCAL binding that is defined relative to one of a group's sections, and that is contained in a symbol table section that is not part of the group, must be discarded if the group members are discarded. References to this symbol table entry from outside the group are not allowed.

As a workaround, don't register such inline variables for now.
(If we register the variables in all TUs, we will keep multiple instances of the shadow and break the C++ semantics for inline variables).
We should reject such variables in Sema but our internal users need some time to migrate.

Reviewed By: tra

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

4 years ago[NFC][GCOV] Fix build: there's `llvm::stable_partition()` wrapper
Roman Lebedev [Mon, 5 Oct 2020 19:52:32 +0000 (22:52 +0300)]
[NFC][GCOV] Fix build: there's `llvm::stable_partition()` wrapper

4 years ago[CodeGen][MachineSched] Fixup function name typo. NFC
Jon Roelofs [Mon, 5 Oct 2020 19:43:50 +0000 (12:43 -0700)]
[CodeGen][MachineSched] Fixup function name typo. NFC

4 years ago[lldb/test] Catch invalid calls to expect()
Dave Lee [Sun, 4 Oct 2020 05:51:43 +0000 (22:51 -0700)]
[lldb/test] Catch invalid calls to expect()

Add preconditions to `TestBase.expect()` that catch semantically invalid calls
that happen to succeed anyway. This also fixes the broken callsites caught by
these checks.

This prevents the following incorrect calls:

1. `self.expect("lldb command", "some substr")`
2. `self.expect("lldb command", "assert message", "some substr")`

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

4 years ago[gcov] Fix non-determinism (DenseMap iteration order) of checksum computation
Fangrui Song [Mon, 5 Oct 2020 19:39:19 +0000 (12:39 -0700)]
[gcov] Fix non-determinism (DenseMap iteration order) of checksum computation

... by using MapVector. The issue was caused by 63182c2ac0b643a60d397274e8a31166fc7243fa.

Also use stable_partition instead of partition to get stable results
across different STL implementations.

4 years ago[InstCombine] Handle GEP inbounds in select op replacement (PR47730)
Nikita Popov [Mon, 5 Oct 2020 19:13:02 +0000 (21:13 +0200)]
[InstCombine] Handle GEP inbounds in select op replacement (PR47730)

When retrying the "simplify with operand replaced" select
optimization without poison flags, also handle inbounds on GEPs.

Of course, this particular example would also be safe to transform
while keeping inbounds, but the underlying machinery does not
know this (yet).

4 years ago[InstCombine] Add test for PR47730
Nikita Popov [Mon, 5 Oct 2020 19:09:53 +0000 (21:09 +0200)]
[InstCombine] Add test for PR47730

4 years ago[clangd] Describe non-handling of most IWYU pragmas. NFC
Sam McCall [Mon, 5 Oct 2020 11:17:52 +0000 (13:17 +0200)]
[clangd] Describe non-handling of most IWYU pragmas. NFC

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

4 years ago[NFC][regalloc] Model weight normalization as a virtual
Mircea Trofin [Thu, 1 Oct 2020 23:53:23 +0000 (16:53 -0700)]
[NFC][regalloc] Model weight normalization as a virtual

Continuing from D88499, we can now model the normalization function as a
virtual member of VirtRegAuxInfo. Note that the default
(normalizeSpillWeight) is also used stand-alone in RAGreedy.

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

4 years agodocs: add documentation describing API Notes
Saleem Abdulrasool [Thu, 24 Sep 2020 21:18:24 +0000 (21:18 +0000)]
docs: add documentation describing API Notes

API Notes are a feature which allows annotation of headers by an
auxiliary file that contains metadata for declarations pertaining to the
associated module.  This enables adding attributes to declarations
without requiring modification of the headers, enabling finer grained
control for library headers for consumers without having to modify
external headers.

Differential Revision: https://reviews.llvm.org/D88446
Reviewed By: Richard Smith, Marcel Hlopko

4 years ago[SVE][CodeGen] Fix TypeSize/ElementCount related warnings in sve-split-store.ll
David Sherwood [Wed, 26 Aug 2020 09:51:56 +0000 (10:51 +0100)]
[SVE][CodeGen] Fix TypeSize/ElementCount related warnings in sve-split-store.ll

I have fixed up a number of warnings resulting from TypeSize -> uint64_t
casts and calling getVectorNumElements() on scalable vector types. I
think most of the changes are fairly trivial except for those in
DAGTypeLegalizer::SplitVecRes_MSTORE I've tried to ensure we create
the MachineMemoryOperands in a sensible way for scalable vectors.

I have added a CHECK line to the following test:

 CodeGen/AArch64/sve-split-store.ll

that ensures no new warnings are added.

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

4 years ago[llvm-objcopy][MachO] Add missing std::move.
Alexander Shaposhnikov [Mon, 5 Oct 2020 18:02:13 +0000 (11:02 -0700)]
[llvm-objcopy][MachO] Add missing std::move.

This change fixes the build issue introduced by 32c8435ef7
(detected by the buildbot fuchsia-x86_64-linux).

Test plan: make check-all

4 years ago[GlobalISel] Fix CSEMIRBuilder silently allowing use-before-def.
Amara Emerson [Tue, 29 Sep 2020 19:22:30 +0000 (12:22 -0700)]
[GlobalISel] Fix CSEMIRBuilder silently allowing use-before-def.

If a CSEMIRBuilder query hits the instruction at the current insert point,
move insert point ahead one so that subsequent uses of the builder don't end up with
uses before defs.

This fix also shows that AMDGPU was also affected by this bug often, but got away
with it because it was using a G_IMPLICIT_DEF before the use.

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

4 years ago[InstCombine] FoldShiftByConstant - use m_Specific. NFCI.
Simon Pilgrim [Mon, 5 Oct 2020 17:51:12 +0000 (18:51 +0100)]
[InstCombine] FoldShiftByConstant - use m_Specific. NFCI.

Use m_Specific instead of m_Value followed by an equality check - we already do this for the similar folds above, it looks like an oversight in rG2b459fe7e1e where the original pattern match code looked a little different.

4 years agoRevert "[ARM]Fold select_cc(vecreduce_[u|s][min|max], x) into VMINV or VMAXV"
Amara Emerson [Mon, 5 Oct 2020 17:52:43 +0000 (10:52 -0700)]
Revert "[ARM]Fold select_cc(vecreduce_[u|s][min|max], x) into VMINV or VMAXV"

This reverts commit 2573cf3c3d42c943cb91b6e85b803f7671260185.

These seem to break some lit tests.

4 years ago[llvm-objcopy][MachO] Add support for universal binaries
Alexander Shaposhnikov [Mon, 28 Sep 2020 10:37:21 +0000 (03:37 -0700)]
[llvm-objcopy][MachO] Add support for universal binaries

This diff adds support for universal binaries to llvm-objcopy.

Test plan: make check-all

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

4 years ago[SelectionDAG] Don't remove unused negated constant immediately
Qiu Chaofan [Mon, 5 Oct 2020 16:45:24 +0000 (00:45 +0800)]
[SelectionDAG] Don't remove unused negated constant immediately

This reverts partial of a2fb5446 (actually, 2508ef01) about removing
negated FP constant immediately if it has no uses. However, as discussed
in bug 47517, there're cases when NegX is folded into constant from
other places while NegY is removed by that line of code and NegX is
equal to NegY. In these cases, NegX is deleted before used and crash
happens. So revert the code and add necessary test case.

4 years ago[InstCombine] canEvaluateShifted - remove dead (and never used code). NFC.
Simon Pilgrim [Mon, 5 Oct 2020 16:51:13 +0000 (17:51 +0100)]
[InstCombine] canEvaluateShifted - remove dead (and never used code). NFC.

This was already #if'd out when it was added back in 2010 at rG18d7fc8fc6767 and has never been touched since.

4 years agoRevert "[DebugInfo] Improve dbg preservation in LSR."
Nikita Popov [Mon, 5 Oct 2020 16:58:54 +0000 (18:58 +0200)]
Revert "[DebugInfo] Improve dbg preservation in LSR."

This reverts commit a3caf7f6102dc863425f9714b099af58397f0cd2.

The ReleaseLTO-g test-suite configuration has been failing
to build since this commit, because clang segfaults while
building 7zip.

4 years ago[mlir][Linalg] Remove unused variable. NFCI.
Benjamin Kramer [Mon, 5 Oct 2020 16:58:29 +0000 (18:58 +0200)]
[mlir][Linalg] Remove unused variable. NFCI.

4 years agoAdd definition for static constexpr member (NFC)
Mehdi Amini [Mon, 5 Oct 2020 16:55:59 +0000 (16:55 +0000)]
Add definition for static constexpr member (NFC)

Fix the build for some toolchain and config.

4 years ago[flang] Introduce DiagnosticConsumer classes in libflangFrontend
Andrzej Warzynski [Mon, 5 Oct 2020 16:42:00 +0000 (17:42 +0100)]
[flang] Introduce DiagnosticConsumer classes in libflangFrontend

Currently Flang uses TextDiagnostic, TextDiagnosticPrinter &
TestDiagnosticBuffer classes from Clang (more specifically, from
libclangFrontend). This patch introduces simplified equivalents of these
classes in Flang (i.e. it removes the dependency on libclangFrontend).

Flang only needs these diagnostics classes for the compiler driver
diagnostics. This is unlike in Clang in which similar diagnostic classes
are used for e.g. Lexing/Parsing/Sema diagnostics. For this reason, the
implementations introduced here are relatively basic. We can extend them
in the future if this is required.

This patch also enhances how the diagnostics are printed. In particular,
this is the diagnostic that you'd get _before_  the changes introduced here
(no text formatting):

```
$ bin/flang-new
error: no input files
```

This is the diagnostic that you get _after_ the changes introduced here
(in terminals that support it, the text is formatted - bold + red):

```
$ bin/flang-new
flang-new: error: no input files
```

Tests are updated accordingly and options related to enabling/disabling
color diagnostics are flagged as supported by Flang.

Reviewed By: sameeranjoshi, CarolineConcatto

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

4 years agoRevert "[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload"
Joseph Huber [Mon, 5 Oct 2020 16:34:39 +0000 (12:34 -0400)]
Revert "[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload"

Reverting because detecting architecture size doesn't work on all
platforms.

This reverts commit eaf73293cb6b8d45dd85ffced57aea7ad4177754.

4 years ago[SVE] Lower fixed length VECREDUCE_AND operation
Cameron McInally [Mon, 5 Oct 2020 16:27:15 +0000 (11:27 -0500)]
[SVE] Lower fixed length VECREDUCE_AND operation

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

4 years ago[InstCombine] Extend 'shift with constants' vector tests
Simon Pilgrim [Mon, 5 Oct 2020 16:21:54 +0000 (17:21 +0100)]
[InstCombine] Extend 'shift with constants' vector tests

Added missing test coverage for shl(add(and(lshr(x,c1),c2),y),c1) -> add(and(x,c2<<c1),shl(y,c1)) combine

Rename tests as 'foo' and 'bar' isn't very extensible

Added vector tests with undefs and nonuniform constants

4 years ago[InstCombine] Add or(shl(v,and(x,bw-1)),lshr(v,bw-and(x,bw-1))) funnel shift tests
Simon Pilgrim [Mon, 5 Oct 2020 15:50:07 +0000 (16:50 +0100)]
[InstCombine] Add or(shl(v,and(x,bw-1)),lshr(v,bw-and(x,bw-1))) funnel shift tests

If we know the shift amount is less than the bitwidth we should be able to convert this to a funnel shift

4 years ago[X86] isTargetShuffleEquivalent - merge duplicate array accesses. NFCI.
Simon Pilgrim [Mon, 5 Oct 2020 14:51:50 +0000 (15:51 +0100)]
[X86] isTargetShuffleEquivalent - merge duplicate array accesses. NFCI.

4 years ago[libc++/abi] Revert "[libc++] Move the weak symbols list to libc++abi"
Louis Dionne [Mon, 5 Oct 2020 15:42:13 +0000 (11:42 -0400)]
[libc++/abi] Revert "[libc++] Move the weak symbols list to libc++abi"

This reverts commit c7d4aa711a. I am still investigating the issue,
but it looks like that commit has an interaction with ld64 that causes
new/delete weak re-exports not to work properly anymore. This is weird
because this commit did not touch the exports of new/delete -- I am
still investigating.

4 years ago[mlir] Split alloc-like op LLVM lowerings into base and separate derived classes.
Christian Sigg [Thu, 1 Oct 2020 19:51:54 +0000 (21:51 +0200)]
[mlir] Split alloc-like op LLVM lowerings into base and separate derived classes.

The previous code did the lowering to alloca, malloc, and aligned_malloc
in a single class with different code paths that are somewhat difficult to
follow.

This change moves the common code to a base class and has a separte
derived class per lowering target that contains the specifics.

Reviewed By: ftynse

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

4 years ago[docs] Revise loop terminology reference.
Michael Kruse [Mon, 5 Oct 2020 15:21:57 +0000 (10:21 -0500)]
[docs] Revise loop terminology reference.

Motivated by D88183, this seeks to clarify the current loop nomenclature with added illustrations, examples for possibly unexpected situations (infinite loops not part of the "parent" loop, logical loops sharing the same header, ...), and clarification on what other sources may consider a loop. The current document also has multiple errors that are fixed here.

Some selected errors:
 * Loops a defined as strongly-connected components. A component a partition of all nodes, i.e. a subloop can never be a component. That is, the document as it currently is only covers top-level loops, even it also uses the term SCC for subloops.
 * "a block can be the header of two separate loops at the same time" (it is considered a single loop by LoopInfo)
 * "execute before some interesting event happens" (some interesting event is not well-defined)

Reviewed By: baziotis, Whitney

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

4 years agoRevert SVML support for sqrt
Wenlei He [Mon, 5 Oct 2020 15:12:54 +0000 (08:12 -0700)]
Revert SVML support for sqrt

As was brought up in D87169 by @craig.topper we shouldn't map llvm.sqrt to svml since there is a faster native instruction.
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_sqrt_p&expand=5824,5823,5356,5823,5825,5365,5356

Reviewed By: craig.topper

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

4 years ago[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload
Joseph Huber [Sun, 4 Oct 2020 22:12:01 +0000 (18:12 -0400)]
[OpenMP] Add Error Handling for Conflicting Pointer Sizes for Target Offload

Summary:
This patch adds an error to Clang that detects if OpenMP offloading is
used between two architectures with incompatible pointer sizes. This
ensures that the data mapping can be done correctly and solves an issue
in code generation generating the wrong size pointer. This patch adds a
new lit substitution, %omp_powerpc_triple that, if the system is 32-bit or
64-bit, sets the powerpc triple accordingly. This was required to fix
some OpenMP tests that automatically populated the target architecture.

Reviewers: jdoerfert

Subscribers: cfe-commits guansong sstefan1 yaxunl delcypher

Tags: OpenMP clang LLVM

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

4 years ago[OpenMP][Tests] NFC: fix flaky test failure caused by rare scheduling
Joachim Protze [Mon, 5 Oct 2020 11:30:22 +0000 (13:30 +0200)]
[OpenMP][Tests] NFC: fix flaky test failure caused by rare scheduling

The worker thread can start execution of the task before creation of the second task
Fixes the spurious failure reported in https://reviews.llvm.org/D61657

4 years ago[SystemZ] Add support for .insn directives for vector instructions.
Jonas Paulsson [Fri, 25 Sep 2020 16:34:17 +0000 (18:34 +0200)]
[SystemZ] Add support for .insn directives for vector instructions.

Support VRI, VRR, VRS, VRV, VRX, VSI instruction formats with the .insn
directive.

Review: Ulrich Weigand
Differential Revision: https://reviews.llvm.org/D88357

4 years ago[ARM]Fold select_cc(vecreduce_[u|s][min|max], x) into VMINV or VMAXV
Sam Tebbs [Wed, 23 Sep 2020 10:43:27 +0000 (11:43 +0100)]
[ARM]Fold select_cc(vecreduce_[u|s][min|max], x) into VMINV or VMAXV

    This folds a select_cc or select(set_cc) of a max or min vector reduction with a scalar value into a VMAXV or VMINV.

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

4 years ago[mlir][Linalg] Canonicalize TensorCastOp away when it feeds a LinalgOp.
Nicolas Vasilache [Mon, 5 Oct 2020 14:36:19 +0000 (14:36 +0000)]
[mlir][Linalg] Canonicalize TensorCastOp away when it feeds a LinalgOp.

This canonicalization is the counterpart of MemRefCastOp -> LinalgOp but on tensors.

This is needed to properly canonicalize post linalg tiling on tensors.

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

4 years ago[VPlan] Clean up uses/operands on VPBB deletion.
Florian Hahn [Sat, 3 Oct 2020 16:40:42 +0000 (17:40 +0100)]
[VPlan] Clean up uses/operands on VPBB deletion.

Update the code responsible for deleting VPBBs and recipes to properly
update users and release operands.

This is another preparation for D84680 & following patches towards
enabling modeling def-use chains in VPlan.

4 years ago[Parser] ParseMicrosoftAsmStatement - Replace bit '|' operator with logical '||'...
Simon Pilgrim [Mon, 5 Oct 2020 13:23:13 +0000 (14:23 +0100)]
[Parser] ParseMicrosoftAsmStatement - Replace bit '|' operator with logical '||' operator. (PR47071)

Fixes static analysis warning.

4 years ago[clangd] Add isKeyword function.
Haojian Wu [Mon, 5 Oct 2020 13:10:53 +0000 (15:10 +0200)]
[clangd] Add isKeyword function.

This will be used in rename for doing basic name validation.

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

4 years ago[LV] Regenerate test. NFC
David Green [Mon, 5 Oct 2020 12:46:15 +0000 (13:46 +0100)]
[LV] Regenerate test. NFC

This just reruns the update script to add the new
[[LOOP0:!llvm.loop !.*]] checks to remove them from
other diffs.

4 years ago[ValueTracking] canCreateUndefOrPoison - use APInt to check bounds instead of getZExt...
Simon Pilgrim [Mon, 5 Oct 2020 12:45:27 +0000 (13:45 +0100)]
[ValueTracking] canCreateUndefOrPoison - use APInt to check bounds instead of getZExtValue().

Fixes OSS Fuzz #26135

4 years ago[ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl
Gabor Marton [Thu, 1 Oct 2020 15:45:57 +0000 (17:45 +0200)]
[ASTImporter][AST] Fix structural equivalency crash on dependent FieldDecl

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

4 years ago[AMDGPU][RegAlloc][SplitKit] Pre-commit test for D88821
Carl Ritson [Mon, 5 Oct 2020 11:26:27 +0000 (20:26 +0900)]
[AMDGPU][RegAlloc][SplitKit] Pre-commit test for D88821

4 years ago[TableGen] Added a function for identification of unsupported opcodes.
Dmitry Preobrazhensky [Mon, 5 Oct 2020 11:23:41 +0000 (14:23 +0300)]
[TableGen] Added a function for identification of unsupported opcodes.

This change implements generation of a function which may be used by a backend to check if a given instruction is supported for a specific subtarget.

Reviewers: sdesmalen

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

4 years ago[clangd] Remove unused using-decls in TypeHierarchyTests, NFC.
Haojian Wu [Mon, 5 Oct 2020 11:14:53 +0000 (13:14 +0200)]
[clangd] Remove unused using-decls in TypeHierarchyTests, NFC.

4 years ago[AST][RecoveryExpr] Fix a crash on undeduced type.
Haojian Wu [Mon, 5 Oct 2020 10:52:03 +0000 (12:52 +0200)]
[AST][RecoveryExpr] Fix a crash on undeduced type.

We should not capture the type if the function return type is undeduced.

Reviewed By: adamcz

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

4 years agoReland "[lldb] Don't send invalid region addresses to lldb server"
David Spickett [Thu, 24 Sep 2020 13:50:41 +0000 (14:50 +0100)]
Reland "[lldb] Don't send invalid region addresses to lldb server"

This reverts commit c65627a1fe3be7521fc232d633bb6df577f55269.

The test immediately after the new invalid symbol test was
failing on Windows. This was because when we called
VirtualQueryEx to get the region info for 0x0,
even if it succeeded we would call GetLastError.

Which must have picked up the last error that was set while
trying to lookup "not_an_address". Which happened to be 2.
("The system cannot find the file specified.")

To fix this only call GetLastError when we know VirtualQueryEx
has failed. (when it returns 0, which we were also checking for anyway)

Also convert memory region to an early return style
to make the logic clearer.

Reviewed By: labath, stella.stamenova

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

4 years ago[AMDGPU] Use tablegen for argument indices
Sebastian Neubauer [Wed, 30 Sep 2020 12:15:24 +0000 (14:15 +0200)]
[AMDGPU] Use tablegen for argument indices

Use tablegen generic tables to get the index of image intrinsic
arguments.
Before, the computation of which image intrinsic argument is at which
index was scattered in a few places, tablegen, the SDag instruction
selection and GlobalISel. This patch changes that, so only tablegen
contains code to compute indices and the ImageDimIntrinsicInfo table
provides these information.

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

4 years ago[mlir] Fix SubViewOp doc in .td
Nicolas Vasilache [Mon, 5 Oct 2020 09:44:27 +0000 (05:44 -0400)]
[mlir] Fix SubViewOp doc in .td

4 years ago[VE] Support register and frame-index pair correctly
Kazushi (Jam) Marukawa [Mon, 21 Sep 2020 08:17:29 +0000 (17:17 +0900)]
[VE] Support register and frame-index pair correctly

Support register and frame-index pair correctly as operands of
generic load/store instrucitons, e.g. LD1BZXrri, STLrri, and etc.
Add regression tests also.

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

4 years agoPromote transpose from linalg to standard dialect
Benjamin Kramer [Wed, 30 Sep 2020 17:19:04 +0000 (19:19 +0200)]
Promote transpose from linalg to standard dialect

While affine maps are part of the builtin memref type, there is very
limited support for manipulating them in the standard dialect. Add
transpose to the set of ops to complement the existing view/subview ops.
This is a metadata transformation that encodes the transpose into the
strides of a memref.

I'm planning to use this when lowering operations on strided memrefs,
using the transpose to remove the stride without adding a dependency on
linalg dialect.

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

4 years ago[AMDGPU] Make bfe patterns divergence-aware
Jay Foad [Fri, 25 Sep 2020 15:07:27 +0000 (16:07 +0100)]
[AMDGPU] Make bfe patterns divergence-aware

This tends to increase code size but more importantly it reduces vgpr
usage, and could avoid costly readfirstlanes if the result needs to be
in an sgpr.

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

4 years ago[AMDGPU] Split R600 and GCN bfe patterns
Jay Foad [Fri, 25 Sep 2020 14:55:02 +0000 (15:55 +0100)]
[AMDGPU] Split R600 and GCN bfe patterns

This is in preparation for making the GCN patterns divergence-aware.
NFC.

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

4 years ago[TableGen][GlobalISel] add handling of nested *_SUBREG
Gabriel Hjort Åkerlund [Mon, 5 Oct 2020 08:28:50 +0000 (10:28 +0200)]
[TableGen][GlobalISel] add handling of nested *_SUBREG

When nesting INSERT_SUBREG and EXTRACT_SUBREG, GlobalISelEmitter would
fail to find the register class of the nested node. This patch fixes
that for registers with subregs.

Reviewed By: arsenm

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

4 years ago[AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.
Haojian Wu [Mon, 5 Oct 2020 08:35:29 +0000 (10:35 +0200)]
[AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

The error-bit was missing, if a DeclRefExpr (which refers to a VarDecl
with a contains-errors initializer).

It could cause different violations in clang -- the DeclRefExpr is value-dependent,
but not contains-errors, `ABC<DeclRefExpr>` could produce a non-error
and non-dependent type in non-template context, which will lead to
crashes in constexpr evaluation.

Reviewed By: sammccall

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

4 years ago[DebugInfo] Improve dbg preservation in LSR.
Markus Lavin [Mon, 5 Oct 2020 07:27:30 +0000 (09:27 +0200)]
[DebugInfo] Improve dbg preservation in LSR.

Use SCEV to salvage additional @llvm.dbg.value that have turned into
referencing undef after transformation (and traditional
salvageDebugInfo). Before transformation compute SCEV for each
@llvm.dbg.value in the loop body and store it (along side its current
DIExpression). After transformation update those @llvm.dbg.value now
referencing undef by comparing its stored SCEV to the SCEV of the
current loop-header PHI-nodes. Allow match with offset by inserting
compensation code in the DIExpression.

Fixes : PR38815

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

4 years ago[RISCV][ASAN] mark asan as supported for RISCV64 and enable tests
Alexey Baturo [Sun, 4 Oct 2020 13:51:04 +0000 (16:51 +0300)]
[RISCV][ASAN] mark asan as supported for RISCV64 and enable tests

[11/11] patch series to port ASAN for riscv64

These changes allow using ASAN on RISCV64 architecture.
The majority of existing tests are passing. With few exceptions (see below).
Tests we run on qemu and on "HiFive Unleashed" board.

Tests run:

```
Asan-riscv64-inline-Test  - pass
Asan-riscv64-inline-Noinst-Test  - pass
Asan-riscv64-calls-Noinst-Test  - pass
Asan-riscv64-calls-Test  - pass
```

Lit tests:

```
RISCV64LinuxConfig (282 supported, few failures)
RISCV64LinuxDynamicConfig (289 supported, few failures)
```

Lit failures:

```
TestCases/malloc_context_size.cpp - asan works, but backtrace misses some calls
TestCases/Linux/malloc_delete_mismatch.cpp - asan works, but backtrace misses some calls
TestCases/Linux/static_tls.cpp - "Can't guess glibc version" (under debugging)
TestCases/asan_and_llvm_coverage_test.cpp - missing libclang_rt.profile-riscv64.a
```

These failures are under debugging currently and shall be addressed in a
subsequent commits.

Depends On D87581

Reviewed By: eugenis, vitalybuka

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

4 years ago[llvm] Rename DwarfFile to DWARFFile to fix ODR violation (NFC)
Jonas Devlieghere [Mon, 5 Oct 2020 06:46:26 +0000 (23:46 -0700)]
[llvm] Rename DwarfFile to DWARFFile to fix ODR violation (NFC)

Rename the DwarfFile class in DWARFLinker to DWARFFile. This is
consistent with the other DWARF classes and avoids a ODR violation with
the DwarfFile class in AsmPrinter.

4 years ago[lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin
Michał Górny [Mon, 5 Oct 2020 06:03:46 +0000 (23:03 -0700)]
[lldb] [test/Register] Attempt to fix x86-fp-read.test on Darwin

Darwin seems to use stmmN instead of stN. Use a regex to accept both.

Also try to actually clear st(7).

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

4 years ago[X86] MWAITX_SAVE_RBX should not have EBX as an implicit use.
Craig Topper [Mon, 5 Oct 2020 03:34:31 +0000 (20:34 -0700)]
[X86] MWAITX_SAVE_RBX should not have EBX as an implicit use.

RBX was copied to a virtual register before this instruction
was created. And the EBX input for the final MWAITX is still
in a virtual register. So EBX isn't read by this pseudo.

4 years agollvm-dwarfdump: Don't try to parse rnglist tables when dumping CUs
David Blaikie [Mon, 5 Oct 2020 02:06:28 +0000 (19:06 -0700)]
llvm-dwarfdump: Don't try to parse rnglist tables when dumping CUs

It's not possible to do this in complete generality - a CU using a
sec_offset DW_AT_ranges has no way of knowing where its rnglists
contribution starts, so should not attempt to parse any full rnglist
table/header to do so. And even using FORM_rnglistx there's no need to
parse the header - the offset can be computed using the CU's DWARF
format (32 or 64) to compute offset entry sizes, and then the list
parsed at that offset without ever trying to find a rnglist contribution
header immediately prior to the rnglists_base.

4 years ago[HIP] Fix -fgpu-allow-device-init option
Yaxun (Sam) Liu [Wed, 30 Sep 2020 03:52:03 +0000 (23:52 -0400)]
[HIP] Fix -fgpu-allow-device-init option

The option needs to be passed to both host and device compilation.

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

4 years ago[HIP] Fix default output file for -E
Yaxun (Sam) Liu [Fri, 2 Oct 2020 12:08:26 +0000 (08:08 -0400)]
[HIP] Fix default output file for -E

By convention the default output file for -E is "-" (stdout).
This is expected by tools like ccache, which uses output
of -E to determine if a file and its dependence has changed.

Currently clang does not use stdout as default output file for -E
for HIP, which causes ccache not working.

This patch fixes that.

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

4 years agoRecommit "[HIP] Add option --gpu-instrument-lib="
Yaxun (Sam) Liu [Mon, 5 Oct 2020 01:32:35 +0000 (21:32 -0400)]
Recommit "[HIP] Add option --gpu-instrument-lib="

recommit 64f7790e7d2309b5d38949921a256acf8068e659 after
fixing hip-device-libs.hip.

4 years agoRevert "[HIP] Add option --gpu-instrument-lib="
Yaxun (Sam) Liu [Mon, 5 Oct 2020 01:27:29 +0000 (21:27 -0400)]
Revert "[HIP] Add option --gpu-instrument-lib="

This reverts commit 64f7790e7d2309b5d38949921a256acf8068e659 due
to regression in hip-device-libs.hip.

4 years ago[HIP] Add option --gpu-instrument-lib=
Yaxun (Sam) Liu [Wed, 30 Sep 2020 12:01:02 +0000 (08:01 -0400)]
[HIP] Add option --gpu-instrument-lib=

Add an option --gpu-instrument-lib= to allow users to specify
an instrument device library. This is for supporting -finstrument
in device code for debugging/profiling tools.

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

4 years agollvm-dwarfdump: Add support for DW_RLE_startx_endx
David Blaikie [Mon, 5 Oct 2020 00:50:24 +0000 (17:50 -0700)]
llvm-dwarfdump: Add support for DW_RLE_startx_endx

4 years ago[X86] Remove MWAITX_SAVE_EBX pseudo instruction. Always save/restore the full %rbx...
Craig Topper [Sun, 4 Oct 2020 23:25:35 +0000 (16:25 -0700)]
[X86] Remove MWAITX_SAVE_EBX pseudo instruction. Always save/restore the full %rbx register even in gnux32.

ebx/rbx only needs to be saved when 64-bit registers are supported
anyway. It should be fine to save/restore the whole rbx register
even in gnux32 where the base is technically just ebx.

This matches what we do for cmpxchg16b where rbx is saved/restored
regardless of gnux32.

4 years agollvm-dwarfdump: Print addresses in debug_line to the parsed address size
David Blaikie [Sun, 4 Oct 2020 23:01:05 +0000 (16:01 -0700)]
llvm-dwarfdump: Print addresses in debug_line to the parsed address size

4 years ago[NewPM] collapsing nested pass mangers of the same type
Yuanfang Chen [Sat, 3 Oct 2020 00:16:22 +0000 (17:16 -0700)]
[NewPM] collapsing nested pass mangers of the same type

This is one of the reason for extra invalidations in D84959. In
practice, I don't think we have use cases needing this. This simplifies
the pipeline a bit and prune corner cases when considering
invalidations.

Reviewed By: asbirlea

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

4 years ago[NFCI] Remove unnecessary trailing undef in RuntimeLibcalls.def
Yuanfang Chen [Sat, 3 Oct 2020 00:13:27 +0000 (17:13 -0700)]
[NFCI] Remove unnecessary trailing undef in RuntimeLibcalls.def

All uses of the file undef the macro already.

4 years agollvm-dwarfdump: Dump address forms in their encoded length rather than always in...
David Blaikie [Sun, 4 Oct 2020 22:42:03 +0000 (15:42 -0700)]
llvm-dwarfdump: Dump address forms in their encoded length rather than always in 64 bits

Few places did this already - refactor them all into a common helper.

4 years ago[DomTree] findNearestCommonDominator: assert the nodes are in tree
Fangrui Song [Sun, 4 Oct 2020 22:34:41 +0000 (15:34 -0700)]
[DomTree] findNearestCommonDominator: assert the nodes are in tree

i.e. they cannot be unreachable from the entry (which usually indicate usage errors).
This change allows the removal of some nullptr checks.

Reviewed By: kuhar

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

4 years ago[X86] Correct the implicit defs/uses for the MWAITX pseudo instructions.
Craig Topper [Sun, 4 Oct 2020 20:53:13 +0000 (13:53 -0700)]
[X86] Correct the implicit defs/uses for the MWAITX pseudo instructions.

MWAITX doesn't touch EFLAGS so no pseudos should def EFLAGS.

The SAVE_EBX/RBX pseudos only needs to def the EBX register that
the expansion overwrites. The EAX and ECX registers are only read.

The pseudo emitted during isel that is used by the custom inserter
shouldn't have any implicit defs or uses since everything is in
vregs.

4 years ago[X86] Remove usesCustomInserter from MWAITX_SAVE_EBX and MWAITX_SAVE_RBX. NFC
Craig Topper [Sun, 4 Oct 2020 19:17:54 +0000 (12:17 -0700)]
[X86] Remove usesCustomInserter from MWAITX_SAVE_EBX and MWAITX_SAVE_RBX. NFC

These are now emitted by a CustomInserter rather than using a custom
inserter themselves.

4 years agoRevert "[RFC] Factor out repetitive cmake patterns for llvm-style projects"
Stephen Neuendorffer [Sun, 4 Oct 2020 22:17:34 +0000 (15:17 -0700)]
Revert "[RFC] Factor out repetitive cmake patterns for llvm-style projects"

This reverts commit e9b87f43bde8b5f0d8a79c5884fdce639b12e0ca.

There are issues with macros generating macros without an obvious simple fix
so I'm going to revert this and try something different.

4 years ago[Coroutines][NewPM] Fix coroutine tests under new pass manager
Arthur Eubanks [Mon, 14 Sep 2020 18:22:17 +0000 (11:22 -0700)]
[Coroutines][NewPM] Fix coroutine tests under new pass manager

Some new function parameter attributes are derived under NPM.

Reviewed By: rjmccall

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

4 years ago[NFC][SCEV] Add a test with some patterns where we could treat inttoptr/ptrtoint...
Roman Lebedev [Sun, 4 Oct 2020 19:06:57 +0000 (22:06 +0300)]
[NFC][SCEV] Add a test with some patterns where we could treat inttoptr/ptrtoint as semi-transparent

4 years agollvm-dwarfdump: Skip tombstoned address ranges
David Blaikie [Sun, 4 Oct 2020 19:28:37 +0000 (12:28 -0700)]
llvm-dwarfdump: Skip tombstoned address ranges

Make the dumper & API a bit more informative by using the new tombstone
addresses to filter out or otherwise render more explicitly dead code
ranges.

4 years ago[MemCpyOpt] Add tests for call slot optimization with GEPs (NFC)
Nikita Popov [Sun, 4 Oct 2020 20:25:28 +0000 (22:25 +0200)]
[MemCpyOpt] Add tests for call slot optimization with GEPs (NFC)

4 years agoImplement callee/caller type checking for llvm.call
Mehdi Amini [Sat, 3 Oct 2020 03:30:21 +0000 (03:30 +0000)]
Implement callee/caller type checking for llvm.call

This aligns the behavior with the standard call as well as the LLVM verifier.

Reviewed By: ftynse, dcaballe

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