platform/upstream/llvm.git
3 years ago[SimplifyCFG] Update FoldBranchToCommonDest to be poison-safe
Juneyoung Lee [Sun, 7 Mar 2021 16:23:04 +0000 (01:23 +0900)]
[SimplifyCFG] Update FoldBranchToCommonDest to be poison-safe

This patch makes FoldBranchToCommonDest merge branch conditions into `select i1` rather than `and/or i1` when it is called by SimplifyCFG.
It is known that merging conditions into and/or is poison-unsafe, and this is towards making things *more* correct by removing possible miscompilations.
Currently, InstCombine simply consumes these selects into and/or of i1 (which is also unsafe), so the visible effect would be very small. The unsafe select -> and/or transformation will be removed in the future.
There has been efforts for updating optimizations to support the select form as well, and they are linked to D93065.

The safe transformation is fired when it is called by SimplifyCFG only. This is done by setting the new `PoisonSafe` argument as true.
Another place that calls FoldBranchToCommonDest is LoopSimplify. `PoisonSafe` flag is set to false in this case because enabling it has a nontrivial impact in performance because SCEV is more conservative with select form and InductiveRangeCheckElimination isn't aware of select form of and/or i1.

Reviewed By: nikic

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

3 years ago[LoopUnswitch] unswitch if cond is in select form of and/or as well
Juneyoung Lee [Sun, 7 Mar 2021 16:05:31 +0000 (01:05 +0900)]
[LoopUnswitch] unswitch if cond is in select form of and/or as well

Hello all,
I'm trying to fix unsafe propagation of poison values in and/or conditions by using
equivalent select forms (`select i1 A, i1 B, i1 false` and `select i1 A, i1 true, i1 false`)
instead.
D93065 has links to patches for this.

This patch allows unswitch to happen if the condition is in this form as well.
`collectHomogenousInstGraphLoopInvariants` is updated to keep traversal if
Root and the visiting I matches both m_LogicalOr()/m_LogicalAnd().
Other than this, the remaining changes are almost straightforward and simply replaces
Instruction::And/Or check with match(m_LogicalOr()/m_LogicalAnd()).

Reviewed By: nikic

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

3 years ago[InstCombine] enrich select-safe-bool-transforms.ll test (NFC)
Juneyoung Lee [Sun, 7 Mar 2021 15:01:05 +0000 (00:01 +0900)]
[InstCombine] enrich select-safe-bool-transforms.ll test (NFC)

for https://reviews.llvm.org/D96945

3 years ago[ValueTracking] update directlyImpliesPoison to look into select's condition
Juneyoung Lee [Sun, 7 Mar 2021 14:16:39 +0000 (23:16 +0900)]
[ValueTracking] update directlyImpliesPoison to look into select's condition

This is a minor update in directlyImpliesPoison and makes it look into select's
condition.
Splitted from https://reviews.llvm.org/D96945

3 years ago[X86] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFB handling.
Simon Pilgrim [Sun, 7 Mar 2021 12:56:35 +0000 (12:56 +0000)]
[X86] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFB handling.

3 years ago[X86] canonicalizeShuffleWithBinOps - shuffle oneuse constants.
Simon Pilgrim [Sun, 7 Mar 2021 11:17:03 +0000 (11:17 +0000)]
[X86] canonicalizeShuffleWithBinOps - shuffle oneuse constants.

We can freely shuffle all ones/zeros constants but we can also freely shuffle other constants as long as they only have one use.

3 years ago[libcxx] [test] Fix path.modifiers remove_filename and replace_filename for windows
Martin Storsjö [Thu, 15 Oct 2020 10:47:36 +0000 (13:47 +0300)]
[libcxx] [test] Fix path.modifiers remove_filename and replace_filename for windows

Also fix the synopsis in the replace_filename test, while touching
that file.

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

3 years ago[libunwind] Install the DLL when doing "ninja install"
Martin Storsjö [Thu, 4 Mar 2021 20:48:41 +0000 (22:48 +0200)]
[libunwind] Install the DLL when doing "ninja install"

This matches how install(... RUNTIME) is used in e.g. libcxx.

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

3 years ago[Driver] Pass --unwindlib=platform to tests that check unwinder
Petr Hosek [Sun, 7 Mar 2021 01:42:36 +0000 (17:42 -0800)]
[Driver] Pass --unwindlib=platform to tests that check unwinder

This addresses an issue which was revealed by D98022.

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

3 years ago[NFC][AMDGPU]DWARF Extensions For Heterogeneous Debugging generic type endianity
Tony [Sat, 6 Mar 2021 20:12:22 +0000 (20:12 +0000)]
[NFC][AMDGPU]DWARF Extensions For Heterogeneous Debugging generic type endianity

In "DWARF Extensions For Heterogeneous Debugging" document that the
DWARF generic type has a target architecture defined endianity.

Reviewed By: scott.linder

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

3 years ago[MC] Migrate some parseToken(AsmToken::EndOfStatement, ...) to parseEOL()
Fangrui Song [Sun, 7 Mar 2021 03:25:22 +0000 (19:25 -0800)]
[MC] Migrate some parseToken(AsmToken::EndOfStatement, ...) to parseEOL()

