platform/upstream/llvm.git
2 years ago[InstCombine] add tests for icmp of sext i1; NFC
Sanjay Patel [Tue, 31 May 2022 15:02:43 +0000 (11:02 -0400)]
[InstCombine] add tests for icmp of sext i1; NFC

These are adapted from the zext tests added for D126171.

2 years ago[X86] Add test case for PR55648
Simon Pilgrim [Tue, 31 May 2022 16:21:34 +0000 (17:21 +0100)]
[X86] Add test case for PR55648

2 years ago[X86] LowerMINMAX - split v4i64 types on AVX1 targets (Issue #55648)
Simon Pilgrim [Tue, 31 May 2022 16:17:39 +0000 (17:17 +0100)]
[X86] LowerMINMAX - split v4i64 types on AVX1 targets (Issue #55648)

Originally we tried to use default expansion for v4i64 types to make it easier to concatenate the results back together, but this can cause infinite loop issues with existing VSELECT splitting code in narrowExtractedVectorSelect if we have other uses of the VSELECT results (e.g. reduction patterns).

To fix the infinite loop, this patch always splits MIN/MAX v4i64 nodes during lowering and I've added a TODO for combineConcatVectorOps to investigate when we can cheaply concatenate VSELECT/BLENDV nodes together.

Fixes #55648 - regression test case will be added in a follow up.

2 years ago[Clang][Docs] Fix typo in offload packager reference
Joseph Huber [Tue, 31 May 2022 16:27:15 +0000 (12:27 -0400)]
[Clang][Docs] Fix typo in offload packager reference

2 years ago[MLIR][Math] Improve docs (NFC)
lorenzo chelini [Mon, 30 May 2022 10:19:10 +0000 (12:19 +0200)]
[MLIR][Math] Improve docs (NFC)

Remove boilerplate examples and add a text at the dialect level to describe
what kind of operands the operations accept (i.e., scalar, tensor or vector).
Left a shorter sentence describing the input operands for each operation as
this redundancy is convenient when browsing the documentation using the
website.

Reviewed By: ftynse

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

2 years ago[Clang][Docs] Document the clang-offload-packager better
Joseph Huber [Tue, 31 May 2022 15:52:44 +0000 (11:52 -0400)]
[Clang][Docs] Document the clang-offload-packager better

Summary:
This patch adds more in-depth documentation to the
clang-offload-packacker's binary format. This format is used to create
fat binaries and link them.

2 years ago[clangd] Minor fixes to ExtractVariableTests missed in D124486
David Goldman [Tue, 31 May 2022 15:32:23 +0000 (11:32 -0400)]
[clangd] Minor fixes to ExtractVariableTests missed in D124486

2 years ago[flang] Support BIND(C) variable scope check
PeixinQiao [Tue, 31 May 2022 15:26:00 +0000 (23:26 +0800)]
[flang] Support BIND(C) variable scope check

As Fortran 2018 C819, a variable with the BIND attribute shall be declared
in the specification part of a module. Add the support for this check.

Reviewed By: klausler

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

2 years ago[Scalarizer] Regenerate test checks (NFC)
Nikita Popov [Tue, 31 May 2022 15:21:58 +0000 (17:21 +0200)]
[Scalarizer] Regenerate test checks (NFC)

2 years ago[PS5] Tweak dllexport test
Paul Robinson [Tue, 31 May 2022 15:21:10 +0000 (08:21 -0700)]
[PS5] Tweak dllexport test

Post-commit review pointed out that both PS4 and PS5 were using the
same -std argument, better to use different ones just in case.

2 years ago[AMDGPU] gfx11 Image instructions
Joe Nash [Thu, 12 May 2022 13:27:48 +0000 (09:27 -0400)]
[AMDGPU] gfx11 Image instructions

MC layer support for instructions in the MIMG encoding(Image
instructions).

Contributors:
Carl Ritson <carl.ritson@amd.com>

Patch 13/N for upstreaming of AMDGPU gfx11 architecture.

Depends on D125992

Reviewed By: rampitec, #amdgpu

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

2 years ago[clangd] ExtractVariable support for C and Objective-C
David Goldman [Tue, 26 Apr 2022 19:30:50 +0000 (15:30 -0400)]
[clangd] ExtractVariable support for C and Objective-C

- Use the expression's type for non-C++ as the variable type. This works
  well, but might not preserve the typedefs due to type
  canonicalization.

- Improve support for Objective-C property references which are
  represented using `ObjCPropertyRefExpr` and `BuiltinType::PseudoObject`.

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

2 years ago[X86] combineEXTRACT_SUBVECTOR - pull out repeated getVectorNumElements() calls....
Simon Pilgrim [Tue, 31 May 2022 15:13:41 +0000 (16:13 +0100)]
[X86] combineEXTRACT_SUBVECTOR - pull out repeated getVectorNumElements() calls. NFC.

2 years agoLangRef: fix bad indentation in allockind bullets
Augie Fackler [Tue, 31 May 2022 15:06:15 +0000 (11:06 -0400)]
LangRef: fix bad indentation in allockind bullets

2 years ago[Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp
Daniel McIntosh [Mon, 30 May 2022 17:13:29 +0000 (13:13 -0400)]
[Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp

The new tests in clang/test/Driver/modules.cpp added by D120540 will fail if the
toolchain getting tested doesn't support linking. This reduces the utility of
the test since we would like a failure of this test to reflect a problem with
modules. We should already have other tests that validate linking support.

Reviewed By: ChuanqiXu

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

2 years ago[AArch64] Remove references to Streaming SVE from target features.
Sander de Smalen [Wed, 18 May 2022 06:26:50 +0000 (07:26 +0100)]
[AArch64] Remove references to Streaming SVE from target features.

Following discussion on D120261 and D121208 it seems better to remove the
concept of Streaming SVE from the subtarget/assembler predicates and
instead reason about 'SVE' and 'SME' as its higher level features, rather
than trying to model this runtime mode through explicit feature flags.

This patch is largely NFC.

Reviewed By: paulwalker-arm, david-arm

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

2 years agoRevert "[Libomptarget] Add `leaf` attribute to `vprintf` declaration"
Joseph Huber [Tue, 31 May 2022 14:14:51 +0000 (10:14 -0400)]
Revert "[Libomptarget] Add `leaf` attribute to `vprintf` declaration"

This is preventing users from calling `printf` on NVPTX code. Revert for
now until there is a fix.

This reverts commit eda4ef3add4d25345e0b29580776f1576040c525.

2 years agoBuildLibCalls: infer allockind attributes on relevant functions
Augie Fackler [Tue, 29 Mar 2022 18:27:30 +0000 (14:27 -0400)]
BuildLibCalls: infer allockind attributes on relevant functions

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

2 years agoattributes: introduce allockind attr for describing allocator fn behavior
Augie Fackler [Tue, 29 Mar 2022 15:14:07 +0000 (11:14 -0400)]
attributes: introduce allockind attr for describing allocator fn behavior

I chose to encode the allockind information in a string constant because
otherwise we would get a bit of an explosion of keywords to deal with
the possible permutations of allocation function types.

I'm not sure that CodeGen.h is the correct place for this enum, but it
seemed to kind of match the UWTableKind enum so I put it in the same
place. Constructive suggestions on a better location most certainly
encouraged.

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

2 years ago[X86] narrowExtractedVectorSelect - don't peek through bitcasts to find source vector
Simon Pilgrim [Tue, 31 May 2022 13:57:10 +0000 (14:57 +0100)]
[X86] narrowExtractedVectorSelect - don't peek through bitcasts to find source vector

We don't seem to need this for any test coverage and it was making tracking of the uses() of the source vector more difficult

Noticed while investigating Issue #55648

2 years ago[InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)
Nikita Popov [Mon, 30 May 2022 15:09:40 +0000 (17:09 +0200)]
[InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)

When reassociating GEPs, we can only keep inbounds if both original
GEPs were inbounds, and their offsets have the same sign. For the
sake of simplicity, I only handle the case where both offsets are
non-negative here.

It would probably be fine to just not preserve inbounds at all here,
but as I don't see a compile-time impact for adding the
isKnownNonNegative() calls I went with this more conservative
approach.

Fixes https://github.com/llvm/llvm-project/issues/44206.

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

2 years ago[Clang] Always set opaque pointers mode
Nikita Popov [Tue, 31 May 2022 13:40:46 +0000 (15:40 +0200)]
[Clang] Always set opaque pointers mode

Always set the opaque pointers mode, to make sure that
-no-opaque-pointers continues working when the default on the LLVM
side is flipped.

2 years ago[X86] LowerTRUNCATE - avoid creating extract_subvector(bitcast(vec)) patterns
Simon Pilgrim [Tue, 31 May 2022 13:30:28 +0000 (14:30 +0100)]
[X86] LowerTRUNCATE - avoid creating extract_subvector(bitcast(vec)) patterns

We have a generic DAG combine to attempt to fold extract_subvector(bitcast(vec)) -> bitcast(extract_subvector(vec)) but if we create these patterns late in lowering then we often miss them.

Noticed while investigating Issue #55648 which gets caught in an infinite loop trying to split extract_subvector(bitcast(vselect()) patterns - this doesn't fix the issue yet but reduces the regressions from the WIP fix.

2 years ago[libc++abi][AIX] add personality and helper functions for the state table EH
Xing Xue [Tue, 31 May 2022 13:21:34 +0000 (09:21 -0400)]
[libc++abi][AIX] add personality and helper functions for the state table EH

Summary:
This patch adds the personality and helper functions for the state table based EH used by IBM legacy compilers xlC and xlclang++ on AIX.

 * A high level description of the state table based EH is provided in the code comments.

 * Function scan_state_tab() is added to scan the state table. It is invoked by the state table personality routine __xlcxx_personality_v0() and returns scan_results like scan_eh_tab() does.

 * A couple of EH helper functions used by xlC and xlclang++ generated code are also added, e.g., __xlc_catch_matchv2() which checks whether the thrown object matches the catch handler's exception type.

 * Debugging macros _LIBCXXABI_TRACE_STATETAB, _LIBCXXABI_TRACE_STATETAB0, and _LIBCXXABI_TRACING_STATETAB are added to dump state table scanning traces if environment variable LIBCXXABI_PRINT_STATTAB is set.

 * The state variable and state table data is the LSDA found from the traceback table of the function during unwinding.

Reviewed by: MaskRay, cebowleratibm, libc++abi

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

2 years ago[NFC] Change LoopVectorizationCostModel::useOrderedReductions() to be a const function.
Mel Chen [Tue, 31 May 2022 12:38:44 +0000 (05:38 -0700)]
[NFC] Change LoopVectorizationCostModel::useOrderedReductions() to be a const function.

Reviewed By: fhahn

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

2 years ago[InstCombine] Fix const folding of switches with default case
Danila Malyutin [Mon, 30 May 2022 13:30:49 +0000 (16:30 +0300)]
[InstCombine] Fix const folding of switches with default case

In case phi was in the default block it could lead to multi-edge.
Fixes #55721.

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

2 years ago[mlir][Bazel] Adjust BUILD.bazel file
Adrian Kuegel [Tue, 31 May 2022 11:35:49 +0000 (13:35 +0200)]
[mlir][Bazel] Adjust BUILD.bazel file

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpPythonBindingGen.cpp (NFC)
Mehdi Amini [Mon, 30 May 2022 14:44:00 +0000 (14:44 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpPythonBindingGen.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in SparseTensorUtils.cpp...
Mehdi Amini [Mon, 30 May 2022 13:56:16 +0000 (13:56 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in SparseTensorUtils.cpp (NFC)

2 years ago[bazel] Port 42c17073fcba
Benjamin Kramer [Tue, 31 May 2022 11:47:01 +0000 (13:47 +0200)]
[bazel] Port 42c17073fcba

2 years ago[AMDGPU][DOC][NFC] Add GFX90C and GFX940 assembler syntax description
Dmitry Preobrazhensky [Tue, 31 May 2022 11:29:06 +0000 (14:29 +0300)]
[AMDGPU][DOC][NFC] Add GFX90C and GFX940 assembler syntax description

2 years ago[mlir] Support import llvm intrinsics.
jacquesguan [Mon, 30 May 2022 09:38:33 +0000 (09:38 +0000)]
[mlir] Support import llvm intrinsics.

This patch supports to convert the llvm intrinsic to the corresponding op. It still leaves some intrinsics to be handled specially.

Reviewed By: ftynse

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

2 years ago[InstCombine] Fix inbounds preservation when merging GEPs (PR55722)
Nikita Popov [Tue, 31 May 2022 09:51:19 +0000 (11:51 +0200)]
[InstCombine] Fix inbounds preservation when merging GEPs (PR55722)

Even if the total offset is inbounds, we might represent it by first
performing a large negative offset and then a small positive one.
With inbounds semantics as currently specified, each offset must
be inbounds individually, not just the overall offset of the GEP.

Fix this by checking that the sign of all offsets is the same.

Fixes https://github.com/llvm/llvm-project/issues/55722.

2 years ago[Flang][OpenMP] Fix for unstructured regions in OpenMP constructs - 2
kiranchandramohan [Tue, 31 May 2022 09:25:00 +0000 (09:25 +0000)]
[Flang][OpenMP] Fix for unstructured regions in OpenMP constructs - 2

The following changes are made for OpenMP operations with unstructured region,
1. For combined constructs the outer operation is considered a structured
region and the inner one as the unstructured.
2. Added a condition to ensure that we create new blocks only once for nested
unstructured OpenMP constructs.

Tests are added for checking the structure of the CFG.

Note: This is part of upstreaming from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project. Code originally reviewed
at https://github.com/flang-compiler/f18-llvm-project/pull/1394.

Reviewed By: vdonaldson, shraiysh, peixin

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

2 years ago[RISCV][NFC] Adjust some comments in RISCVInsertVSETVLI
Fraser Cormack [Tue, 31 May 2022 09:12:30 +0000 (10:12 +0100)]
[RISCV][NFC] Adjust some comments in RISCVInsertVSETVLI

Capitalize the first letter of comments like the others, and a few other
tweaks.

2 years agoRevert "Round up zero-sized symbols to 1 byte in `.debug_aranges`."
Bjorn Pettersson [Tue, 31 May 2022 09:03:33 +0000 (11:03 +0200)]
Revert "Round up zero-sized symbols to 1 byte in `.debug_aranges`."

This reverts commit 256a52d9aac8a9e98fbfd6a3d91090bf127cef7d (and
also the follow-up commit 38eb4fe74b3843ab0d7fc1e that moved a test
case to a different directory).

As discussed in https://reviews.llvm.org/D126257 there is a suspicion
that something was wrong with this commit as text section range was
shortened to 1 byte rather than rounded up as shown in the
llvm/test/DebugInfo/X86/dwarf-aranges.ll test case.

2 years ago[AMDGPU][NFC] Refine defining the offset field for GFX10+ SMEM instructions.
Ivan Kosarev [Tue, 31 May 2022 08:54:11 +0000 (09:54 +0100)]
[AMDGPU][NFC] Refine defining the offset field for GFX10+ SMEM instructions.

Reviewed By: dp

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

2 years ago[AArch64] Look through copy in MachineCombiner FMUL patterns.
David Green [Tue, 31 May 2022 08:28:00 +0000 (09:28 +0100)]
[AArch64] Look through copy in MachineCombiner FMUL patterns.

This is a small addition to D99662, which added machine combiner
patterns for FMUL(DUP(..)). Due to the way these are generated from
ISel, they may also be FMUL(COPY(DUP(..))), which this patch now
ignores the no-op COPY in.

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

2 years ago[BOLT][NFC] Don't over-specify the size of SmallVector
Yi Kong [Tue, 31 May 2022 08:13:23 +0000 (16:13 +0800)]
[BOLT][NFC] Don't over-specify the size of SmallVector

This is the recommended way, should make merging profiles ever so
slightly faster.

2 years agoFix bazel build
Mikhail Goncharov [Tue, 31 May 2022 08:15:12 +0000 (10:15 +0200)]
Fix bazel build

After 1c2edb026ed67ddbb30ebe3e2d2f4f17a882a881

2 years ago[X86] Adjust vector test costs to match SoG (Issue #54889)
Simon Pilgrim [Tue, 31 May 2022 08:14:06 +0000 (09:14 +0100)]
[X86] Adjust vector test costs to match SoG (Issue #54889)

znver1/2 models were incorrectly modelling the latency/throughput/uops and znver1 ymm variants also require double pumping.

Now matches what I can decipher from the AMD SoG, Agner and instlatx64 numbers vs the llvm-exegesis report provided by @fabian-r

2 years ago[flang] Upstream the lowering of the while loop
Diana Picus [Wed, 25 May 2022 12:51:10 +0000 (12:51 +0000)]
[flang] Upstream the lowering of the while loop

Upstream the code for handling while loops from the fir-dev branch at
https://github.com/flang-compiler/f18-llvm-project/tree/fir-dev/

Also add tests.

The while loop is lowered to a header block that checks the loop
condition and branches either to the exit block or to the body of the
loop. The body of the loop will unconditionally branch back to the
header.

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years agoRevert "[clang-repl] Recover the lookup tables of the primary context."
Vassil Vassilev [Tue, 31 May 2022 06:24:24 +0000 (06:24 +0000)]
Revert "[clang-repl] Recover the lookup tables of the primary context."

This reverts commit 5ff27fe1ff03d5aeaf8567c97618170f0cef8f58.

This patch caused failures in asan: https://lab.llvm.org/buildbot/#/builders/5/builds/24221

2 years ago[Clang][CSKY] Add support about CSKYABIInfo
Zi Xuan Wu (Zeson) [Fri, 20 May 2022 03:59:17 +0000 (11:59 +0800)]
[Clang][CSKY] Add support about CSKYABIInfo

According to the CSKY ABIv2 document, https://github.com/c-sky/csky-doc/blob/master/C-SKY_V2_CPU_Applications_Binary_Interface_Standards_Manual.pdf
construct the ABIInfo to handle argument passing and return of clang data type. It also includes how to emit and expand VAArg intrinsic.

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

2 years ago[X86][NFC] Refine X86 Domain Reassignment for compiling time
Xiang1 Zhang [Mon, 30 May 2022 00:37:36 +0000 (08:37 +0800)]
[X86][NFC] Refine X86 Domain Reassignment for compiling time

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

2 years ago[mlir:PDLL] Rework the C++ generation of native Constraint/Rewrite arguments and...
River Riddle [Tue, 3 May 2022 02:24:53 +0000 (19:24 -0700)]
[mlir:PDLL] Rework the C++ generation of native Constraint/Rewrite arguments and results

The current translation uses the old "ugly"/"raw" form which used PDLValue for the arguments
and results. This commit updates the C++ generation to use the recently added sugar that
allows for directly using the desired types for the arguments and result of PDL functions.
In addition, this commit also properly imports the C++ class for ODS operations, constraints,
and interfaces. This allows for a much more convienent C++ API than previously granted
with the raw/low-level types.

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

2 years ago[mlir:PDLL] Fix signature help for operation operands
River Riddle [Sat, 30 Apr 2022 07:32:24 +0000 (00:32 -0700)]
[mlir:PDLL] Fix signature help for operation operands

We were currently only completing on the first operand because
the completion check was outside of the parse loop.

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

2 years ago[mlir:PDLL-LSP] Add a custom LSP command for viewing the output of PDLL
River Riddle [Sat, 30 Apr 2022 07:29:49 +0000 (00:29 -0700)]
[mlir:PDLL-LSP] Add a custom LSP command for viewing the output of PDLL

This commit adds a new PDLL specific LSP command, pdll.viewOutput, that
allows for viewing the intermediate outputs of a given PDLL file. The available
intermediate forms currently mirror those in mlir-pdll, namely: AST, MLIR, CPP.
This is extremely useful for a developer of PDLL, as it simplifies various testing,
and is also quite useful for users as they can easily view what is actually being
generated for their PDLL files.

This new command is added to the vscode client, and is available in the right
client context menu of PDLL files, or via the vscode command palette.

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

2 years ago[mlir:PDLL] Add proper support for operation result type inference
River Riddle [Sat, 30 Apr 2022 04:13:29 +0000 (21:13 -0700)]
[mlir:PDLL] Add proper support for operation result type inference

This allows for the results of operations to be inferred in certain contexts,
and matches the support in PDL for result type inference. The main two
initial circumstances are when used as a replacement of another operation,
or when the operation being created implements InferTypeOpInterface.

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

2 years ago[RISCV] Pass OptLevel to `RISCVDAGToDAGISel` correctly
eopXD [Mon, 30 May 2022 12:06:48 +0000 (05:06 -0700)]
[RISCV] Pass OptLevel to `RISCVDAGToDAGISel` correctly

Originally, `OptLevel` isn't passed into the `MachineFunctionPass`.
This lets the default parameter of `SelectionDAGISel`, which is
`CodeGenOpt::Default`, be passed in. OptLevelChanger captures the
optimization level with the parameter, and rather not the value
within `TargetMachine`. This lets the optimization be
unintentionally overwriten if other value than `CodeGenOpt::Default`
passed.

This patch fixes this by passing the optimization level rather
than using the default value.

Reviewed By: craig.topper

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

2 years ago[libc++][test] Enable some ADL robust algorithm tests
Joe Loser [Mon, 30 May 2022 17:59:51 +0000 (11:59 -0600)]
[libc++][test] Enable some ADL robust algorithm tests

Some algorithm ADL robustness tests are commented out, but work as is. Uncomment
them.

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

2 years ago[RISCV] Precommit test case to show bug in RISCVISelDagToDag
eopXD [Mon, 30 May 2022 20:40:06 +0000 (13:40 -0700)]
[RISCV] Precommit test case to show bug in RISCVISelDagToDag

The optimization level should not be restored into O2.
This is a pre-commit test case to show fix in D126641.

Reviewed By: craig.topper

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

2 years ago[clang] NFC: introduce test for D126620
Matheus Izvekov [Mon, 30 May 2022 18:54:48 +0000 (20:54 +0200)]
[clang] NFC: introduce test for D126620

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

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

2 years agocompiler-rt/cpu_model: Ensure constructor priority is set and align with GCC
Keno Fischer [Wed, 25 May 2022 21:35:01 +0000 (21:35 +0000)]
compiler-rt/cpu_model: Ensure constructor priority is set and align with GCC

GCC recently started setting constructor priority on init_have_lse_atomics [1]
to avoid undefined initialization order with respect to other initializers,
causing accidental use of ll/sc intrinsics on targets where this was not
intended (which presents a minor performance problem as well as a
compatibility problem for users wanting to use the rr debugger). I initially
thought compiler-rt does not have the same issue as libgcc, since it looks
like we're already setting init priority on the constructor.

Unfortuantely, it does not appear that the HAVE_INIT_PRIORITY check is ever
performed anyway, so despite appearances the init priority was not actually
applied. Fix that by applying the init priority unconditionally. It has been
supported in clang ever since it was first introduced and in any case for
more than 14 years in both gcc and clang. MSVC is already excluded from this
code path and we're already using constructors with init priority elsewhere
in compiler-rt without additional check (though mostly in the sanitizer
runtime, which may have more narrow target support). Regardless, I believe
that for our supported compilers, if they support the constructor attribute,
they should also support init priorities.

While we're here, change the init priority from 101, which is the highest
priority for end user applications, to instead use one of the priority levels
reserved for implementations (1-100; lower integers are higher priority).
GCC ended up using `90`, so this commit aligns the value in compiler-rt
to the same value to ensure that there are no subtle initialization order
differences between libgcc and compiler-rt.

[1] https://github.com/gcc-mirror/gcc/commit/75c4e4909ae2667f56487434f99c2915b4570794

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

2 years ago[FileCheck] Use %ProtectFileCheckOutput in recently added test
Joel E. Denny [Mon, 30 May 2022 20:26:17 +0000 (16:26 -0400)]
[FileCheck] Use %ProtectFileCheckOutput in recently added test

2 years ago[libc++][NFC] Improve comment about vector and string base class ABI flags
Louis Dionne [Mon, 30 May 2022 20:26:33 +0000 (16:26 -0400)]
[libc++][NFC] Improve comment about vector and string base class ABI flags

2 years ago[Hexagon] Widen vector types with non-power-of-2 element counts
Krzysztof Parzyszek [Mon, 30 May 2022 19:14:59 +0000 (12:14 -0700)]
[Hexagon] Widen vector types with non-power-of-2 element counts

Such vector types cannot be split at the moment, because splitting expects
an even number of elements in the source type. If a target marks such a type
as "split", TargetLoweringBase::computeRegisterProperties will override it
with widening to the next power of 2. This could lead to issues during
instruction selection when conflicting information about how to handle this
type is present.

2 years agocmake: fix clang standalone build
Matheus Izvekov [Mon, 30 May 2022 18:33:50 +0000 (20:33 +0200)]
cmake: fix clang standalone build

D126308 broke building clang standalone, as LLVM_UTILS_INSTALL_DIR is
not exported.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D126671

2 years ago[InstCombine] fold shift-right-by-constant with shift-right-of-constant operand
Sanjay Patel [Mon, 30 May 2022 19:30:01 +0000 (15:30 -0400)]
[InstCombine] fold shift-right-by-constant with shift-right-of-constant operand

  (C2 >> X) >> C1 --> (C2 >> C1) >> X

The shift-left form of this transform has existed since:
16f18ed7b555bce5163

...but it applies to matching shift right opcodes too:
https://alive2.llvm.org/ce/z/c5eQms

2 years ago[InstCombine] remove unnecessary one-use check from (C2 << X) << C1 fold
Sanjay Patel [Mon, 30 May 2022 19:15:27 +0000 (15:15 -0400)]
[InstCombine] remove unnecessary one-use check from (C2 << X) << C1 fold

The restriction goes back to:
16f18ed7b555bce51
...but the fold only replaces a shift with a shift, so that's not necessary.
Generalizing to other opcodes is planned as a follow-up.

2 years ago[InstCombine] add/move tests for shift-of-constant-by-same-shift-by-constant; NFC
Sanjay Patel [Mon, 30 May 2022 18:04:56 +0000 (14:04 -0400)]
[InstCombine] add/move tests for shift-of-constant-by-same-shift-by-constant; NFC

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in OneShotModuleBuffer...
Mehdi Amini [Mon, 30 May 2022 13:18:19 +0000 (13:18 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in OneShotModuleBufferize.cpp (NFC)

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpenMPToLLVM.cpp (NFC)
Mehdi Amini [Mon, 30 May 2022 12:59:27 +0000 (12:59 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpenMPToLLVM.cpp (NFC)

2 years agofix tests after my commit 80b3dcc045f8ea6e5e532d8891bbf1305bce89e8
Nuno Lopes [Mon, 30 May 2022 18:44:06 +0000 (19:44 +0100)]
fix tests after my commit 80b3dcc045f8ea6e5e532d8891bbf1305bce89e8
 doesn't like exit code 126 I'm afraid

2 years ago[Support] Make report_fatal_error respect its GenCrashDiag argument so it doesn't...
Nuno Lopes [Mon, 30 May 2022 18:16:06 +0000 (19:16 +0100)]
[Support] Make report_fatal_error respect its GenCrashDiag argument so it doesn't generate a backtrace

There are a few places where we use report_fatal_error when the input is broken.
Currently, this function always crashes LLVM with an abort signal, which
then triggers the backtrace printing code.
I think this is excessive, as wrong input shouldn't give a link to
LLVM's github issue URL and tell users to file a bug report.
We shouldn't print a stack trace either.

This patch changes report_fatal_error so it uses exit() rather than
abort() when its argument GenCrashDiag=false.

Reviewed by: nikic, MaskRay, RKSimon

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

2 years agoRevert "[HLSL] Enable vector types for hlsl."
Nico Weber [Mon, 30 May 2022 18:10:21 +0000 (14:10 -0400)]
Revert "[HLSL] Enable vector types for hlsl."

This reverts commit e576280380d3f5221cfcc14e9fabeacc8506a43c.
Breaks tests on mac/arm, see comment on https://reviews.llvm.org/D125052

Also revert follow-up "[gn build] Port e576280380d3"
This reverts commit 1e01b1ec72031fcaceb4e77e1c5c8e34f1e862e8.

2 years ago[VPlan] Add test for printing VPlan for outer loop vectorization.
Florian Hahn [Mon, 30 May 2022 17:19:32 +0000 (18:19 +0100)]
[VPlan] Add test for printing VPlan for outer loop vectorization.

Test coverage for D123005.

2 years ago[ODRHash][NFC] Add missing 'select' case for `ODRMismatchDecl`.
Volodymyr Sapsai [Fri, 27 May 2022 21:05:12 +0000 (14:05 -0700)]
[ODRHash][NFC] Add missing 'select' case for `ODRMismatchDecl`.

No test changes because `err_module_odr_violation_mismatch_decl_unknown`
is a catch-all when custom diagnostic is missing. And missing custom
diagnostic we should fix by implementing it, not by improving the
general case. But if we pass enum value not covered by 'select', clang
can crash, so protect against that.

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

2 years agoFix warning for unused variable in the non-assert build (NFC)
Mehdi Amini [Mon, 30 May 2022 16:21:38 +0000 (16:21 +0000)]
Fix warning for unused variable in the non-assert build (NFC)

2 years ago[gn build] Port e576280380d3
LLVM GN Syncbot [Mon, 30 May 2022 16:11:40 +0000 (16:11 +0000)]
[gn build] Port e576280380d3

2 years ago[TwoAddressInstructionPass] Special processing of STATEPOINT instruction.
Denis Antrushin [Sun, 10 Apr 2022 08:31:31 +0000 (15:31 +0700)]
[TwoAddressInstructionPass] Special processing of STATEPOINT instruction.

STATEPOINT is a special pseudo instruction which represent Moving GC semantic to LLVM.
Every tied def/use VReg pair in STATEPOINT represent same physical register which can
'magically' change during call wrapped by statepoint.
(By construction, tied use operand  is not live across  STATEPOINT).

This means that when converting into two-address form, there is not need to insert COPY
instruction before stateppoint, what TwoAddressInstruction pass does for 'regular'
instructions.

Reviewed By: MatzeB

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

2 years ago[HLSL] Enable vector types for hlsl.
Xiang Li [Thu, 5 May 2022 22:31:22 +0000 (15:31 -0700)]
[HLSL] Enable vector types for hlsl.

Vector types in hlsl is using clang ext_vector_type.
Declaration of vector types is in builtin header hlsl.h.
hlsl.h will be included by default for hlsl shader.

Reviewed By: Anastasia

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

2 years ago[libc++] Reduce the verbosity when running the libc++ Lit configuration
Louis Dionne [Mon, 30 May 2022 15:06:19 +0000 (11:06 -0400)]
[libc++] Reduce the verbosity when running the libc++ Lit configuration

We print the same information as before, however we do it with less
verbosity unless `--debug` is used.

2 years ago[sanitizers] Fixes strndup API behaviour when intercepted by sanitizers
Pierre Gousseau [Mon, 30 May 2022 16:00:10 +0000 (17:00 +0100)]
[sanitizers] Fixes strndup API behaviour when intercepted by sanitizers

Sanitizers ignore flag allocator_may_return_null=1 in strndup() calls.
When OOM is emulated, this causes to the unexpected crash.

Committed by pgousseau on behalf of "Kostyantyn Melnik, kmnls.kmnls@gmail.com"

Reviewed by: pgousseau

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

2 years ago[mlir] provide Python bindings for the Transform dialect
Alex Zinenko [Mon, 30 May 2022 13:14:02 +0000 (15:14 +0200)]
[mlir] provide Python bindings for the Transform dialect

Python bindings for extensions of the Transform dialect are defined in separate
Python source files that can be imported on-demand, i.e., that are not imported
with the "main" transform dialect. This requires a minor addition to the
ODS-based bindings generator. This approach is consistent with the current
model for downstream projects that are expected to bundle MLIR Python bindings:
such projects can include their custom extensions into the bundle similarly to
how they include their dialects.

Reviewed By: nicolasvasilache

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

2 years ago[mlir] add VectorizeOp to structured transform ops
Alex Zinenko [Mon, 30 May 2022 13:13:23 +0000 (15:13 +0200)]
[mlir] add VectorizeOp to structured transform ops

Vectorization is a key transformation to achieve high performance on most
architectures. In the transform dialect, vectorization is implemented as a
parameterizable transform op. It currently applies to a scope of payload IR
delimited by some isolated-from-above op, mainly because several enabling
transformations (such as affine simplification) are needed to perform
vectorization and these transformation would apply to ops other than the "main"
computational payload op. A separate "navigation" transform op that obtains the
isolated-from-above ancestor of an op is introduced in the core transform
dialect. Even though it is currently only useful for vectorization,
isolated-from-above ops are a common anchor for transformations (usually
implemented as passes) that is likely to be reused in the future.

Depends On D126374

Reviewed By: nicolasvasilache

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

2 years agoChange build_llvm_package.bat to build_llvm_release.bat
Hans Wennborg [Mon, 30 May 2022 15:06:41 +0000 (17:06 +0200)]
Change build_llvm_package.bat to build_llvm_release.bat

We don't build snapshot packages anymore, so repurpose this
for doing release builds instead.

2 years ago[InstCombine] When swapping GEPs, only keep inbounds if both are
Nikita Popov [Mon, 30 May 2022 14:52:11 +0000 (16:52 +0200)]
[InstCombine] When swapping GEPs, only keep inbounds if both are

If only one of the GEPs is inbounds, then after swapping, there is
no guarantee that one of them will be inbounds as well
(see e.g. https://alive2.llvm.org/ce/z/agaCnp).

This is only a partial fix, because even if both are inbounds, the
result is not necessarily inbounds (if the offsets have different
signs).

2 years ago[OpenMP][Clang] Fix atomic compare for signed vs. unsigned
Joel E. Denny [Mon, 30 May 2022 15:01:10 +0000 (11:01 -0400)]
[OpenMP][Clang] Fix atomic compare for signed vs. unsigned

Without this patch, arguments to the
`llvm::OpenMPIRBuilder::AtomicOpValue` initializer are reversed.

Reviewed By: ABataev, tianshilei1992

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

2 years ago[flang][OpenMP] Check for occurrence of multiple list items in nontemporal clause...
Arnamoy Bhattacharyya [Mon, 30 May 2022 14:10:54 +0000 (10:10 -0400)]
[flang][OpenMP] Check for occurrence of multiple list items in nontemporal clause for simd directive

This patch implements the following semantic check:

A list-item cannot appear in more than one nontemporal clause.

Reviewed By: kiranchandramohan, shraiysh

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

2 years ago[InstCombine] Always create new GEPs when swapping GEPs
Nikita Popov [Mon, 30 May 2022 14:46:53 +0000 (16:46 +0200)]
[InstCombine] Always create new GEPs when swapping GEPs

As the long explanatory comment attests, performing the modification
in place is pretty tricky. Drop this unnecessary complexity and
always create new instructions.

This should be NFC-ish, but can probably cause difference due to
worklist order.

2 years ago[InstCombine] Add tests for inbounds handling in loop invariant GEP fold (NFC)
Nikita Popov [Mon, 30 May 2022 14:40:18 +0000 (16:40 +0200)]
[InstCombine] Add tests for inbounds handling in loop invariant GEP fold (NFC)

2 years ago[Local] Don't remove invoke of non-willreturn function
Nikita Popov [Mon, 30 May 2022 13:37:46 +0000 (15:37 +0200)]
[Local] Don't remove invoke of non-willreturn function

The code was only checking for memory side-effects, but not for
divergence side-effects. Replace this with a generic check.

2 years ago[SimplifyCFG] Add test for invoke of nounwind non-willreturn function (NFC)
Nikita Popov [Mon, 30 May 2022 13:33:23 +0000 (15:33 +0200)]
[SimplifyCFG] Add test for invoke of nounwind non-willreturn function (NFC)

Test both the case with and without willreturn attribute.

2 years agoRevert "[clang][test] mark tests added in ee8524087c78 as unsupported on AIX"
Jake Egan [Mon, 30 May 2022 13:33:10 +0000 (09:33 -0400)]
Revert "[clang][test] mark tests added in ee8524087c78 as unsupported on AIX"

The tests pass now on a clean build.

This reverts commit 1b34f1e996565bc5e4f2be14b89f881f8fe0f3b9.

2 years ago[InstCombine] Fold a mul with bool value into and
zhongyunde [Mon, 30 May 2022 13:04:40 +0000 (21:04 +0800)]
[InstCombine] Fold a mul with bool value into and

Fixes https://github.com/llvm/llvm-project/issues/55599
  X * Y --> X & Y, iff X, Y can be only {0, 1}.
https://alive2.llvm.org/ce/z/_RsTKF

Reviewed By: spatel, nikic

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

2 years agoRe-land "[VP] vp intrinsics are not speculatable" with test fix
Simon Moll [Mon, 30 May 2022 12:38:59 +0000 (14:38 +0200)]
Re-land "[VP] vp intrinsics are not speculatable" with test fix

Update the llvmir-intrinsics.mlir test to account for the modified
attribute sets.

This reverts commit 2e2a8a2d9082250e4aad312c6008a526f2b007c7.

2 years agoRevert "[VP] vp intrinsics are not speculatable"
Mehdi Amini [Mon, 30 May 2022 12:26:16 +0000 (12:26 +0000)]
Revert "[VP] vp intrinsics are not speculatable"

This reverts commit 78a18d2b54e7e8e0e2c1d1cb33d015d7f69b8cc7.

Break MLIR bot: https://lab.llvm.org/buildbot/#/builders/61/builds/27127

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpPythonBindingGen.cpp (NFC)
Mehdi Amini [Tue, 24 May 2022 01:28:57 +0000 (01:28 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpPythonBindingGen.cpp (NFC)

2 years agoApply clang-tidy fixes for modernize-use-override in SparseTensorUtils.cpp (NFC)
Mehdi Amini [Tue, 24 May 2022 00:41:23 +0000 (00:41 +0000)]
Apply clang-tidy fixes for modernize-use-override in SparseTensorUtils.cpp (NFC)

2 years agoRevert "build_llvm_package.bat: Produce zip files in addition to the installers"
Hans Wennborg [Mon, 30 May 2022 11:55:54 +0000 (13:55 +0200)]
Revert "build_llvm_package.bat: Produce zip files in addition to the installers"

The zip files were too large to be practical, so they were never
shipped. Reverting to reduce build time and complexity of the script.

This reverts commit 4486aa03c5f431ba33a1d1ac9991da912e3decd9.

2 years ago[OpenMP] Pass chunk-size to MLIR while lowering from parse-tree
Mats Petersson [Mon, 22 Mar 2021 15:28:31 +0000 (15:28 +0000)]
[OpenMP] Pass chunk-size to MLIR while lowering from parse-tree

Test that chunk size is passed to the static init function.
Using three different variations:
1. Single constant.
2. Expression with constants.
3. Variable value.

Reviewed By: peixin, shraiysh

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

2 years ago[MemDep][NFC] Remove duplicating check in `if` and `else` branch
Max Kazantsev [Mon, 30 May 2022 10:28:33 +0000 (17:28 +0700)]
[MemDep][NFC] Remove duplicating check in `if` and `else` branch

Same check is done whether the condition is true or false. Just hoist
it out of conditional.

2 years ago[VP] vp intrinsics are not speculatable
Simon Moll [Mon, 30 May 2022 10:19:48 +0000 (12:19 +0200)]
[VP] vp intrinsics are not speculatable

VP intrinsics show UB if the %evl parameter is out of bounds - they must
not carry the speculatable attribute.  The out-of-bounds UB disappears
when the %evl parameter is expanded into the mask or expansion replaces
the entire VP intrinsic with non-VP code.

This patch
- Removes the speculatable attribute on all VP intrinsics.
- Generalizes the isSafeToSpeculativelyExecute function to let VP
  expansion know whether the VP intrinsic replacement will be
  speculatable.  VP expansion may only discard %evl where this is the
  case.

Reviewed By: frasercrmck

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

2 years ago[MemDep][NFCI] Remove redundant dyn_cast, replace with cast
Max Kazantsev [Mon, 30 May 2022 10:16:42 +0000 (17:16 +0700)]
[MemDep][NFCI] Remove redundant dyn_cast, replace with cast

When `IsLoad` is `true`, we don't need to check if the instruction
is actually a load with dyn_cast. Saves some petty amount of CT.

2 years agoUpdate the Windows packaging script
Hans Wennborg [Mon, 30 May 2022 09:51:28 +0000 (11:51 +0200)]
Update the Windows packaging script

Check in updates based on how the latest release was built [0] and add
the bug fix from [1] which allows LLDB to start.

Other changes which had accumulated in the local release script:
- Don't build the clang format plugin (VS has the functionality built
  in now)
- Disable tests that have been failing (I'll try to follow up and
  re-enable them)
- Switch to Python 3.10
- Jump through more hoops to make LLDB pick the right Python.

0. https://discourse.llvm.org/t/14-0-4-final-has-been-tagged/62750/3
1. https://github.com/llvm/llvm-project/issues/54589

2 years agoTest stackmap support for floating point types.
Edd Barrett [Mon, 30 May 2022 09:18:22 +0000 (10:18 +0100)]
Test stackmap support for floating point types.

It appears that float support is complete, or at least, the stackmap records
emitted are not inconceivable (I must admit that I don't know about many of the
architectures under test here).

One curiosity, the SystemZ tests highlight an undocumented (or maybe incorrect)
quirk of the stackmap format: in the case of a Register record, the Offset or
SmallConstant field can encode a sub-register index! I've only ever seen this
field zero for Register entries up until now.

2 years ago[OpenCL] Expose wg collective functions for CL3 SPIR targets
Sven van Haastregt [Mon, 30 May 2022 09:48:49 +0000 (10:48 +0100)]
[OpenCL] Expose wg collective functions for CL3 SPIR targets

Since the SPIR/SPIR-V targets enable all known features, we must
ensure the Work-group Collective Functions feature macro is set for
OpenCL 3.0.

Fixes https://github.com/llvm/llvm-project/issues/55770

2 years ago[AArch64] Tests for showing MachineCombiner COPY patterns. NFC
David Green [Mon, 30 May 2022 09:47:44 +0000 (10:47 +0100)]
[AArch64] Tests for showing MachineCombiner COPY patterns. NFC

2 years ago[mlir] add interchange, pad and scalarize to structured transform dialect
Alex Zinenko [Tue, 24 May 2022 16:25:57 +0000 (18:25 +0200)]
[mlir] add interchange, pad and scalarize to structured transform dialect

Add ops to the structured transform extension of the transform dialect that
perform interchange, padding and scalarization on structured ops. Along with
tiling that is already defined, this provides a minimal set of transformations
necessary to build vectorizable code for a single structured op.

Define two helper traits: one that implements TransformOpInterface by applying
a function to each payload op independently and another that provides a simple
"functional-style" producer/consumer list of memory effects for the transform
ops.

Reviewed By: nicolasvasilache

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