platform/upstream/llvm.git
2 years ago[clangd] Avoid "expected one compiler job" by picking the first eligible job.
Sam McCall [Fri, 6 Aug 2021 10:07:13 +0000 (12:07 +0200)]
[clangd] Avoid "expected one compiler job" by picking the first eligible job.

This happens in createInvocationWithCommandLine but only clangd currently passes
ShouldRecoverOnErorrs (sic).

One cause of this (with correct command) is several -arch arguments for mac
multi-arch support.

Fixes https://github.com/clangd/clangd/issues/827

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

2 years agoclangd: Make documentation property of completion items more similar
Christian Kandeler [Thu, 12 Aug 2021 22:15:03 +0000 (00:15 +0200)]
clangd: Make documentation property of completion items more similar

... to the one of signature hints.
In particular, completion items now also carry annotations, which client
code might be interested in.

Reviewed By: sammccall

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

2 years agoFrontend: Refactor compileModuleAndReadAST, NFC
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 02:16:51 +0000 (18:16 -0800)]
Frontend: Refactor compileModuleAndReadAST, NFC

This renames `compileModuleAndReadAST`, adding a `BehindLock` suffix,
and refactors it to significantly reduce nesting.

- Split out helpers `compileModuleAndReadASTImpl` and
  `readASTAfterCompileModule` which have straight-line code that doesn't
  worry about locks.
- Use `break` in the interesting cases of `switch` statements to reduce
  nesting.
- Use early `return`s to reduce nesting.

Detangling the compile-and-read logic from the check-for-locks logic
should be a net win for readability, although I also have a side
motivation of making the locks optional in a follow-up.

No functionality change here.

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

2 years agoclangd: Provide hover info for include directives
Christian Kandeler [Thu, 12 Aug 2021 22:04:19 +0000 (00:04 +0200)]
clangd: Provide hover info for include directives

It's quite useful to be able to hover over an #include and see the full
path to the header file.

Reviewed By: sammccall

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

2 years ago[CodeComplete] Basic code completion for attribute names.
Sam McCall [Sat, 7 Aug 2021 15:36:26 +0000 (17:36 +0200)]
[CodeComplete] Basic code completion for attribute names.

Only the bare name is completed, with no args.
For args to be useful we need arg names. These *are* in the tablegen but
not currently emitted in usable form, so left this as future work.

C++11, C2x, GNU, declspec, MS syntax is supported, with the appropriate
spellings of attributes suggested.
`#pragma clang attribute` is supported but not terribly useful as we
only reach completion if parens are balanced (i.e. the line is not truncated)