3 years ago[MC] Add parseEOL() overload and migrate some parseToken(AsmToken::EndOfStatement...
Fangrui Song [Sun, 7 Mar 2021 01:45:23 +0000 (17:45 -0800)]
[MC] Add parseEOL() overload and migrate some parseToken(AsmToken::EndOfStatement) to parseEOL()

For many directives, the following diagnostics

* `error: unexpected token`
* `error: unexpected token in '.abort' directive"`

are replaced with `error: expected newline`.

`unexpected token` may make the user think a different token is needed.
`expected newline` is clearer about the expected token.

For `in '...' directive`, the directive name is not useful because the next line
replicates the error line which includes the directive.

3 years ago[MC] Parse end-of-line for .addrsig & .addrsig_sym
Fangrui Song [Sun, 7 Mar 2021 00:26:27 +0000 (16:26 -0800)]
[MC] Parse end-of-line for .addrsig & .addrsig_sym

3 years ago[MC] Parse end-of-line for .cfi_* directives
Fangrui Song [Sun, 7 Mar 2021 00:20:55 +0000 (16:20 -0800)]
[MC] Parse end-of-line for .cfi_* directives

Otherwise MCAsmStreamer will emit duplicate newlines.

3 years ago[TableGen] Use range-based for loops (NFC)
Kazu Hirata [Sat, 6 Mar 2021 23:52:55 +0000 (15:52 -0800)]
[TableGen] Use range-based for loops (NFC)

3 years ago[objdump] Use ListSeparator (NFC)
Kazu Hirata [Sat, 6 Mar 2021 23:52:54 +0000 (15:52 -0800)]
[objdump] Use ListSeparator (NFC)

3 years ago[clang] Fix typos in documentation (NFC)
Kazu Hirata [Sat, 6 Mar 2021 23:52:52 +0000 (15:52 -0800)]
[clang] Fix typos in documentation (NFC)

3 years ago[MC] Support .symver *, *, remove
Fangrui Song [Sat, 6 Mar 2021 23:23:02 +0000 (15:23 -0800)]
[MC] Support .symver *, *, remove

As a resolution to https://sourceware.org/bugzilla/show_bug.cgi?id=25295 , GNU as
from binutils 2.35 supports the optional third argument for the .symver directive.

'remove' for a non-default version is useful:
`.symver def_v1, def@v1, remove` => def_v1 is not retained in the symbol table.
Previously the user has to strip the original symbol or specify a `local:`
version node in a version script to localize the symbol.

`.symver def, def@@v1, remove` and `.symver def, def@@@v1, remove` are supported
as well, though they are identical to `.symver def, def@@@v1`.

local/hidden are not useful so this patch does not implement them.

3 years ago[GVN] Don't explicitly materialize undefs from dead blocks
Nikita Popov [Sat, 6 Mar 2021 22:28:38 +0000 (23:28 +0100)]
[GVN] Don't explicitly materialize undefs from dead blocks

When materializing an available load value, do not explicitly
materialize the undef values from dead blocks. Doing so will
will force creation of a phi with an undef operand, even if there
is a dominating definition. The phi will be folded away on
subsequent GVN iterations, but by then we may have already
poisoned MDA cache slots.

Simply don't register these values in the first place, and let
SSAUpdater do its thing.

3 years ago[GVN] Add test for load GVN with dead block (NFC)
Nikita Popov [Sat, 6 Mar 2021 22:17:28 +0000 (23:17 +0100)]
[GVN] Add test for load GVN with dead block (NFC)

What this test illustrates is that GVN inserts an unnecessary
phi node initially, which prevents alias analysis from establishing
NoAlias, and MDA caches that result. We would be able to fully fold
this after another -gvn run with clean MDA.

3 years ago[ModuleSummaryAnalysis] Avoid duplicate elements in Worklist. NFC
Fangrui Song [Sat, 6 Mar 2021 22:19:22 +0000 (14:19 -0800)]
[ModuleSummaryAnalysis] Avoid duplicate elements in Worklist. NFC

3 years ago[FunctionImport] Delete unneeded setLive. NFC
Fangrui Song [Sat, 6 Mar 2021 22:09:54 +0000 (14:09 -0800)]
[FunctionImport] Delete unneeded setLive. NFC

ValueInfo's in Worklist are guaranteed to be live.

3 years ago[VPlan] Support to widen call intructions in VPlan native path
Mauri Mustonen [Sat, 6 Mar 2021 21:45:50 +0000 (21:45 +0000)]
[VPlan] Support to widen call intructions in VPlan native path

Add support to widen call instructions in VPlan native path by using a correct recipe when such instructions are encountered. This is already used by inner loop vectorizer.

Previously call instructions got handled by wrong recipes and resulted in unreachable instruction errors like this one: https://bugs.llvm.org/show_bug.cgi?id=48139.

Patch by Mauri Mustonen <mauri.mustonen@tuni.fi>

Reviewed By: fhahn

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

3 years ago[libcxx] [test] Fix lexically_normal and lexically_relative_and_proximate for windows
Martin Storsjö [Thu, 15 Oct 2020 10:58:32 +0000 (13:58 +0300)]
[libcxx] [test] Fix lexically_normal and lexically_relative_and_proximate for windows

Convert the expected result path to preferred separators, add exceptions
to the test results where needed (due to some cases being interpreted
as a root name).

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

3 years ago[InstCombine] Don't canonicalize (gep i8* X, -(ptrtoint Y)) as (inttoptr (sub...
Roman Lebedev [Sat, 6 Mar 2021 19:58:53 +0000 (22:58 +0300)]
[InstCombine] Don't canonicalize  (gep i8* X, -(ptrtoint Y))  as  (inttoptr (sub (ptrtoint X), (ptrtoint Y)))

It's just a wrong thing to do.

We introduce inttoptr where there were none, which results in
loosing all provenance information because we no longer have a GEP{i,},
and pessimize all future optimizations,
because we are basically not allowed to look past `inttoptr`.

(gep i8* X, -(ptrtoint Y))  *is* the canonical form.
So just drop this fold.

Noticed while reviewing D98120.

3 years ago[NFC][InstCombine] Add plain GEP test for (gep i8* X, -(ptrtoint Y)) --> (inttoptr...
Roman Lebedev [Sat, 6 Mar 2021 19:53:30 +0000 (22:53 +0300)]
[NFC][InstCombine] Add plain GEP test for  (gep i8* X, -(ptrtoint Y))  -->  (inttoptr (sub (ptrtoint X), (ptrtoint Y)))  fold

3 years ago[rs4gc] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds
Fangrui Song [Sat, 6 Mar 2021 19:42:27 +0000 (11:42 -0800)]
[rs4gc] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds

3 years ago[NFCI] SCEVExpander: emit intrinsics for integral {u,s}{min,max} SCEV expressions
Roman Lebedev [Fri, 26 Feb 2021 13:48:58 +0000 (16:48 +0300)]
[NFCI] SCEVExpander: emit intrinsics for integral {u,s}{min,max} SCEV expressions

These intrinsics, not the icmp+select are the canonical form nowadays,
so we might as well directly emit them.

This should not cause any regressions, but if it does,
then then they would needed to be fixed regardless.

Note that this doesn't deal with `SCEVExpander::isHighCostExpansion()`,
but that is a pessimization, not a correctness issue.

Additionally, the non-intrinsic form has issues with undef,
see https://reviews.llvm.org/D88287#2587863

3 years ago[PowePC][AIX] Handle variadic vector call operands.
Sean Fertile [Sat, 6 Mar 2021 16:33:35 +0000 (11:33 -0500)]
[PowePC][AIX] Handle variadic vector call operands.

Patch adds support for passing vector call operands to variadic
functions. Arguments which are fixed shadow GPRs and stack space even
when they are passed in vector registers, while arguments passed through
ellipses are passed in properly aligned GPRs if available and on the
stack once all GPR arguments registers are consumed.

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

3 years ago[NPM] Add -enable-loopinterchange option to NPM
Ta-Wei Tu [Sat, 6 Mar 2021 18:37:54 +0000 (02:37 +0800)]
[NPM] Add -enable-loopinterchange option to NPM

We have the `enable-loopinterchange` option in legacy pass manager but not in NPM.
Add `LoopInterchange` pass to the optimization pipeline (at the same position as before)
when `enable-loopinterchange` is turned on.

Reviewed By: aeubanks, fhahn

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

3 years ago[XRay][compiler-rt][x86_64] Fix CFI directives in assembly trampolines
Elia Geretto [Sat, 6 Mar 2021 18:38:27 +0000 (10:38 -0800)]
[XRay][compiler-rt][x86_64] Fix CFI directives in assembly trampolines

This patch modifies the x86_64 XRay trampolines to fix the CFI information
generated by the assembler. One of the main issues in correcting the CFI
directives is the `ALIGNED_CALL_RAX` macro, which makes the CFA dependent on
the alignment of the stack. However, this macro is not really necessary because
some additional assumptions can be made on the alignment of the stack when the
trampolines are called. The code has been written as if the stack is guaranteed
to be 8-bytes aligned; however, it is instead guaranteed to be misaligned by 8
bytes with respect to a 16-bytes alignment. For this reason, always moving the
stack pointer by 8 bytes is sufficient to restore the appropriate alignment.

Trampolines that are called from within a function as a result of the builtins
`__xray_typedevent` and `__xray_customevent` are necessarely called with the
stack properly aligned so, in this case too, `ALIGNED_CALL_RAX` can be
eliminated.

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

Reviewed By: MaskRay

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

3 years ago[sanitizer] Restrict clock_gettime workaround to glibc
Fangrui Song [Sat, 6 Mar 2021 18:32:27 +0000 (10:32 -0800)]
[sanitizer] Restrict clock_gettime workaround to glibc

The hackery is due to glibc clock_gettime crashing from preinit_array (D40679).
32-bit musl architectures do not define `__NR_clock_gettime` so the code causes a compile error.

Tested on Alpine Linux x86-64 (musl) and FreeBSD x86-64.

Reviewed By: vitalybuka

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

3 years ago[Attributor] Enable heap-to-stack of any size
William S. Moses [Tue, 2 Mar 2021 19:41:43 +0000 (14:41 -0500)]
[Attributor] Enable heap-to-stack of any size

Enable Attributor's heap-to-stack to lower unbounded allocations given a max size of -1

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

3 years ago[tests] Update an autogen test for format change
Philip Reames [Sat, 6 Mar 2021 17:49:27 +0000 (09:49 -0800)]
[tests] Update an autogen test for format change

3 years ago[gvn] Handle simply phi equivalence cases
Philip Reames [Sat, 6 Mar 2021 17:27:19 +0000 (09:27 -0800)]
[gvn] Handle simply phi equivalence cases

GVN basically doesn't handle phi nodes at all. This is for a reason - we can't value number their inputs since the predecessor blocks have probably not been visited yet.

However, it also creates a significant pass ordering problem. As it stands, instcombine and simplifycfg ends up implementing CSE of phi nodes. This means that for any series of CSE opportunities intermixed with phi nodes, we end up having to alternate instcombine/simplifycfg and gvn to make progress.

This patch handles the simplest case by simply preprocessing the phi instructions in a block, and CSEing them if they are syntactically identical. This turns out to be powerful enough to handle many cases in a single invocation of GVN since blocks which use the cse'd phi results are visited after the block containing the phi. If there's a CSE opportunity in one the phi predecessors required to recognize the phi CSE opportunity, that will require a second iteration on the function. (Still within a single run of gvn though.)

Compile time wise, this could go either way. On one hand, we're potentially causing GVN to iterate over the function more. On the other, we're cutting down on iterations between two passes and potentially shrinking the IR aggressively. So, a bit unclear what to expect.

Note that this does still rely on instcombine to canonicalize block order of the phis, but that's a one time transformation independent of the values incoming to the phi.

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

3 years ago[libcxx] [test] Fix path.itr/iterator.pass.cpp for windows
Martin Storsjö [Wed, 4 Nov 2020 09:06:45 +0000 (11:06 +0200)]
[libcxx] [test] Fix path.itr/iterator.pass.cpp for windows

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

3 years ago[rs4gc/tests] Remove use of internal debug flags
Philip Reames [Sat, 6 Mar 2021 17:20:02 +0000 (09:20 -0800)]
[rs4gc/tests] Remove use of internal debug flags

As a pragmatic tradeoff, the ease of updating the tests outweighs the slightly easier to understand test conditions.  Where revevant, debug output was converted to comments to help human understanding.

3 years ago[rs4gc] autogen a bunch of tests for ease of update
Philip Reames [Sat, 6 Mar 2021 17:04:00 +0000 (09:04 -0800)]
[rs4gc] autogen a bunch of tests for ease of update

3 years ago[rs4gc] track the original value in the state use for base pointer rewriting
Philip Reames [Sat, 6 Mar 2021 02:05:21 +0000 (18:05 -0800)]
[rs4gc] track the original value in the state use for base pointer rewriting

I'd originally intended to build on this for another purpose and have decided not to, but at a minimum, the stronger asserts are useful.

3 years ago[rs4gc] minor code style improvement
Philip Reames [Sat, 6 Mar 2021 00:51:53 +0000 (16:51 -0800)]
[rs4gc] minor code style improvement

3 years ago[lld-macho][NFC] Replace config param with a global in hasCompatVersion() helper.
Vy Nguyen [Sat, 6 Mar 2021 16:31:16 +0000 (11:31 -0500)]
[lld-macho][NFC] Replace config param with a global in hasCompatVersion() helper.

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

3 years ago[Loads] Restructure getAvailableLoadStore implementation (NFC)
Nikita Popov [Sat, 6 Mar 2021 14:58:18 +0000 (15:58 +0100)]
[Loads] Restructure getAvailableLoadStore implementation (NFC)

Separate out some conditions with early exits, to make it easier to
support additional cases.

3 years ago[InstCombine] Add tests for non-trivial store to load forward (NFC)
Nikita Popov [Sat, 6 Mar 2021 15:49:25 +0000 (16:49 +0100)]
[InstCombine] Add tests for non-trivial store to load forward (NFC)

Examples of things we mostly don't handle.

3 years ago[MLIR][SPIRV] Rename `spv.selection` to `spv.mlir.selection`.
KareemErgawy-TomTom [Sat, 6 Mar 2021 14:40:14 +0000 (15:40 +0100)]
[MLIR][SPIRV] Rename `spv.selection` to `spv.mlir.selection`.

To unify the naming scheme across all ops in the SPIR-V dialect, we are
moving from spv.camelCase to spv.CamelCase everywhere. For ops that
don't have a SPIR-V spec counterpart, we use spv.mlir.snake_case.

Reviewed By: antiagainst

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

3 years ago[HIP] Support Spack packages
Yaxun (Sam) Liu [Mon, 22 Feb 2021 23:17:20 +0000 (18:17 -0500)]
[HIP] Support Spack packages

Spack is a package management tool extensively used by HPC community.
As ROCm packages are built by Spack by HPC community, we need to teach
clang driver to detect ROCm installation built by Spack.

Reviewed by: Artem Belevich

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

3 years ago[mlir][spirv] Convert tensor.extract for very small tensors
Lei Zhang [Sat, 6 Mar 2021 13:03:27 +0000 (08:03 -0500)]
[mlir][spirv] Convert tensor.extract for very small tensors

Normally tensors will be stored in buffers before converting to SPIR-V,
given that is how a large amount of data is sent to the GPU. However,
SPIR-V supports converting from tensors directly too. This is for the
cases where the tensor just contains a small amount of elements and it
makes sense to directly inline them as a small data array in the shader.
To handle this, internally the conversion might create new local
variables. SPIR-V consumers in GPU drivers may or may not optimize that
away. So this has implications over register pressure. Therefore, a
threshold is used to control when the patterns should kick in.

Reviewed By: ThomasRaoux

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

3 years ago[X86][VARARG] Avoid spilling xmm registers for va_start.
Alexey Lapshin [Sun, 14 Feb 2021 15:34:19 +0000 (18:34 +0300)]
[X86][VARARG] Avoid spilling xmm registers for va_start.

That review is extracted from D69372.
It fixes https://bugs.llvm.org/show_bug.cgi?id=42219 bug.

For the noimplicitfloat mode, the compiler mustn't generate
floating-point code if it was not asked directly to do so.
This rule does not work with variable function arguments currently.
Though compiler correctly guards block of code, which copies xmm vararg
parameters with a check for %al, it does not protect spills for xmm registers.
Thus, such spills are generated in non-protected areas and could break code,
which does not expect floating-point data. The problem happens in -O0
optimization mode. With this optimization level there is used
FastRegisterAllocator, which spills virtual registers at basic block boundaries.
Register Allocator does not protect spills with additional control-flow modifications.
Thus to resolve that problem, it is suggested to not copy incoming physical
registers into virtual registers. Instead, store incoming physical xmm registers
into the memory from scratch.

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

3 years ago[ConstantFold] Handle vectors in ConstantFoldLoadThroughBitcast()
Nikita Popov [Sat, 6 Mar 2021 11:14:48 +0000 (12:14 +0100)]
[ConstantFold] Handle vectors in ConstantFoldLoadThroughBitcast()

There seems to be an impedance mismatch between what the type
system considers an aggregate (structs and arrays) and what
constants consider an aggregate (structs, arrays and vectors).

Rather than adjusting the type check, simply drop it entirely,
as getAggregateElement() is well-defined for non-aggregates: It
simply returns null in that case.

3 years ago[GVN] Regenerate test checks (NFC)
Nikita Popov [Sat, 6 Mar 2021 11:10:52 +0000 (12:10 +0100)]
[GVN] Regenerate test checks (NFC)

3 years agoPartially revert "[runtimes] Use add_lit_testsuite to register lit testsuites"
David Zarzycki [Sat, 6 Mar 2021 11:06:55 +0000 (06:06 -0500)]
Partially revert "[runtimes] Use add_lit_testsuite to register lit testsuites"

This partially reverts commit e1173c8794f4942d2cdddb090489ba5a6cc193e8
until we find out why libcxx tests are failing under runtimes build.

3 years ago[LangRef] dos2unix (NFC)
Juneyoung Lee [Sat, 6 Mar 2021 09:42:17 +0000 (18:42 +0900)]
[LangRef] dos2unix (NFC)

3 years ago[LVI] Simplify and generalize handling of clamp patterns
Nikita Popov [Sat, 6 Mar 2021 09:24:34 +0000 (10:24 +0100)]
[LVI] Simplify and generalize handling of clamp patterns

Instead of handling a number of special cases for selects, handle
this generally when inferring ranges from conditions. We already
infer ranges from `x + C pred C2` to `x`, so doing the same for
`x pred C2` to `x + C` is straightforward.

3 years ago[CVP] Add additional tests for clamp patterns (NFC)
Nikita Popov [Sat, 6 Mar 2021 09:35:30 +0000 (10:35 +0100)]
[CVP] Add additional tests for clamp patterns (NFC)

These are the same as the existing tests, but using different
predicates that are not handled by the current code.

3 years ago[runtimes] Fix crosscompiling after a7cad6680b4087eff8994f1f99ac40c661a6621f (D97451)
Raul Tambre [Wed, 3 Mar 2021 14:25:25 +0000 (16:25 +0200)]
[runtimes] Fix crosscompiling after a7cad6680b4087eff8994f1f99ac40c661a6621f (D97451)

It moved the logic for CMake target arguments into llvm_ExternalProject_Add().
No handling was added for CMAKE_CROSSCOMPILING, which has a separate set of compiler_args.
This broke crosscompiling, as now the runtimes builds defaulted to the compiler's default.

I've also added passing of CMAKE_ASM_COMPILER, which was missing before although we were passing the triple for it.

Reviewed By: zero9178

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

3 years ago[LVI] Pass offset by reference (NFC)
Nikita Popov [Sat, 6 Mar 2021 09:18:07 +0000 (10:18 +0100)]
[LVI] Pass offset by reference (NFC)

Instead of by pointer. This allows us to use offsets that are not
materialized in the IR.

3 years ago[CVP] Fix tests for clamp patterns (NFC)
Nikita Popov [Sat, 6 Mar 2021 09:12:17 +0000 (10:12 +0100)]
[CVP] Fix tests for clamp patterns (NFC)

These tests didn't test the pattern they were supposed to, because
%a instead of %add was used in the select, which turned this into
a normal min/max).

Noticed this when commenting out the clamp handling code did not
result in any test failures...

3 years agoRevert "Revert "[AMDGPU] Restore the s_memtime instruction in gfx1030""
Jay Foad [Sat, 6 Mar 2021 08:52:23 +0000 (08:52 +0000)]
Revert "Revert "[AMDGPU] Restore the s_memtime instruction in gfx1030""

This reverts commit e58d68fcd06ddc7743e0419c0b364df3d44121b6.

This reinstates commit fc28f600e558c1344618bda149a068d6162b6f0b
with a fix to initialize HasShaderCyclesRegister. See
https://reviews.llvm.org/D97928.

3 years ago[clangd] Use URIs instead of paths in the index file list
Aleksandr Platonov [Sat, 6 Mar 2021 07:44:05 +0000 (10:44 +0300)]
[clangd] Use URIs instead of paths in the index file list

Without this patch the file list of the preamble index contains URIs, but other indexes file lists contain file paths.
This makes `indexedFiles()` always returns `IndexContents::None` for the preamble index, because current implementation expects file paths inside the file list of the index.

This patch fixes this problem and also helps to avoid a lot of URI to path conversions during indexes merge.

Reviewed By: kadircet

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

3 years ago[libcxx] [test] Move the is_<platform> functions down to subclasses
Martin Storsjö [Fri, 5 Mar 2021 15:27:55 +0000 (17:27 +0200)]
[libcxx] [test] Move the is_<platform> functions down to subclasses

If cross testing (and manually specifying a LIBCXX_TARGET_INFO in the
cmake configuration, as the default is to match the build platform),
we want the accessors for querying the target platform, is_windows,
is_darwin, to return the right value depending on which target info
class is used, not based on what platform is running the build and
driving the tests.

When LIBCXX_TARGET_INFO isn't defined, the right target info class
is chosen automatically based on the platform one is running on, so
this shouldn't make any practical difference for such setups.

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

3 years ago[clang] Don't default to a specifically shared libunwind on mingw with a g++ driver
Martin Storsjö [Thu, 4 Mar 2021 20:19:47 +0000 (22:19 +0200)]
[clang] Don't default to a specifically shared libunwind on mingw with a g++ driver

For MinGW targets, we distinguish between an explicitly shared unwinder
library (requested via -shared-libgcc), an explicitly static one
(requested via -static-libgcc or -static) and the default case (which
just passes -lunwind to the linker, which will pick either shared or
static depending on what's available, with the normal linker logic).

This makes the implicit default case (as added in D79995) actually work as
it was intended, when using the g++ driver (which is the main usecase for
libunwind as far as I know).

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

3 years ago[clang] Fix typos in the default logic for CLANG_DEFAULT_UNWINDLIB
Martin Storsjö [Thu, 4 Mar 2021 20:33:11 +0000 (22:33 +0200)]
[clang] Fix typos in the default logic for CLANG_DEFAULT_UNWINDLIB

CLANG_DEFAULT_RTLIB had a typo, and libunwind isn't a valid
option for it.

This keeps the actual behaviour from before, defaulting to none if
using compiler-rt as rtlib.

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

3 years ago[MC][RISCV] Support .reloc *, BFD_RELOC_{NONE,32,64}, *
Fangrui Song [Sat, 6 Mar 2021 05:45:11 +0000 (21:45 -0800)]
[MC][RISCV] Support .reloc *, BFD_RELOC_{NONE,32,64}, *

BFD_RELOC_NONE is useful for ld --gc-sections: it provides a generic way indicating a dependency between two sections.

3 years ago[MC][ARM] Support .reloc *, BFD_RELOC_{NONE,8,16,32}, *
Fangrui Song [Sat, 6 Mar 2021 05:39:15 +0000 (21:39 -0800)]
[MC][ARM] Support .reloc *, BFD_RELOC_{NONE,8,16,32}, *

BFD_RELOC_NONE is useful for ld --gc-sections: it provides a generic way indicating a dependency between two sections.

3 years ago[MC][test] Fix reloc-directive-elf-*.s
Fangrui Song [Sat, 6 Mar 2021 05:37:29 +0000 (21:37 -0800)]
[MC][test] Fix reloc-directive-elf-*.s

3 years agoUse gen-dialect-doc instead of gen-op-doc for the Builtin dialect
Mehdi Amini [Sat, 6 Mar 2021 05:31:51 +0000 (05:31 +0000)]
Use gen-dialect-doc instead of gen-op-doc for the Builtin dialect

This is fixing the missing title and menu entry on the MLIR website.

3 years ago[MC][PowerPC] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *
Fangrui Song [Sat, 6 Mar 2021 05:31:45 +0000 (21:31 -0800)]
[MC][PowerPC] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *

BFD_RELOC_NONE is useful for ld --gc-sections: it provides a generic way indicating a dependency between two sections.

3 years ago[MC][AArch64] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *
Fangrui Song [Sat, 6 Mar 2021 05:17:31 +0000 (21:17 -0800)]
[MC][AArch64] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *

BFD_RELOC_NONE is useful for ld --gc-sections: it provides a generic way indicating a dependency between two sections.

3 years ago[MC][X86] Support .reloc *, BFD_RELOC_{NONE,8,16,32,64}, *
Fangrui Song [Sat, 6 Mar 2021 05:01:32 +0000 (21:01 -0800)]
[MC][X86] Support .reloc *, BFD_RELOC_{NONE,8,16,32,64}, *

The names are unfortunate, but BFD_RELOC_NONE provides a generic way indicating
a dependency between two sections, which is useful for ld --gc-sections.
See https://sourceware.org/bugzilla/show_bug.cgi?id=27530

3 years ago[sanitizer] Don't expect ABORTING in print-module-map
Vitaly Buka [Sat, 6 Mar 2021 03:19:00 +0000 (19:19 -0800)]
[sanitizer] Don't expect ABORTING in print-module-map

ABORTING message is inconsistent across sanitizers.

Another followup for D98089

3 years ago[libcxx] adds std::ranges::swap, std::swappable, and std::swappable_with
Christopher Di Bella [Thu, 4 Mar 2021 06:47:06 +0000 (22:47 -0800)]
[libcxx] adds std::ranges::swap, std::swappable, and std::swappable_with

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96742

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

3 years ago[dfsan] Re-enable origin tracking test cases
Jianzhou Zhao [Sat, 6 Mar 2021 02:32:57 +0000 (02:32 +0000)]
[dfsan] Re-enable origin tracking test cases

3 years agoRevert "[AMDGPU] Restore the s_memtime instruction in gfx1030"
Mitch Phillips [Sat, 6 Mar 2021 01:13:33 +0000 (17:13 -0800)]
Revert "[AMDGPU] Restore the s_memtime instruction in gfx1030"

Broke the ASan/MSan buildbots. See more comments in the original patch,
https://reviews.llvm.org/D97928.

Build failure at http://lab.llvm.org:8011/#/builders/5/builds/5327

This reverts commit fc28f600e558c1344618bda149a068d6162b6f0b.

3 years ago[clang] Fix constrained decltype(auto) deduction
Matheus Izvekov [Sat, 6 Mar 2021 01:16:58 +0000 (17:16 -0800)]
[clang] Fix constrained decltype(auto) deduction

Prior to this fix, constrained decltype(auto) behaves exactly the same
as constrained regular auto.
This fixes it so it deduces like decltype(auto).

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

3 years ago[dfsan] Remove dfsan_get_origin from done_abilist.txt
Vitaly Buka [Sat, 6 Mar 2021 01:59:01 +0000 (17:59 -0800)]
[dfsan] Remove dfsan_get_origin from done_abilist.txt

Followup for D95835

3 years ago[DirectoryWatcher] Increase timeout to make test less flaky
Shoaib Meenai [Wed, 3 Mar 2021 19:32:06 +0000 (11:32 -0800)]
[DirectoryWatcher] Increase timeout to make test less flaky

We've observed this test being significantly flaky on our Mac CI
machines when we're running the full check-clang suite. It fails because
the wait_for condition isn't met within 3 seconds. We believe it's
because our CI machines are somewhat underpowered and pretty heavily
loaded when we're running the full check-clang suite.

I ran some experiments on increasing the timeout. I ran the full
check-clang suite 100 times with each timeout value and recorded how
many flaky failures we encountered in these tests. The results are:

3 second timeout (baseline): 20 failures
10 second timeout: 14 failures
20 second timeout: 4 failures
30 second timeout: 2 failures
40 second timeout: 1 failure
50 second timeout: 0 failures
60 second timeout: 0 failures

I ran another set of 100 tests for the 50 second timeout and observed
one flaky failure. By contrast, I ended up running check-clang 500 times
for the 60 second timeout and didn't observe a single flaky failure.
That's how the 60 second timeout value used in this patch was derived.

While a 60 second timeout might seem high, keep in mind that:
- This is a timeout, not a sleep; the test should require much less time
  the vast majority of instances, especially on more powerful machines.
- The long timeout is most likely to occur when other tests are also
  running at the same time, so the latency of the timeout will also be
  masked by the latency of the other tests.

See https://reviews.llvm.org/D58418?id=200123#inline-554211 for where
this timeout was originally introduced and the possibility of raising it
if it wasn't enough was discussed.

Reviewed By: plotfi

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

3 years ago[NFC] Fix module map test
Vitaly Buka [Sat, 6 Mar 2021 01:22:22 +0000 (17:22 -0800)]
[NFC] Fix module map test

Followup for D98089

3 years ago[dfsan] Disable origin test cases temporarily
Jianzhou Zhao [Sat, 6 Mar 2021 01:12:54 +0000 (01:12 +0000)]
[dfsan] Disable origin test cases temporarily

3 years ago[benchmark] Replace references to M680x0 with M68k
Jessica Clarke [Sat, 6 Mar 2021 01:00:22 +0000 (01:00 +0000)]
[benchmark] Replace references to M680x0 with M68k

The former was the old unusual name of the out-of-tree backend but it
was renamed to M68k during the code review process to conform with how
almost everything refers to the Motorola 68000 family of processors.
Thus, update the comments to avoid confusion when the backend lands.

3 years ago[mlir][AVX512] Add mask.compress to AVX512 dialect.
Matthias Springer [Fri, 5 Mar 2021 04:08:05 +0000 (13:08 +0900)]
[mlir][AVX512] Add mask.compress to AVX512 dialect.

Adds mask.compress to the AVX512 dialect and defines a lowering to the LLVM dialect.

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

3 years ago[PowerPC] Add missing double precision vec_all overloads to altivec.h
Nemanja Ivanovic [Sat, 6 Mar 2021 00:24:28 +0000 (18:24 -0600)]
[PowerPC] Add missing double precision vec_all overloads to altivec.h

We somehow missed vec_all_nlt, vec_all_nle and vec_all_numeric
overloads for double precision vectors when VSX is enabled.

3 years ago[sanitizers] fix print-module-map test on linux
Emily Shi [Sat, 6 Mar 2021 00:26:22 +0000 (16:26 -0800)]
[sanitizers] fix print-module-map test on linux

Looks like the default options for halt_on_error are different between linux and mac. set it to 0 in the test so the behavior is the same on both platforms.

rdar://75110847

Reviewed By: delcypher

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

3 years ago[asan][test] Handle Solaris in large_func_test.cpp etc.
Rainer Orth [Sat, 6 Mar 2021 00:28:17 +0000 (01:28 +0100)]
[asan][test] Handle Solaris in large_func_test.cpp etc.

Two ASan tests currently `FAIL' on Solaris

  AddressSanitizer-i386-sunos :: TestCases/large_func_test.cpp
  AddressSanitizer-i386-sunos :: TestCases/use-after-delete.cpp

both for the same reason:

  error: no check strings found with prefix 'CHECK-SunOS:'

Fixed by adding the appropriate check strings.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

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

3 years ago[dfsan] Add utils to get and print origin paths and some test cases
Jianzhou Zhao [Thu, 4 Mar 2021 02:35:13 +0000 (02:35 +0000)]
[dfsan] Add utils to get and print origin paths and some test cases

This is a part of https://reviews.llvm.org/D95835.

Reviewed By: morehouse, gbalats

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

3 years agoPR49260: Improve diagnostics for no matching 'operator new'.
Richard Smith [Fri, 5 Mar 2021 23:50:30 +0000 (15:50 -0800)]
PR49260: Improve diagnostics for no matching 'operator new'.

Fix duplicate diagnostic for an over-aligned allocation with no matching
function, and add custom diagnostic for the case where the
non-allocating placement new was intended but <new> was not included.

3 years agoFix Dialect doc generation to special case for the Builtin dialect empty name
Mehdi Amini [Fri, 5 Mar 2021 21:04:23 +0000 (21:04 +0000)]
Fix Dialect doc generation to special case for the Builtin dialect empty name

This should fix the issue with an empty entry for the builtin dialect on
the website.

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

3 years ago[lld-macho] Move a bunch of options into the "obsolete" category
Jez Ng [Fri, 5 Mar 2021 23:42:22 +0000 (18:42 -0500)]
[lld-macho] Move a bunch of options into the "obsolete" category

These are mostly things that ld64 has itself marked obsolete.
In the case of `-sectorder`, it's suggested in ld64's manpage that it
could be deprecated, so let's skip implementing it for now.

Reviewed By: #lld-macho, thakis

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

3 years ago[sanitizers] run print module map test run on posix
Emily Shi [Fri, 5 Mar 2021 22:39:18 +0000 (14:39 -0800)]
[sanitizers] run print module map test run on posix

Previously, this test only ran for mac because platforms have different messaging. This diff enables the test for all posix

rdar://75110847

Reviewed By: vitalybuka

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

3 years ago[clang][OpenMP][docs] Update loop transformation status.
Michael Kruse [Fri, 5 Mar 2021 23:22:42 +0000 (17:22 -0600)]
[clang][OpenMP][docs] Update loop transformation status.

Mark tiling as done and unrolling as being worked on.

3 years agoPartially revert "[runtimes] Use add_lit_testsuite to register lit testsuites"
Petr Hosek [Fri, 5 Mar 2021 23:24:38 +0000 (15:24 -0800)]
Partially revert "[runtimes] Use add_lit_testsuite to register lit testsuites"

This partially reverts commit e1173c8794f4942d2cdddb090489ba5a6cc193e8
until we find out why compiler-rt tests are failing under runtimes build.

3 years ago[tests] precommit tests for D98082
Philip Reames [Fri, 5 Mar 2021 23:21:23 +0000 (15:21 -0800)]
[tests] precommit tests for D98082

3 years ago[libcxx] [test] Fix detection of clang-cl when cross compiling
Martin Storsjö [Sun, 2 Feb 2020 21:22:49 +0000 (23:22 +0200)]
[libcxx] [test] Fix detection of clang-cl when cross compiling

When cross compiling, the compiler tool doesn't have a .exe suffix.

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

3 years ago[Fuchsia] Enable Polly for first stage as well
Petr Hosek [Fri, 5 Mar 2021 09:23:39 +0000 (01:23 -0800)]
[Fuchsia] Enable Polly for first stage as well

We want Polly enabled for both stages of the toolchain build.

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

3 years ago[lld-macho] Check platform and version when constructor ObjFile
Vy Nguyen [Thu, 4 Mar 2021 21:58:21 +0000 (16:58 -0500)]
[lld-macho] Check platform and version when constructor ObjFile

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

3 years ago[mlir] Squash LLVM_ArmNeon dialect into ArmNeon
Alex Zinenko [Fri, 5 Mar 2021 18:19:06 +0000 (19:19 +0100)]
[mlir] Squash LLVM_ArmNeon dialect into ArmNeon

The two dialects are largely redundant. The former was introduced as a mirror
of the latter operating on LLVM dialect types. This is no longer necessary
since the LLVM dialect operates on built-in types. Combine the two dialects.

Reviewed By: mehdi_amini

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

3 years ago[lld-macho] Skip over symbols in un-parsed debug info sections
Jez Ng [Fri, 5 Mar 2021 22:22:57 +0000 (17:22 -0500)]
[lld-macho] Skip over symbols in un-parsed debug info sections

clang appears to emit symbols in `__debug_aranges`, at least
for arm64... in the examples I've seen, it doesn't seem like those
symbols are referenced outside of `__DWARF`, so I think they're safe to
ignore. But hopefully @clayborg can confirm.

Reviewed By: clayborg

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

3 years ago[lld-macho] Replace debug-info-related assert with FIXME
Jez Ng [Fri, 5 Mar 2021 22:22:56 +0000 (17:22 -0500)]
[lld-macho] Replace debug-info-related assert with FIXME

We'll need to properly handle object files with multiple source inputs
eventually, but remove the assert for now so we can successfully emit binaries
for testing.

Reviewed By: #lld-macho, smeenai

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

3 years ago[tests] precommit tests for phi handling in GVN
Philip Reames [Fri, 5 Mar 2021 22:24:08 +0000 (14:24 -0800)]
[tests] precommit tests for phi handling in GVN

3 years ago[mlir][vector] canonicalize unmasked gather/scatter/compress/expand directly into l/s
Aart Bik [Fri, 5 Mar 2021 17:32:15 +0000 (09:32 -0800)]
[mlir][vector] canonicalize unmasked gather/scatter/compress/expand directly into l/s

With the new vector.load/store operations, there is no need to go through
unmasked transfer operations (which will canonicalized to l/s anyway).

Reviewed By: dcaballe

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

3 years ago[mlir] Add 'Skip' result to Operation visitor
Diego Caballero [Fri, 5 Mar 2021 21:47:36 +0000 (23:47 +0200)]
[mlir] Add 'Skip' result to Operation visitor

This patch is a follow-up on D97217. It adds a new 'Skip' result to the Operation visitor
so that a callback can stop the ongoing visit of an operation/block/region and
continue visiting the next one without fully interrupting the walk. Skipping is
needed to be able to erase an operation/block in pre-order and do not continue
visiting the internals of that operation/block.

Related to the skipping mechanism, the patch also introduces the following changes:
 * Added new TestIRVisitors pass with basic testing for the IR visitors.
 * Fixed missing early increment ranges in visitor implementation.
 * Updated documentation of walk methods to include erasure information and walk
   order information.

Reviewed By: rriddle

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

3 years ago[mlir] Extend Operation visitor with pre-order traversal
Diego Caballero [Fri, 5 Mar 2021 21:46:56 +0000 (23:46 +0200)]
[mlir] Extend Operation visitor with pre-order traversal

This patch extends the Region, Block and Operation visitors to also support pre-order walks.
We introduce a new template argument that dictates the walk order (only pre-order and
post-order are supported for now). The default order for Regions, Blocks and Operations is
post-order. Mixed orders (e.g., Region/Block pre-order + Operation post-order) could easily
be implemented, as shown in NumberOfExecutions.cpp.

Reviewed By: rriddle, frgossen, bondhugula

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