platform/upstream/llvm.git
2 years ago[clang-apply-replacements] Added an option to ignore insert conflict.
Sockke [Mon, 30 May 2022 05:02:25 +0000 (13:02 +0800)]
[clang-apply-replacements] Added an option to ignore insert conflict.

If two different texts are inserted at the same offset, clang-apply-replacements prints the conflict error and discards all fixes. This patch adds support for adjusting conflict offset and keeps running to continually fix them.

https://godbolt.org/z/P938EGoxj doesn't have any fixes when I run run-clang-tidy.py to generate a YAML file with clang-tidy and fix them with clang-apply-replacements. The YAML file has two different header texts insertions at the same offset, unlike clang-tidy with '-fix', clang-apply-replacements does not adjust for this conflict.

Reviewed By: aaron.ballman

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

2 years ago[RISCV] Support VP_REDUCE_MUL mask operation
Ping Deng [Mon, 30 May 2022 02:54:23 +0000 (02:54 +0000)]
[RISCV] Support VP_REDUCE_MUL mask operation

Reviewed By: reames

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

2 years ago[LegalizeTypes][VP] Add integer promotion support for vp.fptosi/vp.fptoui
Ping Deng [Mon, 30 May 2022 02:52:40 +0000 (02:52 +0000)]
[LegalizeTypes][VP] Add integer promotion support for vp.fptosi/vp.fptoui

Reviewed By: craig.topper

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

2 years agoRevert "[Driver] Enable to use C++20 standalne by -fcxx-modules"
Chuanqi Xu [Mon, 30 May 2022 02:43:13 +0000 (10:43 +0800)]
Revert "[Driver] Enable to use C++20 standalne by -fcxx-modules"

This reverts commit 99eca8353808f63670c647aeae03e0ce66eb21e0.

Since it would cause clang-tools-extra fail.

2 years ago[Driver] Enable to use C++20 standalne by -fcxx-modules
Chuanqi Xu [Mon, 30 May 2022 02:08:39 +0000 (10:08 +0800)]
[Driver] Enable to use C++20 standalne by -fcxx-modules

This patch allows user to use C++20 module by -fcxx-modules. Previously,
we could only use it under -std=c++20. Given that user could use C++20
coroutine standalonel by -fcoroutines-ts. It makes sense to offer an
option to use C++20 modules without enabling C++20.

Reviewed By: iains, MaskRay

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

2 years ago[InstCombine] bitcast (extractelement <1 x elt>, dest) -> bitcast(<1 x elt>, dest)
Chenbing Zheng [Mon, 30 May 2022 02:16:32 +0000 (10:16 +0800)]
[InstCombine] bitcast (extractelement <1 x elt>, dest) -> bitcast(<1 x elt>, dest)

Only solve dest type is vector to avoid inverse transform in visitBitCast.

Reviewed By: spatel

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

2 years agoFix `performance-unnecessary-value-param` for template specialization
Sockke [Mon, 30 May 2022 01:43:27 +0000 (09:43 +0800)]
Fix `performance-unnecessary-value-param` for template specialization

The checker missed a check for parameter type of primary template of specialization template and this could cause build breakages.

Reviewed By: aaron.ballman, flx

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

2 years ago[NFC][VP] Fix llvm.vp.merge intrinsic Expansion in LangRef
Lian Wang [Fri, 27 May 2022 06:20:21 +0000 (06:20 +0000)]
[NFC][VP] Fix llvm.vp.merge intrinsic Expansion in LangRef

Reviewed By: simoll

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

2 years ago[RISCV] isel (add (and X, 0x1FFFFFFFE), Y) as (SH1ADD (SRLI X, 1), Y)
Craig Topper [Mon, 30 May 2022 01:05:06 +0000 (18:05 -0700)]
[RISCV] isel (add (and X, 0x1FFFFFFFE), Y) as (SH1ADD (SRLI X, 1), Y)

This pattern is what we get after DAG combine for C code like this.

short *ptr1, *ptr2, *ptr3;
unsigned diff = ptr1 - ptr2;
return ptr3[diff];

Reviewed By: reames

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

2 years ago[RISCV] Add test cases showing missed opportunity to use shXadd.uw. NFC
Craig Topper [Mon, 30 May 2022 01:03:25 +0000 (18:03 -0700)]
[RISCV] Add test cases showing missed opportunity to use shXadd.uw. NFC

The tests here show the codegen for something like this C code.

unsigned diff = ptr1 - ptr2;
return ptr3[diff];

The pointer difference is truncated to 32-bits before being used
again as an index. In SelectionDAG this appears as an AND between
a SRL and a SHL. DAGCombiner will remove the shifts leaving only
an AND. The Mask now has 1,2, or 3 trailing zeros and 31, 30, or 29
leading zeros. We end up falling back to constant materialization
to create this mask.

We could instead use srli followed by slli.uw. Or since
we have an add, we can use srli followed by shXadd.uw.

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

2 years agoRecommit "[LICM] Only create load in ph when promoting load or store doesn't exec."
Florian Hahn [Sun, 29 May 2022 20:57:14 +0000 (21:57 +0100)]
Recommit "[LICM] Only create load in ph when promoting load or store doesn't exec."

This reverts the revert commit ad95255b9215a.

The updated version also creates a load when the store may not execute.
In those cases, we still need to introduce a load in a function where
there may not have been one before, so this doesn't completely resolve
issue #51248.

Original message:

    When only a store is sunk, there is no need to create a load in the
    pre-header, as the result of the load will never get used.

    The dead load can can introduce UB, if the function is marked as
    writeonly.

    Reviewed By: nikic

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