There's no filtering of which attributes might make sense in this
grammatical context (e.g. attached to a function). In code-completion context
this is hard to do, and will only work in few cases :-(

There's also no filtering by langopts: this is because currently the
only way of checking is to try to produce diagnostics, which requires a
valid ParsedAttr which is hard to get.
This should be fairly simple to fix but requires some tablegen changes
to expose the logic without the side-effect.

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

2 years ago[Attributes]: refactor to expose ParsedAttrInfo::acceptsLangOpts. NFC
Sam McCall [Tue, 10 Aug 2021 15:56:32 +0000 (17:56 +0200)]
[Attributes]: refactor to expose ParsedAttrInfo::acceptsLangOpts. NFC

We will use this function to filter code completion of attributes.

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

2 years ago[clangd] Overload bundles are only deprecated if each overloads is.
Sam McCall [Tue, 2 Mar 2021 21:26:29 +0000 (22:26 +0100)]
[clangd] Overload bundles are only deprecated if each overloads is.

Fixes https://github.com/clangd/clangd/issues/705

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

2 years agoSymbolicate aarch64 adrp+add pc-relative addr in disass
Jason Molenda [Thu, 12 Aug 2021 21:29:30 +0000 (14:29 -0700)]
Symbolicate aarch64 adrp+add pc-relative addr in disass

On aarch64 a two instruction sequence is used to calculate a
pc-relative address, add some state to the DisassemblerLLVMC
symbolicator so it can track the necessary data across the
two instructions and compute the address being calculated.

Differential Revision: https://reviews.llvm.org/D107213
rdar://49119253

2 years ago[PowerPC] Implement XL compatibility builtin __addex
Lei Huang [Wed, 28 Jul 2021 20:34:17 +0000 (15:34 -0500)]
[PowerPC] Implement XL compatibility builtin __addex

Add builtin and intrinsic for `__addex`.

This patch is part of a series of patches to provide builtins for
compatibility with the XL compiler.

Reviewed By: stefanp, nemanjai, NeHuang

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

2 years ago[libc][nfc] add CPP Limits.h for numeric_limits
Michael Jones [Thu, 12 Aug 2021 18:29:58 +0000 (18:29 +0000)]
[libc][nfc] add CPP Limits.h for numeric_limits

Add an implementation of numeric_limits for use in str_conv_utils.
It currently only supports the basic integer types, with more types
coming as needed.

Reviewed By: sivachandra

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

2 years ago[mlir-tblgen] Minor Refactor for StaticVerifierFunctionEmitter.
Chia-hung Duan [Thu, 12 Aug 2021 17:35:00 +0000 (17:35 +0000)]
[mlir-tblgen] Minor Refactor for StaticVerifierFunctionEmitter.

Move StaticVerifierFunctionEmitter to CodeGenHelper.h so that it can be
used for both ODS and DRR.

Reviewed By: jpienaar

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

2 years ago[openmp][ELF] Recognize LLVM OpenMP offload specific notes
Vyacheslav Zakharin [Thu, 12 Aug 2021 18:14:41 +0000 (11:14 -0700)]
[openmp][ELF] Recognize LLVM OpenMP offload specific notes

The new ELF notes are added in clang-offload-wrapper, and llvm-readobj has to visualize them properly.

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

2 years ago[WebAssembly] Disable offset folding for function addresses
Heejin Ahn [Thu, 12 Aug 2021 01:18:13 +0000 (18:18 -0700)]
[WebAssembly] Disable offset folding for function addresses

Wasm does not support function addresses with offsets, but isel can
generate folded SDValues in the form of (@func + offset) without this
patch.

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

Reviewed By: dschuff, sbc100

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

2 years ago[clang/test] Run thinlto-clang-diagnostic-handler-in-be.c on x86
Thomas Preud'homme [Fri, 6 Aug 2021 20:53:19 +0000 (21:53 +0100)]
[clang/test] Run thinlto-clang-diagnostic-handler-in-be.c on x86

Clang test CodeGen/thinlto-clang-diagnostic-handler-in-be.c fails on
some non x86 targets, e.g. hexagon. Since the test already requires x86
to be available as a target this commit forces the target to x86_64.

Reviewed By: steven_wu

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

2 years ago[InstCombine] factorize min/max intrinsic ops with common operand (2nd try)
Sanjay Patel [Thu, 12 Aug 2021 20:18:13 +0000 (16:18 -0400)]
[InstCombine] factorize min/max intrinsic ops with common operand (2nd try)

This is a re-try of 6de1dbbd09c1 which was reverted because
it missed a null check. Extra test for that failure added.

Original commit message:
This is an adaptation of D41603 and another step on the way
to canonicalizing to the intrinsic forms of min/max.

See D98152 for status.

2 years ago[flang] Correct off-by-one error in SET_EXPONENT
peter klausler [Thu, 12 Aug 2021 18:10:53 +0000 (11:10 -0700)]
[flang] Correct off-by-one error in SET_EXPONENT

SET_EXPONENT is returning values that are too large by a factor
of two.

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

2 years ago[RISCV] Improve check prefixes in B extension tests. NFC
Craig Topper [Thu, 12 Aug 2021 19:33:54 +0000 (12:33 -0700)]
[RISCV] Improve check prefixes in B extension tests. NFC

-Add Z for the B extension subextensions.
-Don't mention I along with B or its sub extensions.

This is based on comments in D107817.

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

2 years agoRevert "[InstCombine] factorize min/max intrinsic ops with common operand"
Amy Huang [Thu, 12 Aug 2021 19:34:14 +0000 (12:34 -0700)]
Revert "[InstCombine] factorize min/max intrinsic ops with common operand"

This reverts commit 6de1dbbd09c12abbec7eb187ffa1afbd47302dfa because it causes a
compiler crash.

2 years ago[flang] Disable Plugins in out-of-tree builds
Andrzej Warzynski [Thu, 12 Aug 2021 16:11:54 +0000 (16:11 +0000)]
[flang] Disable Plugins in out-of-tree builds

https://reviews.llvm.org/D106137 added support for plugins in Flang. The
CMake configuration for plugins requires some LLVM variables that are
not available in out-of-tree builds (e.g. `LLVM_SHLIB_OUTPUT_INTDIR`).
This has caused the out-of-tree BuildBot worker to start failing:
  * https://lab.llvm.org/buildbot/#/builders/175

This patch effectively disables plugins in out-of-tree builds and fixes
the configuration error. In order to support plugins in out-of-tree
builds, we would have to find a way to access the missing CMake
variables from LLVM. This could be implemented at a later time.

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

2 years ago[AST][clangd] Expose documentation of Attrs on hover.
Sam McCall [Sat, 7 Aug 2021 22:41:40 +0000 (00:41 +0200)]
[AST][clangd] Expose documentation of Attrs on hover.

This adds a method to Attr to get at the documentation programmatically.

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

2 years ago[unwind] Handle UNW_X86_64_RIP register
Vitaly Buka [Wed, 11 Aug 2021 17:35:23 +0000 (10:35 -0700)]
[unwind] Handle UNW_X86_64_RIP register

In some binaries, built with clang/lld, libunwind crashes
with "unsupported x86_64 register" for regNum == 16:

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

2 years ago[Polly] Fix compiler warnings. NFC.
Michael Kruse [Thu, 12 Aug 2021 18:34:02 +0000 (13:34 -0500)]
[Polly] Fix compiler warnings. NFC.

2 years ago[llvm-diff] correct variable typo
Bill Wendling [Thu, 12 Aug 2021 18:29:48 +0000 (11:29 -0700)]
[llvm-diff] correct variable typo

2 years ago[llvm-diff] add "reset" method to DiffConsumer
Bill Wendling [Thu, 12 Aug 2021 18:23:57 +0000 (11:23 -0700)]
[llvm-diff] add "reset" method to DiffConsumer

A DiffConsumer object may be reused, but we'd like to reset it before
the next use.

No functionality change intended.

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

2 years ago[mlir][sparse][python] add an "exhaustive" sparse test using python
Aart Bik [Thu, 12 Aug 2021 01:23:10 +0000 (18:23 -0700)]
[mlir][sparse][python] add an "exhaustive" sparse test using python

Using the python API to easily set up sparse kernels, this test
exhaustively builds, compilers, and runs SpMM for all annotations
on a sparse tensor, making sure every version generates the correct
result. This test also illustrates using the python API to set up
a sparse kernel and sparse compilation.

Reviewed By: bixia

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

2 years ago[NFC] Enumerate LLVMOMPOFFLOAD note types.
Vyacheslav Zakharin [Thu, 12 Aug 2021 18:01:41 +0000 (11:01 -0700)]
[NFC] Enumerate LLVMOMPOFFLOAD note types.

It is a NFC to enumerate types of LLVMOMPOFFLOAD ELF notes.

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

2 years ago[Flang] Fix error messages on Windows.
Ivan Zhechev [Thu, 12 Aug 2021 17:04:29 +0000 (18:04 +0100)]
[Flang] Fix error messages on Windows.

Flang uses positional arguments for `messages::say()`, such as "%1$s" which is only supported in MS Compilers with the `_*printf_p` form of the function. This uses a conditional macro to convert the existing `vsnprintf` used to the one needed in MS-World.

7 tests in D107575 rely on this change.

Reviewed By: Meinersbur

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

2 years agoRecommit "[Matrix] Overload stride arg in matrix.columnwise.load/store."
Florian Hahn [Thu, 12 Aug 2021 12:21:35 +0000 (13:21 +0100)]
Recommit "[Matrix] Overload stride arg in matrix.columnwise.load/store."

This reverts the revert 28c04794df74ad3c38155a244729d1f8d57b9400.

The failing MLIR test that caused the revert should be fixed  in this
version.

Also includes a PPC test fix previously in 1f87c7c478a6.

2 years ago[libc++] Remove Lit annotations for unsupported GCC versions from the test suite
Louis Dionne [Mon, 9 Aug 2021 22:08:39 +0000 (18:08 -0400)]
[libc++] Remove Lit annotations for unsupported GCC versions from the test suite

Since we officially don't support several older compilers now, we can
drop a lot of the markup in the test suite. This helps keep the test
suite simple and makes sure that UNSUPPORTED annotations don't rot.

This is the first patch of a series that will remove annotations for
compilers that are now unsupported.

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

2 years ago[gn build] Port 4ac87e33785e
LLVM GN Syncbot [Thu, 12 Aug 2021 17:16:05 +0000 (17:16 +0000)]
[gn build] Port 4ac87e33785e

2 years ago[Flang] Fix build failure on MacOS
Kiran Chandramohan [Thu, 12 Aug 2021 16:42:29 +0000 (17:42 +0100)]
[Flang] Fix build failure on MacOS

std::clock_t can be an unsigned value on some platforms like MacOS and
therefore needs a cast when initializing an std::clock_t value with -1.

Reviewed By: klausler

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

2 years ago[RISCV] Add test cases showing inefficient materialization for stores of immediates...
Craig Topper [Thu, 12 Aug 2021 17:08:07 +0000 (10:08 -0700)]
[RISCV] Add test cases showing inefficient materialization for stores of immediates. NFC

DAGCombiner::visitStore can call GetDemandedBits which will remove
upper bits from immediates. The upper bits are important for good
materialization of negative constants on RISCV. GetDemandedBits is a
different mechanism than SimplifyDemandedBits so
TargetShrinkDemandedConstant can't block it.

As far as I know this behavior is unique to stores.

I think we can fix this in isel using a concept similar to D107658.

Reviewed By: frasercrmck

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

2 years ago[libcxx][ranges] Add `unreachable_sentinel`.
zoecarver [Wed, 11 Aug 2021 18:16:27 +0000 (11:16 -0700)]
[libcxx][ranges] Add `unreachable_sentinel`.

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

2 years ago[RISCV] Teach vsetvli insertion pass that it doesn't need to insert vsetvli for unit...
Craig Topper [Thu, 12 Aug 2021 16:39:55 +0000 (09:39 -0700)]
[RISCV] Teach vsetvli insertion pass that it doesn't need to insert vsetvli for unit-stride or strided loads/stores in some cases.

For unit-stride and strided load/stores we set the SEW operand of
the pseudo instruction equal the EEW in the opcode. The LMUL
of the pseudo instruction is the LMUL we want.

These instructions calculate EMUL=(EEW/SEW) * LMUL. We can use
this to avoid changing vtype if the SEW/LMUL of the previous
vtype matches the EEW/EMUL ratio we need for the instruction.

Due to how the global analysis works, we can only do this
optimization when the previous vsetvli was produced in the block
containing the store. We need to know in the first phase if the
vsetvli will be inserted so we can propagate information to
the successors in the second phase correctly. This means we can't
depend on predecessors.

Reviewed By: rogfer01

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

2 years ago[Sema] Fix -Wparentheses warning from gcc. NFC
Craig Topper [Thu, 12 Aug 2021 16:03:41 +0000 (09:03 -0700)]
[Sema] Fix -Wparentheses warning from gcc. NFC

2 years ago[RISCV] Use getNaturalPointeeTypeAlignment to get alignment for stores created for...
Craig Topper [Thu, 12 Aug 2021 15:52:20 +0000 (08:52 -0700)]
[RISCV] Use getNaturalPointeeTypeAlignment to get alignment for stores created for vector builtins.

Instead of using scalar size divided by 8 for segment loads, get
the alignment from clang's type system.

Make vleff match for consistency.

Also replace uses of getPointerElementType() which will be removed as part of the OpaquePtr changes.

Reviewed By: HsiangKai

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

2 years ago[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological
Roman Lebedev [Thu, 12 Aug 2021 17:02:48 +0000 (20:02 +0300)]
[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological

We really shouldn't deal with a conditional branch that can be trivially
constant-folded into an unconditional branch.

Indeed, barring failure to trigger BB reprocessing, that should be true,
so let's assert as much, and hope the assertion never fires.
If it does, we have a bug to fix.

2 years ago[SimplifyCFG] If FoldTwoEntryPHINode() changed things, restart
Roman Lebedev [Thu, 12 Aug 2021 16:45:11 +0000 (19:45 +0300)]
[SimplifyCFG] If FoldTwoEntryPHINode() changed things, restart

Mainly, i want to add an assertion that `SimplifyCFGOpt::simplifyCondBranch()`
doesn't get asked to deal with non-unconditional branches,
and if i do that, then said assertion fires on existing tests,
and this is what prevents it from firing.

2 years ago[DWARF] Remove getMaxLineIncrementForSpecialOpcode (NFC)
Kazu Hirata [Thu, 12 Aug 2021 16:53:49 +0000 (09:53 -0700)]
[DWARF] Remove getMaxLineIncrementForSpecialOpcode (NFC)

The function was introduced without a use on Sep 16, 2011 in
commit 5acab501de113acb4c0d28b48e76c27631ba0904.

2 years agoRevert "[openmp] Annotate tmp variables with omp_thread_mem_alloc"
Jon Chesterfield [Thu, 12 Aug 2021 16:44:36 +0000 (17:44 +0100)]
Revert "[openmp] Annotate tmp variables with omp_thread_mem_alloc"

This reverts commit b6113548c9217fb8a6d0e9ac5bef5584c1aa614d.

2 years ago[InstCombine] fold umax/umin intrinsics based on demanded bits
Sanjay Patel [Thu, 12 Aug 2021 16:35:39 +0000 (12:35 -0400)]
[InstCombine] fold umax/umin intrinsics based on demanded bits

This is a direct translation of the select folds added with
D53033 / D53036 and another step towards canonicalization
using the intrinsics (see D98152).

2 years ago[InstCombine] add test for umax/umin intrinsic demanded bits; NFC
Sanjay Patel [Thu, 12 Aug 2021 16:18:21 +0000 (12:18 -0400)]
[InstCombine] add test for umax/umin intrinsic demanded bits; NFC

2 years ago[flang] Fix crash in runtime-type-info.cpp
peter klausler [Tue, 10 Aug 2021 19:16:40 +0000 (12:16 -0700)]
[flang] Fix crash in runtime-type-info.cpp

Recent work in runtime assignments failed an assertion in fir-dev
while running tests (flang/test/Semantics/defined-ops.f90).  This
test didn't fail in llvm-project/main because only the "new" Arm
driver is used now, and that only builds runtime derived type information
tables when some debug dumping options are enabled.

So add a reproducing test case to another test that is run with
-fdebug-dump-symbols, and fix the crash by emitting special procedure
binding information only for type-bound generic ASSIGNMENT(=) bindings
that are relevant to the runtime support library for use in intrinsic
assignment of derived types.

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

2 years ago[crt][test] Make ctor_dtor.c robust if DT_INIT/DT_FINI is disabled
Fangrui Song [Thu, 12 Aug 2021 16:31:31 +0000 (09:31 -0700)]
[crt][test] Make ctor_dtor.c robust if DT_INIT/DT_FINI is disabled

New ports in glibc typically don't define ELF_INITFINI, so
DT_INIT/DT_FINI support is disabled.
(rhel ppc64le likely patches their glibc this way as well.)
musl can disable DT_INIT/DT_FINI via -DNO_LEGACY_INITFINI.

So we cannot guarantee ctor()/dtor() will be printed.

2 years ago[openmp] Annotate tmp variables with omp_thread_mem_alloc
Jon Chesterfield [Thu, 12 Aug 2021 16:30:22 +0000 (17:30 +0100)]
[openmp] Annotate tmp variables with omp_thread_mem_alloc

Fixes miscompile of calls into ocml. Bug 51445.

The stack variable `double __tmp` is moved to dynamically allocated shared
memory by CGOpenMPRuntimeGPU. This is usually fine, but when the variable
is passed to a function that is explicitly annotated address_space(5) then
allocating the variable off-stack leads to a miscompile in the back end,
which cannot decide to move the variable back to the stack from shared.

This could be fixed by removing the AS(5) annotation from the math library
or by explicitly marking the variables as thread_mem_alloc. The cast to
AS(5) is still a no-op once IR is reached.

Reviewed By: jdoerfert

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

2 years ago[LICM] Support sinking in LNICM
maekawatoshiki [Thu, 12 Aug 2021 15:53:03 +0000 (00:53 +0900)]
[LICM] Support sinking in LNICM

Currently, LNICM pass does not support sinking instructions out of loop nest.
This patch enables LNICM to sink down as many instructions to the exit block of outermost loop as possible.

Reviewed By: Whitney

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

2 years agoSpeculatively fix the build bots.
Aaron Ballman [Thu, 12 Aug 2021 15:55:32 +0000 (11:55 -0400)]
Speculatively fix the build bots.

This is a fix for commit d2c5cbc3a856c2f8bbda05540fa761bb94ba32f6

2 years ago[CSSPGO] Allow the use of debug-info-for-profiling and pseudo-probe-for-profiling...
Hongtao Yu [Wed, 11 Aug 2021 01:19:21 +0000 (18:19 -0700)]
[CSSPGO] Allow the use of debug-info-for-profiling and pseudo-probe-for-profiling together

Previoulsy debug-info-for-profiling and pseudo-probe-for-profiling are mutual exclusive because they compete the dwarf discrimnator for callsites on the IR. This changes allows to use the two switches together. The side effect is that callsite discriminators will be taken by pseudo probe, while discriminators for other instructions are still available for AutoFDO use. This is less than ideal, however, it still allows us a chance to smoothly transition from AutoFDO to CSSPGO, by collecting both profiles from a CSSPGO binary.

Reviewed By: wenlei, wmi

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

2 years ago[InstCombine] remove unused function argument; NFC
Sanjay Patel [Thu, 12 Aug 2021 15:46:11 +0000 (11:46 -0400)]
[InstCombine] remove unused function argument; NFC

This was just added with 6de1dbbd09c1 , and I missed
pulling the extra arg from the final revision.

2 years ago[Attributor][FIX] Do not try to rewrite functions with casted call sites
Johannes Doerfert [Thu, 12 Aug 2021 15:10:27 +0000 (10:10 -0500)]
[Attributor][FIX] Do not try to rewrite functions with casted call sites

If we cast a function at the call site it is hard(er) to get the rewrite
correct, let's not attempt it for now.

Fixes PR51448.

2 years ago[Attributor][FIX] Guard constant casts with type size checks
Johannes Doerfert [Thu, 12 Aug 2021 14:52:24 +0000 (09:52 -0500)]
[Attributor][FIX] Guard constant casts with type size checks

2 years ago[Attributor] Do not delete volatile stores to null/undef
Johannes Doerfert [Wed, 11 Aug 2021 14:48:46 +0000 (09:48 -0500)]
[Attributor] Do not delete volatile stores to null/undef

See D106309.

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

2 years ago[ARM] Fix DAG combine loop in reduction distribution
David Green [Thu, 12 Aug 2021 15:37:39 +0000 (16:37 +0100)]
[ARM] Fix DAG combine loop in reduction distribution

Given a constant operand, the MVE and DAGCombine combines could fight,
each redistributing in the opposite order. Add a guard to the MVE
vecreduce distribution to prevent that.

2 years ago[gn build] Port d2c5cbc3a856
LLVM GN Syncbot [Thu, 12 Aug 2021 15:33:09 +0000 (15:33 +0000)]
[gn build] Port d2c5cbc3a856

2 years agoAdd a check for enforcing minimum length for variable names
Florin Iucha [Thu, 12 Aug 2021 15:31:26 +0000 (11:31 -0400)]
Add a check for enforcing minimum length for variable names

Add a check for enforcing minimum length for variable names. A default
minimum length of three characters is applied to regular variables
(including function parameters). Loop counters and exception variables
have a minimum of two characters. Additionally, the 'i', 'j' and 'k'
are accepted as legacy values.

All three sizes, as well as the list of accepted legacy loop counter
names are configurable.

2 years ago[InstCombine] remove shl(neg x), y transform
Sanjay Patel [Thu, 12 Aug 2021 15:27:22 +0000 (11:27 -0400)]
[InstCombine] remove shl(neg x), y transform

This diff was accidentally committed with:
1b5a195845e1

2 years ago[InstCombine] factorize min/max intrinsic ops with common operand
Sanjay Patel [Thu, 12 Aug 2021 12:34:30 +0000 (08:34 -0400)]
[InstCombine] factorize min/max intrinsic ops with common operand

This is an adaptation of D41603 and another step on the way
to canonicalizing to the intrinsic forms of min/max.

See D98152 for status.

2 years ago[InstCombine] add tests for factorization of min/max intrinsics; NFC
Sanjay Patel [Thu, 12 Aug 2021 11:07:43 +0000 (07:07 -0400)]
[InstCombine] add tests for factorization of min/max intrinsics; NFC

2 years ago[PowerPC] Fix return address computation for "__builtin_return_address"
Victor Huang [Thu, 12 Aug 2021 13:03:21 +0000 (08:03 -0500)]
[PowerPC] Fix return address computation for "__builtin_return_address"

When depth > 0, callee frame address is used to compute the return address of
callee producing improper return address. This patch adds the fix to use caller
frame address to compute the return address of callee.

Reviewed By: nemanjai, #powerpc

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

2 years ago[llvm][Inline] Refactor out InlineOrder
Liqiang Tao [Thu, 12 Aug 2021 14:19:45 +0000 (22:19 +0800)]
[llvm][Inline] Refactor out InlineOrder

Move InlineOrder to separated file.

Reviewed By: kazu

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

2 years ago[OpenCL] Tidy up preserve_vec3 test
Sven van Haastregt [Thu, 12 Aug 2021 13:51:20 +0000 (14:51 +0100)]
[OpenCL] Tidy up preserve_vec3 test

Add CHECK-LABELs and fix string substitution to actually match the
previous definition.

2 years ago[Polly] Simplify domains before gist.
Michael Kruse [Thu, 12 Aug 2021 11:11:58 +0000 (06:11 -0500)]
[Polly] Simplify domains before gist.

The compilation of the file
526.blender_r/src/blender/source/blender/editors/space_logic/logic_ops.c
from the SPEC CPU 2017 benchmarks took excessive time to compute

    InvalidDomain.gist_params(Ctx)

Simplifying beforehand, specifically using isl_set_detect_equalities,
reduces the computation time to a negible level again.

2 years agotsan: remove implicit memcpy in MutexSet::Desc::operator=()
Dmitry Vyukov [Thu, 12 Aug 2021 12:47:47 +0000 (14:47 +0200)]
tsan: remove implicit memcpy in MutexSet::Desc::operator=()

The default compiler-generated MutexSet::Desc::operator=()
now contains memcpy() call since Desc become bigger.
This fails in debug mode since we call interceptor from within the runtime.
Define own operator=() using internal_memcpy().
This also makes copy ctor necessary, otherwise:
tsan_mutexset.h:33:11: warning: definition of implicit copy constructor for
'Desc' is deprecated because it has a user-declared copy assignment operator
And if we add copy ctor, we also need the default ctor
since it's called by MutexSet ctor.

Depends on D107911.

Reviewed By: melver

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

2 years agoRevert "[Matrix] Update column.major.load call in PPC test."
Florian Hahn [Thu, 12 Aug 2021 12:13:52 +0000 (13:13 +0100)]
Revert "[Matrix] Update column.major.load call in PPC test."

Dependent commit a1ef81de35a4 has been reverted in a1ef81de35a4.

2 years agoRevert "[Matrix] Overload stride arg in matrix.columnwise.load/store."
Mehdi Amini [Thu, 12 Aug 2021 11:57:19 +0000 (11:57 +0000)]
Revert "[Matrix] Overload stride arg in matrix.columnwise.load/store."

This reverts commit a1ef81de35a4bac6d3b22e9d7186d880124d7a55.

Broke the MLIR buildbot.

2 years ago[Test] Move test for PR50555 from InstCombine to AggressiveInstCombine
Anton Afanasyev [Thu, 12 Aug 2021 11:40:27 +0000 (14:40 +0300)]
[Test] Move test for PR50555 from InstCombine to AggressiveInstCombine

2 years agotsan: extend MutexSet to memorize mutex address/stack_id
Dmitry Vyukov [Tue, 10 Aug 2021 18:19:58 +0000 (20:19 +0200)]
tsan: extend MutexSet to memorize mutex address/stack_id

We currently memorize u64 id + epoch for each mutex.
The new tsan runtime will memorize address + stack_id instead.
But switching to address + stack_id requires new trace,
which in turn requires new MutexSet and some other changes.
Extend MutexSet to support both new and old info to break
the dependency cycles. The plan is to remove the old
info/methods after switching to the new runtime.

Reviewed By: vitalybuka, melver

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

2 years ago[flang][driver] Add support for Frontend Plugins
Stuart Ellis [Thu, 12 Aug 2021 10:42:08 +0000 (11:42 +0100)]
[flang][driver] Add support for Frontend Plugins

Introducing a plugin API and a simple HelloWorld Plugin example.
This patch adds the `-load` and `-plugin` flags to frontend driver and
the code around using custom frontend actions from within a plugin
shared library object.

It also adds to the Driver-help test to check the help option with the
updated driver flags.

Additionally, the patch creates a plugin-example test to check the
HelloWorld plugin example runs correctly. As part of this, a new CMake
flag (`FLANG_BUILD_EXAMPLES`) is added to allow the example to be built
and for the test to run.

This Plugin API has only been tested on Linux.

Reviewed By: awarzynski

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

2 years ago[llvm][sve] Fix erroneous tests for fixed length extending loads
David Truby [Thu, 12 Aug 2021 10:29:12 +0000 (10:29 +0000)]
[llvm][sve] Fix erroneous tests for fixed length extending loads

2 years ago[clang] [MinGW] Consider the per-target libc++ include directory too
Martin Storsjö [Wed, 11 Aug 2021 10:53:43 +0000 (13:53 +0300)]
[clang] [MinGW] Consider the per-target libc++ include directory too

The existing logic for per-target libc++ include directories only
seem to exist for the Gnu and Fuchsia drivers, added in
ea12d779bc238c387511fe7462020f4ecf4a8246 / D89013.

This is less generic than the corresponding case in the Gnu driver,
but matches the existing level of genericity in the MinGW driver
(and others too).

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

2 years ago[CMake] Make the vendor part of default mingw triples consistent
Martin Storsjö [Wed, 11 Aug 2021 11:06:28 +0000 (14:06 +0300)]
[CMake] Make the vendor part of default mingw triples consistent

Consistently use 'w64' as vendor string; it was 'pc' for the original
i686 triple added in 91bd6c922d7cf, but the later x86_64 triple
used 'w64' as vendor, added in d6c1f37f86440.

When the arm triples were added in c84ad73a27da6, the differing
vendors were copied over accidentally to the arm targets too.

When using per-target runtime directories, having inconsistent vendor
parts of the target triples is fatal.

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

2 years ago[LLD] [MinGW] Add more options for disabling flags in the executable
Martin Storsjö [Wed, 11 Aug 2021 20:41:24 +0000 (23:41 +0300)]
[LLD] [MinGW] Add more options for disabling flags in the executable

In e72403f96de7f1c681acd5968f72aa986412dfce, we added the flag
"--no-dynamicbase" for disabling the dynamicbase flag which we set
by default. At the time, ld.bfd didn't have any corresponding
option (as ld.bfd defaulted to not setting the flag). Almost at
the same time, corresponding options were added to ld.bfd for
disabling it (while it was being enabled by default), with a
different name, "--disable-dynamicbase".

Thus add the "--disable-dynamicbase" option. Make this default
one advertised in the help listing, but keep the "--no-dynamicbase"
form as an alias. Also improve checking for the last option set
if there are multiple ones on the same command line.

Also add corresponding disable options for a lot of other flags
that we set by default, also added in ld.bfd in the same commit:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=514b4e191d5f46de8e142fe216e677a35fa9c4bb

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

2 years ago[Matrix] Update column.major.load call in PPC test.
Florian Hahn [Thu, 12 Aug 2021 10:25:10 +0000 (11:25 +0100)]
[Matrix] Update column.major.load call in PPC test.

a1ef81de35a4bac6d3 adjusted the definition of the intrinsic, but did not
update a PowerPC test. Fix the test by updating the call & declaration
of @llvm.matrix.column.major.load.

2 years ago[llvm-objcopy][ELF] Avoid reordering section headers
Igor Kudrin [Thu, 12 Aug 2021 10:12:09 +0000 (17:12 +0700)]
[llvm-objcopy][ELF] Avoid reordering section headers

As for now, llvm-objcopy sorts section headers according to the offsets
of the sections in the input file. That can corrupt section references
in the dynamic symbol table because it is a loadable section and as such
is not updated by the tool. Even though the section references are not
required for loading the binary correctly, they are still handy for a
user who analyzes the file.

While the patch removes global reordering of section headers, it layouts
the sections in the same way as before, i.e. according to their original
offsets. All that helps the output file to resemble the input better.

Note that the patch removes sorting SHT_GROUP sections to the start of
the list, which was introduced in D62620 in order to ensure that they
come before the group members, along with the corresponding test. The
original issue was caused by the sorting of section headers, so dropping
the sorting also resolves the issue.

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

2 years ago[Matrix] Overload stride arg in matrix.columnwise.load/store.
Florian Hahn [Thu, 12 Aug 2021 08:53:04 +0000 (09:53 +0100)]
[Matrix] Overload stride arg in matrix.columnwise.load/store.

This patch adjusts the intrinsics definition of
llvm.matrix.column.major.load and llvm.matrix.column.major.store to
allow overloading the type of the stride. The bitwidth of the stride is
used to perform the offset computation.

This fixes a crash when using __builtin_matrix_column_major_load or
__builtin_matrix_column_major_store on 32 bit platforms. The stride argument
of the builtins are defined as `size_t`, which is 32 bits wide on 32 bit
platforms.

Note that we still perform offset computations with 64 bit width on 32
bit platforms for accesses that do not take a user-specified stride.
This can be fixed separately.

Fixes PR51304.

Reviewed By: erichkeane

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

2 years ago[llvm][sve] Lowering for VLS extending loads
David Truby [Wed, 11 Aug 2021 14:59:00 +0000 (14:59 +0000)]
[llvm][sve] Lowering for VLS extending loads

This patch enables extending loads for fixed length SVE code generation.

There is a slight regression here in the mulh tests; since these tests
load the parameter and then extend it these are treated as extending
loads which are merged, preventing the mulh instruction from being
generated. As this affects scalable SVE codegen as well this should be
addressed in a separate patch.

Reviewed By: bsmith

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

2 years ago[clang-tidy][docs] Remove the entry about 'cppcoreguidelines-init-variables' from...
Whisperity [Thu, 12 Aug 2021 08:41:46 +0000 (10:41 +0200)]
[clang-tidy][docs] Remove the entry about 'cppcoreguidelines-init-variables' from the release notes

The patch in http://reviews.llvm.org/D106431 landed in commit
4a097efe7784767b7d12ffcb8f2b22b9f4d045e2 to the main branch.
However, this patch was also backported to upcoming release 13.0.0 in
commit 8dcdfc0de84f60b5b4af97ac5b357881af55bc6e, which makes this entry
in the release notes **NOT** a new thing for the purposes of 14.0.0.

2 years ago[clang-format] improve distinction of K&R function definitions vs attributes
Krasimir Georgiev [Thu, 12 Aug 2021 08:26:56 +0000 (10:26 +0200)]
[clang-format] improve distinction of K&R function definitions vs attributes

After
https://github.com/llvm/llvm-project/commit/9da70ab3d43c79116f80fc06aa7cf517374ce42c
we saw a few regressions around trailing attribute definitions and in
typedefs (examples in the added test cases). There's some tension
distinguishing K&R definitions from attributes at the parser level,
where we have to decide if we need to put the type of the K&R definition
on a new unwrapped line before we have access to the rest of the line,
so we're scanning backwards and looking for a pattern like f(a, b). But
this type of pattern could also be an attribute macro, or the whole
declaration could be a typedef itself. I updated the code to check for a
typedef at the beginning of the line and to not consider raw identifiers
as possible first K&R declaration (but treated as an attribute macro
instead). This is not 100% correct heuristic, but I think it should be
reasonably good in practice, where we'll:
  * likely be in some very C-ish code when using K&R style (e.g., stuff
    that uses `struct name a;` instead of `name a;`
  * likely be in some very C++-ish code when using attributes
  * unlikely mix up the two in the same declaration.

Ideally, we should only decide to add the unwrapped line before the K&R
declaration after we've scanned the rest of the line an noticed the
variable declarations and the semicolon, but the way the parser is
organized I don't see a good way to do this in the current parser, which
only has good context for the previously visited tokens. I also tried
not emitting an unwrapped line there and trying to resolve the situation
later in the token annotator and the continuation indenter, and that
approach seems promising, but I couldn't make it to work without
messing up a bunch of other cases in unit tests.

Reviewed By: MyDeveloperDay

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

2 years ago[X86] Reverse *_set_ph and *_setr_ph 's set order.
Freddy Ye [Thu, 12 Aug 2021 08:24:16 +0000 (16:24 +0800)]
[X86] Reverse *_set_ph and *_setr_ph 's set order.

Reviewed By: pengfei

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

2 years ago[compiler-rt][fuzzer] Mark flags test unsupported on AArch64 Linux
David Spickett [Thu, 12 Aug 2021 08:24:47 +0000 (08:24 +0000)]
[compiler-rt][fuzzer] Mark flags test unsupported on AArch64 Linux

Previously I xfailed this but it's only failing in stage 2 so
we get xpasses for stage 1. Disable it completely.

2 years ago[AArch64] NFC: Remove register decoder tables in disassembler
Cullen Rhodes [Thu, 12 Aug 2021 07:28:56 +0000 (07:28 +0000)]
[AArch64] NFC: Remove register decoder tables in disassembler

The register classes are generated by TableGen, use them instead of
handwritten tables.

Reviewed By: david-arm

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

2 years ago[Object] Add missing PPC_DYNAMIC_TAG macros
Fangrui Song [Thu, 12 Aug 2021 07:05:04 +0000 (00:05 -0700)]
[Object] Add missing PPC_DYNAMIC_TAG macros

2 years ago[clang-format] handle trailing comments in function definition detection
Krasimir Georgiev [Thu, 12 Aug 2021 06:51:58 +0000 (08:51 +0200)]
[clang-format] handle trailing comments in function definition detection

A follow-up to
https://github.com/llvm/llvm-project/commit/f6bc614546e169bb1b17a29c422ebace038e6c62
where we handle the case where the semicolon is followed by a trailing
comment.

Reviewed By: MyDeveloperDay

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

2 years agotsan: fix build breakage due to AppMemBeg
Dmitry Vyukov [Thu, 12 Aug 2021 06:14:22 +0000 (08:14 +0200)]
tsan: fix build breakage due to AppMemBeg

AppMemBeg was renamed to LoAppMemBeg in 3830c93478
("tsan: rename kAppMemBeg to kLoAppMemBeg").
Rename remaining uses of the old name in tsan_platform_mac.cpp.

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

2 years ago[profile][test] Add -no-pie to make value profile merge work on Linux with default PIE
Fangrui Song [Thu, 12 Aug 2021 05:41:52 +0000 (22:41 -0700)]
[profile][test] Add -no-pie to make value profile merge work on Linux with default PIE

Alpine enables PIE by default.

2 years ago[tests] [trace] Add a more comprehensive test for `thread trace export ctf` command
Walter Erquinigo [Thu, 12 Aug 2021 03:05:31 +0000 (20:05 -0700)]
[tests] [trace] Add a more comprehensive test for `thread trace export ctf` command

Follow up on https://reviews.llvm.org/D105741

- Add new test that exhaustively checks the output file's content
- Fix typos in documentation and other minor fixes

Reviewed By: wallace

Original Author: jj10306

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

2 years agoReapply "SROA: Enhance speculateSelectInstLoads"
Christudasan Devadasan [Tue, 10 Aug 2021 03:36:21 +0000 (23:36 -0400)]
Reapply "SROA: Enhance speculateSelectInstLoads"

Originally committed as ffc3fb665d0a0dccd64cc8c803ad8cc1a0d5dfa1
Reverted in fcf2d5f40296be4e0f0e954001beb7814f97a212 due to an
assertion failure.

Original commit message:

Allow the folding even if there is an
intervening bitcast.

Reviewed By: arsenm

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

2 years ago[CMake] Enable clang_rt.crt{begin,end} on ppc32/ppc64
Daniel Kolesa [Thu, 12 Aug 2021 01:25:41 +0000 (18:25 -0700)]
[CMake] Enable clang_rt.crt{begin,end} on ppc32/ppc64

2 years agoUpdate gdbremote_testcase.py to allow new k-v pair in qMemoryRegionInfo
Jason Molenda [Thu, 12 Aug 2021 00:34:52 +0000 (17:34 -0700)]
Update gdbremote_testcase.py to allow new k-v pair in qMemoryRegionInfo

2 years agoFix two bugs with stack corefiles patch, restrict test built debugserver
Jason Molenda [Thu, 12 Aug 2021 00:17:39 +0000 (17:17 -0700)]
Fix two bugs with stack corefiles patch, restrict test built debugserver

These two tests, TestSkinnyCorefile.py and TestStackCorefile.py,
require a new debugserver on darwin systems to run correctly; for now,
skip them if the system debugserver is in use.  There's no easy way to
test if the debugserver being used supports either of these memory
region info features. For end users, the fallback will be a full
corefile and that's not the worst thing, but for the tests it is a
problem.

2 years ago[AArch64][GlobalISel] Simplify/nuke the merge/unmerge legalizer rules.
Amara Emerson [Wed, 11 Aug 2021 23:26:51 +0000 (16:26 -0700)]
[AArch64][GlobalISel] Simplify/nuke the merge/unmerge legalizer rules.

These rules were originally written when the new predicate based legalizer
was introduced in an attempt to preserve existing behaviour. It wasn't
properly kept up to date as things like vector support was split out into
G_CONCAT_VECTORS, and frankly, even if it was, it was too complex.

It's much easier to start from scratch with what we can actually support,
which is just a few type combinations. Anything illegal we should either
legalize, or should be eliminated as a side effect of artifact combination.

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

2 years ago[libc] add strtoll function and backend
Michael Jones [Thu, 5 Aug 2021 21:06:08 +0000 (21:06 +0000)]
[libc] add strtoll function and backend

This change adds the stroll function, but most of the implementation is
in the new file str_conv_utils.h since many of the other integer
conversion functions are implemented through what are effectively calls
to strtoll.

Reviewed By: sivachandra

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

2 years agoSupport post-processing Ops in unrolled loop iterations
Tyler Augustine [Wed, 11 Aug 2021 23:00:29 +0000 (23:00 +0000)]
Support post-processing Ops in unrolled loop iterations

This can be useful when one needs to know which unrolled iteration an Op belongs to, for example, conveying noalias information among memory-affecting ops in parallel-access loops.

Reviewed By: mehdi_amini

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

2 years ago[CSSPGO][llvm-profgen] Trim and merge context beforehand to reduce memory usage
wlei [Mon, 9 Aug 2021 18:44:33 +0000 (11:44 -0700)]
[CSSPGO][llvm-profgen] Trim and merge context beforehand to reduce memory usage

Currently we use a centralized string map(StringMap<FunctionSamples> ProfileMap) to store the profile while populating the sample, which might cause the memory usage bottleneck. I saw in an extreme case, there are thousands of samples whose context stack depth is >= 100. The memory consumption can be greater than 100GB.

As here the context is used for inlining, we can assume we won't have so many of inlinees keeping inlined at the same root function, so this change tried to cap the context stack and merge the samples for peak memory reduction and this is done after recursion compression.

The default value is -1 meaning no depth limit, in the future we can tune to a smaller one.

Reviewed By: hoy, wenlei

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

2 years ago[mlir] Drop LLVM dialect from TestPolynomialApproximation
Benjamin Kramer [Wed, 11 Aug 2021 22:58:52 +0000 (00:58 +0200)]
[mlir] Drop LLVM dialect from TestPolynomialApproximation

No longer needed after c1ebefdf77f34cc0b23597071098c8f8a8d2839b

2 years agoAdd missing cmake dep to fix MLIR build with BUILD_SHARED_LIBS=ON (NFC)
Mehdi Amini [Wed, 11 Aug 2021 22:50:44 +0000 (22:50 +0000)]
Add missing cmake dep to fix MLIR build with BUILD_SHARED_LIBS=ON (NFC)

2 years ago[lldb] Fix TestFormattersBoolRefPtr on AS
Jonas Devlieghere [Wed, 11 Aug 2021 21:54:32 +0000 (14:54 -0700)]
[lldb] Fix TestFormattersBoolRefPtr on AS

BOOL is bool instead of signed char on ARM. See
https://reviews.llvm.org/D93421#inline-874116 for details.

2 years ago[AArch64][SVE] Remove assertion/range check for i16 values during immediate selection
Usman Nadeem [Wed, 11 Aug 2021 21:44:44 +0000 (14:44 -0700)]
[AArch64][SVE] Remove assertion/range check for i16 values during immediate selection

The assertion can fail in some cases when an i16 constant is promoted
to i32.

e.g. in the added test case the value `i16 -32768` is within the range
of i16 but the assert fails when the constant is promoted to positive
`i32 32768` by an earlier call to DAG.getConstant().

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

Change-Id: I2f6179783cbc9630e6acab149a762b43c65664de

2 years ago[lldb] Replace assertTrue(foo in bar) with assertIn(foo, bar)
Jonas Devlieghere [Wed, 11 Aug 2021 21:40:15 +0000 (14:40 -0700)]
[lldb] Replace assertTrue(foo in bar) with assertIn(foo, bar)

The benefit of using assertIn is an improved error message when the
assertion fails:

  AssertionError: False is not True

becomes

  AssertionError: 'have ints 5 20 20 5' not found in '""'

2 years ago[lldb] Skip TestConcurrent.* watchpoint tests for Darwin on ARM
Jonas Devlieghere [Wed, 11 Aug 2021 21:26:31 +0000 (14:26 -0700)]
[lldb] Skip TestConcurrent.* watchpoint tests for Darwin on ARM

All TestConcurrent.* tests that involve watchpoints are broken on
ARM-based Darwin platforms, including Apple Silicon.

rdar://81811539