2 years ago[AArch64] Reuse larger DUP if available
David Green [Sun, 29 May 2022 18:42:13 +0000 (19:42 +0100)]
[AArch64] Reuse larger DUP if available

If both a v2i32 DUP(x) and a v4i32 DUP(x) node exists, we can re-use the
larger node using a vector extract to obtain the smaller. This comes up
in the smull/smlal code, but needs a small fixup to allow the smull2
code in tryExtendDUPToExtractHigh/performAddSubLongCombine to still
match smull2 extracts.

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

2 years ago[libc++][test] Remove Clang <= 3.7 workaround in is_default_constructible test
Joe Loser [Sat, 28 May 2022 23:08:18 +0000 (17:08 -0600)]
[libc++][test] Remove Clang <= 3.7 workaround in is_default_constructible test

Clang 3.7 and below is not actively used or supported in the test suite now, so
remove the workaround in the test.

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

2 years ago[InstCombine] Add baseline tests for shift+and+icmp transforms; NFC
chenglin.bi [Sun, 29 May 2022 17:01:37 +0000 (01:01 +0800)]
[InstCombine] Add baseline tests for shift+and+icmp transforms; NFC

2 years ago[X86] Adjust vector shift costs to match SoG (Issue #54889)
Simon Pilgrim [Sun, 29 May 2022 16:55:39 +0000 (17:55 +0100)]
[X86] Adjust vector shift costs to match SoG (Issue #54889)

znver1/2 models were incorrectly modelling the fpupipe (should be pipe2 for shift-by-scalar-amount and pipe1 for shift-by-element-amount) and znver1 ymm variants also require double pumping.

Now matches AMD SoG, Agner and instlatx64 numbers.

Thanks to @fabian-r for the report

2 years ago[InstCombine] Add baseline tests for shift+and transforms; NFC
chenglin.bi [Sun, 29 May 2022 16:30:56 +0000 (00:30 +0800)]
[InstCombine] Add baseline tests for shift+and transforms; NFC

2 years ago[libc++][doc] Clarify wording on the status page.
Mark de Wever [Sun, 15 May 2022 13:29:03 +0000 (15:29 +0200)]
[libc++][doc] Clarify wording on the status page.

Reviewed By: philnik, #libc

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

2 years ago[libc++] Adds __format_string as nasty macro.
Mark de Wever [Sun, 15 May 2022 13:17:46 +0000 (15:17 +0200)]
[libc++] Adds __format_string as nasty macro.

Both D121530 and D125606 had issues with this macro.

Reviewed By: #libc, philnik

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

2 years ago[libclang] Fix error message capitalization
Ayke van Laethem [Sun, 29 May 2022 11:42:22 +0000 (13:42 +0200)]
[libclang] Fix error message capitalization

This was a review suggestion from MaskRay that I forgot to incorporate
in the patch.

See: https://reviews.llvm.org/D124815

2 years ago[libclang] Fall back to getMainExecutable when dladdr fails
Ayke van Laethem [Tue, 3 May 2022 00:53:05 +0000 (02:53 +0200)]
[libclang] Fall back to getMainExecutable when dladdr fails

musl-libc doesn't support dladdr in statically linked binaries:

> Are you using static or dynamic linking? If static, dladdr is just a
> stub that always fails. It could be implemented to work under some
> conditions, but it would be highly dependent on what options you
> compile the binary with, since by default static binaries do not
> contain the bloat that would be needed to perform introspection.

Source: https://www.openwall.com/lists/musl/2013/01/15/25 (in response
to a bug report).

Libclang unfortunately uses dladdr to find the ResourcesPath so will
fail if it is linked statically on Alpine Linux. This patch fixes this
issue by falling back to getMainExecutable if dladdr returns an error.

Reference: https://github.com/llvm/llvm-project/issues/40641#issuecomment-981011427

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

2 years ago[libc++] Use __enable_if_t and is_integral in cstddef
Nikolas Klauser [Sat, 28 May 2022 13:22:25 +0000 (15:22 +0200)]
[libc++] Use __enable_if_t and is_integral in cstddef

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[mlir][NFC] Trivial : Fix typo
Javed Absar [Sat, 28 May 2022 19:32:13 +0000 (20:32 +0100)]
[mlir][NFC] Trivial : Fix typo

Reviewed By: JohnTitor

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

2 years ago[libc++] Adds missing includes.
Mark de Wever [Sun, 29 May 2022 09:11:32 +0000 (11:11 +0200)]
[libc++] Adds missing includes.

This fixes the broken Apple builds. This has been tested in D121530
(https://buildkite.com/llvm-project/libcxx-ci/builds/11113)

2 years ago[clang-repl] Recover the lookup tables of the primary context.
Purva-Chaudhari [Sun, 29 May 2022 04:55:10 +0000 (04:55 +0000)]
[clang-repl] Recover the lookup tables of the primary context.

Before this patch, there was re-declaration error if error was encountered in
the same line. The recovery support acted only if this type of error was
encountered in the first line of the program and not in subsequent lines.

For example:

```
clang-repl> int i=9;
clang-repl> int j=9; err;
input_line_3:1:5: error: redefinition of 'j'
int j = 9;
```

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

2 years ago[clang] Remove `rm` script which is no longer necessary
Yuki Okushi [Sat, 28 May 2022 16:26:46 +0000 (01:26 +0900)]
[clang] Remove `rm` script which is no longer necessary

8b4fa2c98e07997469f53bee30c0d24a61dc7c8c added this to remove left-over files on January.
Now we could assume they're cleaned up and this `rm` script is no longer necessary as FIXME states.

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

2 years ago[MLIR][Presburger] Add applyDomain/Range to IntegerRelation
Groverkss [Sat, 28 May 2022 20:36:11 +0000 (02:06 +0530)]
[MLIR][Presburger] Add applyDomain/Range to IntegerRelation

This patch adds support for applying a relation on domain/range of a relation.

Reviewed By: arjunp, ftynse

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

2 years ago[VPlan] Use Exiting-block instead of Exit-block terminology (NFC).
Florian Hahn [Sat, 28 May 2022 20:16:05 +0000 (21:16 +0100)]
[VPlan] Use Exiting-block instead of Exit-block terminology (NFC).

In LLVM's common loop terminology, an exit block is a block outside a
loop with a predecessor inside the loop. An exiting block is a block
inside the loop which branches to an exit block outside the loop.

This patch updates a few places where VPlan was using ExitBlock for a
block exiting a region. Those instances have been updated to use
ExitingBlock.

Reviewed By: Ayal

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

2 years agoIncrease the default maximum stack walk
Jason Molenda [Sat, 28 May 2022 20:09:36 +0000 (13:09 -0700)]
Increase the default maximum stack walk

lldb will only backtrace a fixed number of stack frames, as a
last-ditch attempt to avoid a runaway looping backtrace.  It's
unusual that anyone ends up depending on this final safety net in
years. I picked the original number of 300000 was picked by seeing
how many stack frames I could make in a small recursive function
on Darwin systems before using the default stack space.  Checking
again today on a modern system, I can exceed this limit & lldb will
not show the original invocation of the recursing call.  Double the
old value to cover this larger maximum possible stack frame count,
as a default value.
(`target.process.thread.max-backtrace-depth`)

2 years ago[flang] Make extension explicit: exponent-letter matching kind-param
Emil Kieri [Fri, 27 May 2022 22:27:59 +0000 (00:27 +0200)]
[flang] Make extension explicit: exponent-letter matching kind-param

As an extension for REAL literals, we allow an exponent letter which
matches an explicit kind-param. The standard requires the exponent
to be 'E' if a kind-param is present. This patch
 - documents this extension in Extensions.md
 - enables a portability warning if it is used with -pedantic

The test case for this, kinds05.f90, needs D125804, which makes
test_errors.py test warnings as well, to actually test the warnings.
I include it already now to keep things together, it will do no harm
(I hope ...).

We also add WARNING-directives to the test kinds04.f90 in preparation
for D125804. As the exponent-letter 'Q' does not imply the same kind
on all platforms, the emitted warnings are platform-dependent.
Therefore, the test is duplicated into two variants which are run
conditionally.

Finally, we promote the portability warning for when the exponent letter
is neither 'E' nor matching the kind-param to a standard warning.

Reviewed By: klausler

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

2 years ago[clang][cmake] Fixed typo in hmaptool CMakeLists.txt
Daniel Hannon [Sat, 28 May 2022 17:10:10 +0000 (10:10 -0700)]
[clang][cmake] Fixed typo in hmaptool CMakeLists.txt

There was a typo in the CMakeLists.txt for hmap tool that installed it to the wrong directory

https://github.com/llvm/llvm-project/issues/55753

Reviewed By: keith

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

2 years ago[flang] Make generic resolution conform to 15.5.5.2 w/r/t host association
Peter Klausler [Thu, 26 May 2022 23:56:27 +0000 (16:56 -0700)]
[flang] Make generic resolution conform to 15.5.5.2 w/r/t host association

When two or more generic interfaces are available by declaration or
by USE association at different scoping levels, we need to search
the outer generic interfaces as well as the inner ones, but only after
the inner ones have failed to produce a specific procedure that matches
a given set of actual arguments.  This means that it is possible for
a specific procedure of a generic interface of an inner scope to override
a conflicting specific procedure of a generic interface of an outer
scope.

Also cope with forward references to derived types when a generic
interface is also in scope.

Fixes LLVM bug https://github.com/llvm/llvm-project/issues/55240 and
LLVM bug https://github.com/llvm/llvm-project/issues/55300.

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

2 years ago[nfc][flang] Fix spelling errors and usage in an error message
Peter Klausler [Thu, 26 May 2022 18:01:19 +0000 (11:01 -0700)]
[nfc][flang] Fix spelling errors and usage in an error message

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

2 years agoRemove `deplibs` keyword completely
Yuki Okushi [Fri, 27 May 2022 10:21:52 +0000 (19:21 +0900)]
Remove `deplibs` keyword completely

D102763 removed the almost support of `deplibs` but it seems `kw_deplibs` was missed.
This patch removes it.

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

2 years ago[flang] Avoid spurious warnings from reading module files
Peter Klausler [Tue, 24 May 2022 22:06:12 +0000 (15:06 -0700)]
[flang] Avoid spurious warnings from reading module files

When processing the literal constants of the various kinds of
INTEGER that are too large by 1 (e.g., 2147483648_4) in expression
analysis, emit a portability warning rather than a fatal error if
the literal constant appears as the operand to a unary minus, since
the folded result will be in range.  And don't emit any warning if
the negated literal is coming from a module file -- f18 wrote the
module file and the warning would simply be confusing, especially to
the programmer that wrote (-2147483647_4-1) in the first place.

Further, emit portability warnings for the canonical expressions for
infinities and NaN (-1./0., 0./0., & 1./0.), but not when they appear
in a module file, for the same reason.  The Fortran language has no
syntax for these special values so we have to emit expressions that
fold to them.

Fixes LLVM bugs https://github.com/llvm/llvm-project/issues/55086 and
https://github.com/llvm/llvm-project/issues/55081.

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

2 years ago[docs] Update the label name for new contributors
Yuki Okushi [Fri, 27 May 2022 09:03:30 +0000 (18:03 +0900)]
[docs] Update the label name for new contributors

The `beginner` label is deprecated
and the `good first issue` label is now preferred.

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

2 years ago[libc++] Minor emscripten changes from downstream
Sam Clegg [Sat, 22 May 2021 13:39:33 +0000 (06:39 -0700)]
[libc++] Minor emscripten changes from downstream

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

2 years ago[flang][OpenMP] Fix pointer variables in atomic read/write
Peixin-Qiao [Sat, 28 May 2022 08:41:14 +0000 (16:41 +0800)]
[flang][OpenMP] Fix pointer variables in atomic read/write

For pointer variables, using getSymbolAddress cannot get the coorect
address for atomic read/write operands. Use genExprAddr to fix it.

Reviewed By: shraiysh, NimishMishra

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

2 years ago[flang][OpenMP][OpenACC] Fix exit of a region
Peixin-Qiao [Sat, 28 May 2022 08:34:26 +0000 (16:34 +0800)]
[flang][OpenMP][OpenACC] Fix exit of a region

The stop statement is allowed in OpenMP/OpenACC block region.

Reviewed By: kiranchandramohan, shraiysh

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

2 years ago[gn build] Port 30c37fb89cb7
LLVM GN Syncbot [Sat, 28 May 2022 08:16:52 +0000 (08:16 +0000)]
[gn build] Port 30c37fb89cb7

2 years ago[libc++] Granularize more of <type_traits>
Nikolas Klauser [Thu, 26 May 2022 09:49:01 +0000 (11:49 +0200)]
[libc++] Granularize more of <type_traits>

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[libc++] Remove unused __functional includes
Nikolas Klauser [Fri, 20 May 2022 22:45:51 +0000 (00:45 +0200)]
[libc++] Remove unused __functional includes

Reviewed By: ldionne, #libc

Spies: arichardson, smeenai, libcxx-commits, arphaman

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

2 years ago[Lex] Fix crash during dependency scanning while skipping an unmatched `#if`
Argyrios Kyrtzidis [Sat, 28 May 2022 06:59:30 +0000 (23:59 -0700)]
[Lex] Fix crash during dependency scanning while skipping an unmatched `#if`

2 years ago[CompilerInstance] Fix weird condition on `createCodeCompletionConsumer`
Yuki Okushi [Fri, 27 May 2022 08:42:49 +0000 (17:42 +0900)]
[CompilerInstance] Fix weird condition on `createCodeCompletionConsumer`

Fixes llvm#53545

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

2 years ago[Driver] Replace err_invalid_branch_protection with err_drv_unsupported_option_argument
Fangrui Song [Sat, 28 May 2022 05:28:39 +0000 (22:28 -0700)]
[Driver] Replace err_invalid_branch_protection with err_drv_unsupported_option_argument

The convention is to use err_drv_unsupported_option_argument instead of adding a
new diagnostic for every option.

2 years ago[ARM][AArch64] Change -mharden-sls= to use err_drv_unsupported_option_argument
Fangrui Song [Sat, 28 May 2022 05:03:48 +0000 (22:03 -0700)]
[ARM][AArch64] Change -mharden-sls= to use err_drv_unsupported_option_argument

Update the diagnostic in D81404: the convention is to use
err_drv_unsupported_option_argument instead of adding a new diagnostic for every
option.

Reviewed By: nickdesaulniers

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

2 years ago[scudo] Clean up Zircon header file uses
Roland McGrath [Sat, 28 May 2022 01:22:38 +0000 (18:22 -0700)]
[scudo] Clean up Zircon header file uses

Make fuchsia.h and fuchsia.cpp each include what they use.

2 years ago[mlir][bufferization] Add extra filter mechanism to bufferizeOp
Matthias Springer [Sat, 28 May 2022 02:48:36 +0000 (04:48 +0200)]
[mlir][bufferization] Add extra filter mechanism to bufferizeOp

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

2 years ago[mlir][bufferize][NFC] Split analysis+bufferization of ModuleBufferization
Matthias Springer [Sat, 28 May 2022 02:42:47 +0000 (04:42 +0200)]
[mlir][bufferize][NFC] Split analysis+bufferization of ModuleBufferization

Analysis and bufferization can now be run separately.

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

2 years ago[mlir][bufferization][NFC] Remove post-analysis step infrastructure
Matthias Springer [Sat, 28 May 2022 02:36:24 +0000 (04:36 +0200)]
[mlir][bufferization][NFC] Remove post-analysis step infrastructure

Now that analysis and bufferization are better separated, post-analysis steps are no longer needed. Users can directly interleave analysis and bufferization as needed.

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

2 years ago[mlir][bufferization][NFC] Move OpFilter out of BufferizationOptions
Matthias Springer [Fri, 27 May 2022 23:45:55 +0000 (01:45 +0200)]
[mlir][bufferization][NFC] Move OpFilter out of BufferizationOptions

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

2 years ago[OpenACC][OpenMP] Document atomic-in-teams extension
Joel E. Denny [Fri, 27 May 2022 22:53:19 +0000 (18:53 -0400)]
[OpenACC][OpenMP] Document atomic-in-teams extension

That is, put D126323 in the status doc and explain its relationship to
OpenACC support.

Reviewed By: jdoerfert

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

2 years ago[RISCV] Allow PRE of vsetvli involving non-1 LMUL
Philip Reames [Fri, 27 May 2022 22:37:42 +0000 (15:37 -0700)]
[RISCV] Allow PRE of vsetvli involving non-1 LMUL

This is a follow up to address a review comment from D124869. When deciding whether to PRE a vsetvli, we can allow non-LMUL1 vsetvlis.

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

2 years ago[LSR][TTI][PowerPC][SystemZ][X86] Add const-ness to TTI::isLSRCostLess. NFC
eopXD [Wed, 25 May 2022 03:06:34 +0000 (20:06 -0700)]
[LSR][TTI][PowerPC][SystemZ][X86] Add const-ness to TTI::isLSRCostLess. NFC

Reviewed By: Meinersbur

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

2 years ago[bazel] BLAKE3: Adopt aarch64 and x86_64.
NAKAMURA Takumi [Fri, 27 May 2022 14:39:52 +0000 (23:39 +0900)]
[bazel] BLAKE3: Adopt aarch64 and x86_64.

FIXME: arm(32) may be applicable here. I haven't tested yet.

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

2 years ago[lldb] Fix cross compiling on macOS
Martin Storsjö [Fri, 27 May 2022 13:37:43 +0000 (16:37 +0300)]
[lldb] Fix cross compiling on macOS

When cross compiling, a separate nested cmake is spawned, for building
host code generation tools such as lldb-tblgen.

When cross compiling on macOS, the nested native build would trigger
the lldb check for libc++, if testing is enabled (which it is by default).
(Even if `LLDB_INCLUDE_TESTS=OFF` is set on the main build, it has to
be passed separately in `CROSS_TOOLCHAIN_FLAGS_NATIVE` to reach the
nested build.)

Skip this check when building the host tools when cross compiling, as
the user won't try to run tests in that nested build.

(Alternatively, we could consider disabling all the `*_INCLUDE_TESTS`
by default in the nested host tools build.)

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

2 years ago[RISCV] Correct load/store alignments in sink-splat-operands.ll. NFC
Craig Topper [Fri, 27 May 2022 21:39:30 +0000 (14:39 -0700)]
[RISCV] Correct load/store alignments in sink-splat-operands.ll. NFC

These should be aligned to the natural alignment of the element.
Probably copy/paste mistake from the i32 tests.

Reviewed By: reames

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

2 years ago[mlir][sparse] Fixes C++98 warning
wren romano [Fri, 27 May 2022 19:42:46 +0000 (12:42 -0700)]
[mlir][sparse] Fixes C++98 warning

The semicolons were introduced in D126105 in order to correct clang-format, but I forgot this file must be compiled as C++98 rather than C++11.

Reviewed By: aartbik

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

2 years ago[RISCV] Add a vsetvli PRE test involving non-1 LMUL
Philip Reames [Fri, 27 May 2022 19:51:54 +0000 (12:51 -0700)]
[RISCV] Add a vsetvli PRE test involving non-1 LMUL

2 years ago[RISCV] Use template version of SignExtend64 for constant extends. NFC
Craig Topper [Fri, 27 May 2022 20:10:47 +0000 (13:10 -0700)]
[RISCV] Use template version of SignExtend64 for constant extends. NFC

We were inconsistent about which one we used.

2 years ago[CMake] Make FindLibEdit.cmake more robust
Tobias Ribizel [Fri, 27 May 2022 20:06:45 +0000 (13:06 -0700)]
[CMake] Make FindLibEdit.cmake more robust

FindLibEdit uses pkg-config to find the necessary flags, but this may break with cross-compilation,
because the PkgConfig module in CMake doesn't respect the SYSROOT specified in a toolchain file.
Instead of taking the parameters from pkg-config for granted, we check whether our compiler can
actually include and link against the library.

Fixes #55445
Fixes #55671

Reviewed By: MaskRay

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

2 years ago[runtimes] Rename various libcpp-has-no-XYZ Lit features to just no-XYZ
Louis Dionne [Thu, 26 May 2022 15:49:47 +0000 (11:49 -0400)]
[runtimes] Rename various libcpp-has-no-XYZ Lit features to just no-XYZ

Since those features are general properties of the environment, it makes
sense to use them from libc++abi too, and so the name libcpp-has-no-xxx
doesn't make sense.

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

2 years ago[libc++][NFC] Rename rand.dis to rand.dist
Nikolas Klauser [Mon, 23 May 2022 16:47:52 +0000 (18:47 +0200)]
[libc++][NFC] Rename rand.dis to rand.dist

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgrang, mstorsjo

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

2 years ago[RISCV] Remove unused variables. NFC
Craig Topper [Fri, 27 May 2022 19:13:41 +0000 (12:13 -0700)]
[RISCV] Remove unused variables. NFC

2 years ago[lld][WebAssembly] Fix crash on undefined+weak function syms in LTO objects
Sam Clegg [Fri, 27 May 2022 15:34:31 +0000 (08:34 -0700)]
[lld][WebAssembly] Fix crash on undefined+weak function syms in LTO objects

Symbols from LTO objects don't contain Wasm signatures, but we need a
signature when we create undefined/stub functions for missing weakly
undefined symbols.

Luckily, after LTO, we know that symbols that are not referenced by a
regular object file must not be needed in the final output so there
is no need to generate undefined/stub function for them.

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

2 years ago[llvm-lib] Ignore /LTCG option
Pengxuan Zheng [Thu, 19 May 2022 18:30:57 +0000 (11:30 -0700)]
[llvm-lib] Ignore /LTCG option

"The /LTCG option to LIB specifies that the inputs from cl.exe include object
files generated by using the /GL compiler option."

Based on Microsoft's description
above (https://docs.microsoft.com/en-us/cpp/build/reference/running-lib?view=msvc-170),
there doesn't seem to be anything llvm-lib needs to do to support the flag.

Reviewed By: rnk

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

2 years ago[RISCV] Return false from isOffsetFoldingLegal instead of reversing the fold in lowering.
Craig Topper [Fri, 27 May 2022 17:16:32 +0000 (10:16 -0700)]
[RISCV] Return false from isOffsetFoldingLegal instead of reversing the fold in lowering.

When lowering GlobalAddressNodes, we were removing a non-zero offset and
creating a separate ADD.

It already comes out of SelectionDAGBuilder with a separate ADD. The
ADD was being removed by DAGCombiner.

This patch disables the DAG combine so we don't have to reverse it.
Test changes all look to be instruction order changes. Probably due
to different DAG node ordering.

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

2 years agoAMDGPU: Add G_AMDGPU_MAD_64_32 instructions
Nicolai Hähnle [Thu, 28 Apr 2022 22:52:44 +0000 (17:52 -0500)]
AMDGPU: Add G_AMDGPU_MAD_64_32 instructions

These generic instructions are trivially selected to
V_MAD_[IU]64_[IU]32 instructions when run on the VALU.

When at least both factors are scalar, it is usually better to execute
some or all of the instruction on the SALU. To this end, we lower the
instruction to simpler instructions that are supported on the SALU
when applying the register bank mapping.

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

2 years ago[TSan][Darwin] Deflake test
Julian Lettner [Fri, 27 May 2022 17:15:18 +0000 (10:15 -0700)]
[TSan][Darwin] Deflake test

The asserted order of THREAD_DESTROY and end of main() is not
guaranteed:
```
 7: Hello from pthread
 8: THREAD_TERMINATE 0x7e8000104000, self: 0x7e8000104000, name: child thread
 9: Done.
10: THREAD_DESTROY 0x7e8000104000, self: 0x7e8000104000, name: child thread
```

Resulting in:
```
error: CHECK: expected string not found in input
// CHECK: Done.
```

Remove checking for "Done." (end of main()) to deflake this test.
Alternatively, we could use `CHECK-DAG`.

rdar://94036145

2 years ago[runtimes] Officially deprecate the legacy testing configuration system
Louis Dionne [Thu, 26 May 2022 15:12:45 +0000 (11:12 -0400)]
[runtimes] Officially deprecate the legacy testing configuration system

Add a warning and tweak the release note to explain that the deprecation
targets libc++, libc++abi and libuwnind as well.

Also, as a fly-by, ensure that our CI runs the legacy testing configuration
for libc++, libc++abi and libunwind. This doesn't matter too much since
it's deprecated, but we might as well test it properly.

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

2 years ago[libc++] Add various missing _LIBCPP_HIDE_FROM_ABI
Louis Dionne [Thu, 26 May 2022 19:24:59 +0000 (15:24 -0400)]
[libc++] Add various missing _LIBCPP_HIDE_FROM_ABI

Those were spotted when a project unintentionally started exporting
these symbols from its ABI just by using the libc++ headers.

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

2 years ago[OpenMP][mlir] fix broken build
Aart Bik [Fri, 27 May 2022 16:48:50 +0000 (09:48 -0700)]
[OpenMP][mlir] fix broken build

Reviewed By: Mogball

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

2 years agoRevert "[Clang] Extend -gen-reproducer flag"
Alex Brachet [Fri, 27 May 2022 17:03:32 +0000 (17:03 +0000)]
Revert "[Clang] Extend -gen-reproducer flag"

This reverts commit 684c080108766b4f112f172fed4a49059484614d.

2 years ago[libc++] Use __libcpp_clz for a tighter __log2i function
Hans Wennborg [Thu, 19 May 2022 09:06:11 +0000 (11:06 +0200)]
[libc++] Use __libcpp_clz for a tighter __log2i function

While looking at D113413 I noticed that __log2i could perhaps be
improved to be both slightly smaller and faster.

projects/libcxx/benchmarks/sort.libcxx.out --benchmark_filter=BM_Sort_uint32_QuickSortAdversary*
suggests this is performance neutral, but it shaves a few bytes off the
benchmark binary, and even more off a Chromium build.

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

2 years agocmake: use llvm dir variables for clang/utils/hmaptool
Matheus Izvekov [Tue, 24 May 2022 16:21:34 +0000 (18:21 +0200)]
cmake: use llvm dir variables for clang/utils/hmaptool

Install hmaptool using the LLVM specific variables, so
everything goes in the right place in case llvm is included
from a top level CMakeLists.txt.

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

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

2 years ago[WebAssembly] Consolidate sectionTypeToString in BinaryFormat [NFC]
Derek Schuff [Fri, 27 May 2022 15:23:37 +0000 (08:23 -0700)]
[WebAssembly] Consolidate sectionTypeToString in BinaryFormat [NFC]

Currently there are 2 duplicate implementation, and I want to add
a use in a 3rd place. Combine them in lib/BinaryFormat so they can
be shared.

Also update toString for symbol and reloc types to use StringRef

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

2 years ago[OpenMP] Support operation conversion to LLVM for threadprivate directive
PeixinQiao [Fri, 27 May 2022 16:06:57 +0000 (00:06 +0800)]
[OpenMP] Support operation conversion to LLVM for threadprivate directive

This supports the operation conversion for threadprivate directive. The
support for memref type conversion is not implemented.

Reviewed By: kiranchandramohan, shraiysh

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

2 years ago[InstCombine] fold multiply by signbit-splat to cmp+select
Sanjay Patel [Fri, 27 May 2022 15:27:14 +0000 (11:27 -0400)]
[InstCombine] fold multiply by signbit-splat to cmp+select

(ashr i32 X, 31) * C --> (X < 0) ? -C : 0
https://alive2.llvm.org/ce/z/G8u9SS

With a constant operand, this is an improvement in IR
and codegen (where it can be converted to a mask op).

Without a constant operand, we would have to negate
the operand, so that is probably better left to the backend.

This is similar but not the same optimization that is requested
in #55618.

2 years ago[InstCombine] reduce code duplication; NFC
Sanjay Patel [Fri, 27 May 2022 15:07:51 +0000 (11:07 -0400)]
[InstCombine] reduce code duplication; NFC

2 years ago[Clang][Driver] Fix include paths for `--sysroot /` on Linux
Egor Zhdan [Tue, 24 May 2022 11:00:50 +0000 (12:00 +0100)]
[Clang][Driver] Fix include paths for `--sysroot /` on Linux

Currently if `--sysroot /` is passed to the Clang driver, the include paths generated by the Clang driver will start with a double slash: `//usr/include/...`.
 If VFS is used to inject files into the include paths (for example, the Swift compiler does this), VFS will get confused and the injected files won't be visible.

This change makes sure that the include paths start with a single slash.

Fixes #28283.

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

2 years ago[Clang] Extend -gen-reproducer flag
Alex Brachet [Fri, 27 May 2022 15:49:13 +0000 (15:49 +0000)]
[Clang] Extend -gen-reproducer flag

-gen-reproducer causes crash reproduction to be emitted even
when clang didn't crash, and now can optionally take an argument
of never, on-crash (default), on-error and always.

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

2 years ago[PowerPC][AIX] Allow VSX patterns to be 32-bit and 64-bit safe on P8+.
Amy Kwan [Thu, 26 May 2022 14:24:12 +0000 (09:24 -0500)]
[PowerPC][AIX] Allow VSX patterns to be 32-bit and 64-bit safe on P8+.

This patch updates two patterns involving `scalar_to_vector` and
`SCALAR_TO_VECTOR_PERMUTED` nodes to be safe for both 64-bit and 32-bit by
pulling the patterns out of the 64-bit specific guard. These patterns are
matched on POWER8 and above.

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

2 years agoAdd llvm-debuginfod-find tool to Bazel build
Daniele Vettorel [Fri, 27 May 2022 14:17:29 +0000 (10:17 -0400)]
Add llvm-debuginfod-find tool to Bazel build

Add missing `llvm-debuginfod-find` tool to the Bazel build.

Patch by: vettoreldaniele.

Reviewed By: GMNGeoffrey

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

2 years ago[analyzer] Fix wrong annotation of LazyCompoundVal::getStore
Balazs Benics [Fri, 27 May 2022 14:05:33 +0000 (16:05 +0200)]
[analyzer] Fix wrong annotation of LazyCompoundVal::getStore

The build bot https://lab.llvm.org/buildbot#builders/5/builds/24183
uncovered a wrong nonnull annotation intoduced by D126198.

2 years ago[workflow] Don't fail workflow if we already have a PR for an issue
Tobias Hieta [Fri, 27 May 2022 14:02:15 +0000 (16:02 +0200)]
[workflow] Don't fail workflow if we already have a PR for an issue

When running /cherry-pick several times you will get an
error when it tries to create a new PR since there already
is one.

This checks if we have PR first.

Fixes #54862

Reviewed By: tstellar

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

2 years ago[clang][dataflow] Improve handling of constructor initializers.
Yitzhak Mandelbaum [Wed, 25 May 2022 18:51:13 +0000 (18:51 +0000)]
[clang][dataflow] Improve handling of constructor initializers.

Currently, we assert that `CXXCtorInitializer`s are field initializers. Replace
the assertion with an early return. Otherwise, we crash every time we process a
constructor with a non-field (e.g. base class) initializer.

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

2 years ago[clang][dataflow] Remove private-field filtering from `StorageLocation` creation.
Yitzhak Mandelbaum [Wed, 25 May 2022 17:57:27 +0000 (17:57 +0000)]
[clang][dataflow] Remove private-field filtering from `StorageLocation` creation.

The API for `AggregateStorageLocation` does not allow for missing fields (it asserts). Therefore, it is incorrect to filter out any fields at location-creation time which may be accessed by the code. Currently, we limit filtering to private, base-calss fields on the assumption that those can never be accessed. However, `friend` declarations can invalidate that assumption, thereby breaking our invariants.

This patch removes said field filtering to avoid violating the invariant of "no missing fields" for `AggregateStorageLocation`.

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

2 years ago[flang][OpenMP][NFC] Cleanup the sections tests
Shraiysh Vaishay [Fri, 27 May 2022 12:49:14 +0000 (18:19 +0530)]
[flang][OpenMP][NFC] Cleanup the sections tests

This patch cleans up the sections tests as per the recent effort to
separate integration tests from unit tests.

Reviewed By: kiranchandramohan, peixin

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

2 years agoAlso remove the empty StoredDeclsList entry from the lookup table
Vassil Vassilev [Fri, 27 May 2022 11:16:24 +0000 (11:16 +0000)]
Also remove the empty StoredDeclsList entry from the lookup table

In case where we have removed all declarations for a given declaration name
entry we should remove the whole StoredDeclsMap entry.

This patch improves consistency in the lookup tables and helps cling/clang-repl
error recovery.

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

2 years ago[mlir][llvm] Fix compiler error on GCC 9
Daniil Dudkin [Fri, 27 May 2022 12:33:02 +0000 (15:33 +0300)]
[mlir][llvm] Fix compiler error on GCC 9

This patch fixes the following compiler error:

    error: declaration of ‘mlir::LLVM::cconv::CConv mlir::LLVM::detail::CConvAttrStorage::CConv’ changes meaning of ‘CConv’ [-fpermissive]

CConv as a member variable name was shadowing CConv as an enumeration,
hence the compiler error.

Reviewed By: ftynse, alexbatashev

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

2 years ago[LLD][test] Update `zlib` tests for LLD commit c78c00dc16
Andrew Ng [Fri, 27 May 2022 11:02:36 +0000 (12:02 +0100)]
[LLD][test] Update `zlib` tests for LLD commit c78c00dc16

Updates for these tests were missed because I didn't have zlib-dev
installed and thus the tests were unsupported and not run.

2 years ago[flang] Support correct continuations for compiler directives
Daniil Dudkin [Fri, 27 May 2022 10:45:15 +0000 (13:45 +0300)]
[flang] Support correct continuations for compiler directives

If a line is over 72 characters long, flang's preprocessor cuts it there
and continues on the next line.
For this purpose it uses the standard way of continuing line with & on each line.
However, it doesn't work with long compiler directives, like OpenMP or OpenACC ones.
The line that continues the directive also has to
contain the corresponding sentinel at the beginning.

This change implements the described functionality.
Also, some code was refactored in order to simplify and reuse existing code.

Reviewed By: klausler

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

2 years ago[RISCV][NFC] Unify compatibility checks under one function
Fraser Cormack [Thu, 26 May 2022 14:11:02 +0000 (15:11 +0100)]
[RISCV][NFC] Unify compatibility checks under one function

Split off from D125021.

We were duplicating logic across different phases. Since we want to
ensure a consistency of logic across phases for correctness, this patch
combines our multiple compatibility checks into one function to better
convey this.

Several methods were made const too.

Reviewed By: reames

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

2 years ago[MLIR][Presburger] Add intersectDomain/Range to IntegerRelation
Groverkss [Fri, 27 May 2022 10:21:40 +0000 (15:51 +0530)]
[MLIR][Presburger] Add intersectDomain/Range to IntegerRelation

This patch adds support for intersection a set with a relation.

Reviewed By: arjunp

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

2 years ago[Doc][OpenCL] Misc wording improvements for SPIR-V
Anastasia Stulova [Fri, 27 May 2022 10:12:44 +0000 (11:12 +0100)]
[Doc][OpenCL] Misc wording improvements for SPIR-V

2 years ago[llvm-ar][test] add special case of replace converting a regular to a thin archive
Ben Dunbobbin [Fri, 27 May 2022 10:02:04 +0000 (11:02 +0100)]
[llvm-ar][test] add special case of replace converting a regular to a thin archive

Add a regression test for:
  https://github.com/llvm/llvm-project/issues/55527

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

2 years ago[LLD][ELF] Drop the string null terminator from the hash in splitStrings
Andrew Ng [Thu, 26 May 2022 15:03:09 +0000 (16:03 +0100)]
[LLD][ELF] Drop the string null terminator from the hash in splitStrings

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

2 years ago[mlir][Tablegen-LSP] Add support for a tracking definitions and references
River Riddle [Tue, 10 May 2022 17:23:57 +0000 (10:23 -0700)]
[mlir][Tablegen-LSP] Add support for a tracking definitions and references

This essentially builds an index for the parsed records and record values (fields).
This covers quite a few cases, but is limited by the currently lackluster location
tracking in tablegen. A followup will work on plumbing more locations through
tablegen, which should greatly improve what we can do here.

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

2 years ago[mlir][Tablegen-LSP] Add support for include file link and hover
River Riddle [Mon, 9 May 2022 22:22:12 +0000 (15:22 -0700)]
[mlir][Tablegen-LSP] Add support for include file link and hover

This allows for following links to include files. This support is effectively
identical to the logic in the PDLL language server, and code is shared as
much as possible.

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

2 years ago[mlir][Tablegen-LSP] Add support for a compilation database
River Riddle [Mon, 9 May 2022 22:05:03 +0000 (15:05 -0700)]
[mlir][Tablegen-LSP] Add support for a compilation database

This provides a format for externally specifying the include directories
for a source file. The format of the tablegen database is exactly the
same as that for PDLL, namely it includes the absolute source file name and
the set of include directories. The database format is shared to simplify
the infra, and also because the format itself is general enough to share. Even
if we desire to expand in the future to contain the actual compilation command,
nothing there is specific enough that we would need two different formats.

As with PDLL, support for generating the database is added to our mlir_tablegen
cmake command.

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

2 years ago[AArch64] Add support for FMA intrinsics to shouldSinkOperands.
Florian Hahn [Fri, 27 May 2022 09:37:02 +0000 (10:37 +0100)]
[AArch64] Add support for FMA intrinsics to shouldSinkOperands.

If the fma operates on a legal vector type, the indexed variants can be
used, if the second operand is a splat of a valid index.

Reviewed By: dmgreen

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