platform/upstream/llvm.git
2 years ago[analyzer][NFC] Inline ExprEngine::evalComplement
Balazs Benics [Fri, 27 May 2022 08:07:06 +0000 (10:07 +0200)]
[analyzer][NFC] Inline ExprEngine::evalComplement

Reviewed By: martong

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

2 years ago[mlir-vscode] Add support for highlighting pdll and tablegen markdown code blocks
River Riddle [Mon, 16 May 2022 23:52:49 +0000 (16:52 -0700)]
[mlir-vscode] Add support for highlighting pdll and tablegen markdown code blocks

This essentially just piggy backs off of the existing mlir support.

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

2 years ago[GlobalISel] Add G_IS_FPCLASS
Serge Pavlov [Fri, 11 Mar 2022 07:40:44 +0000 (14:40 +0700)]
[GlobalISel] Add G_IS_FPCLASS

Add a generic opcode to represent `llvm.is_fpclass` intrinsic.

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

2 years ago[mlir][LLVM] Add support for Calling Convention in LLVMFuncOp
Alexander Batashev [Fri, 27 May 2022 06:23:27 +0000 (09:23 +0300)]
[mlir][LLVM] Add support for Calling Convention in LLVMFuncOp

This patch adds support for Calling Convention attribute in LLVM
dialect, including enums, custom syntax and import from LLVM IR.
Additionally fix import of dso_local attribute.

Reviewed By: ftynse

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

2 years ago[RISCV] Add test for experimental.vector.reverse
Liqin.Weng [Fri, 27 May 2022 06:27:26 +0000 (06:27 +0000)]
[RISCV] Add test for experimental.vector.reverse

```
void vector_reverse_i64(int *A, int *B, int n) {
  #pragma clang loop vectorize_width(4, scalable)
  for (int i = n-1; i >= 0; i--)
    A[i] = B[i] + 1;
}
```
When option: scalable-vectorization is on (or set #pragma clang loop vectorize_width(elements, scalable)), Reverse Iterators can't loop vectorization as <vscale x elements x elementType>

Reviewed By: craig.topper

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

2 years ago[libunwind][CMake] Fix name of LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG
Pavel Samolysov [Thu, 26 May 2022 14:03:08 +0000 (17:03 +0300)]
[libunwind][CMake] Fix name of LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG

The CMake variable LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG has been renamed
into C_SUPPORTS_NODEFAULTLIBS_FLAG because the last one is used in the
confix-ix.cmake file while the variable with the original name is not used
at al.

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

2 years ago[demangler][RISCV] Fix for long double
Piggy NL [Thu, 26 May 2022 14:59:49 +0000 (22:59 +0800)]
[demangler][RISCV] Fix for long double

Summary:
The size of long double in RISCV (both RV32 and RV64) is 16 bytes, thus
the mangled_size shouble be 32.

This patch will fix test case
"_ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c"
in test_demangle.pass.cpp, which is expected to be invalid but demangler
returned "void test0::h<float>(char (&) [(unsigned int)((sizeof (float))
+ (0x0.000000004001ap-16382L))])" in RISCV environment without this patch.

Reviewed By: urnathan

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

2 years ago[SelectionDAG][NFC] Simplify integer promotion in setcc/vp.setcc
Ping Deng [Fri, 27 May 2022 05:45:17 +0000 (05:45 +0000)]
[SelectionDAG][NFC] Simplify integer promotion in setcc/vp.setcc

Reviewed By: craig.topper

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

2 years ago[libc] Add global stdout and stderr objects.
Siva Chandra Reddy [Tue, 24 May 2022 08:13:11 +0000 (08:13 +0000)]
[libc] Add global stdout and stderr objects.

They are added as entrypoint object targets. The header-gen
infrastructure has been extended to enable handling standard required
global objects. The libc-api-test has also been extended to verify the
global object declarations.

Reviewed By: lntue

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

2 years ago[gn build] Port 08cc05851872
LLVM GN Syncbot [Fri, 27 May 2022 02:54:55 +0000 (02:54 +0000)]
[gn build] Port 08cc05851872

2 years agoReland "[Propeller] Promote functions with propeller profiles to .text.hot."
Rahman Lavaee [Fri, 27 May 2022 02:27:05 +0000 (19:27 -0700)]
Reland "[Propeller] Promote functions with propeller profiles to .text.hot."

This relands commit 4d8d2580c53e130c3c3dd3877384301e3c495554.

The major change here is using 'addUsedIfAvailable<BasicBlockSectionsProfileReader>()` to make sure we don't change the pipeline tests.

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

2 years ago[InstCombine] [NFC] precommit tests for bitcast-extelt
Chenbing Zheng [Fri, 27 May 2022 02:50:30 +0000 (10:50 +0800)]
[InstCombine] [NFC] precommit tests for bitcast-extelt

2 years ago[X86][AMX] Update test case with automation tool.
Luo, Yuanke [Fri, 27 May 2022 02:35:05 +0000 (10:35 +0800)]
[X86][AMX] Update test case with automation tool.

2 years ago[mlir][Linalg] Relax vectorization condition to allow transposed output.
Hanhan Wang [Fri, 27 May 2022 02:20:36 +0000 (19:20 -0700)]
[mlir][Linalg] Relax vectorization condition to allow transposed output.

Reviewed By: ThomasRaoux, dcaballe

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

2 years agoAdd !nosanitize to FixedMetadataKinds
Enna1 [Fri, 27 May 2022 01:39:04 +0000 (09:39 +0800)]
Add !nosanitize to FixedMetadataKinds

This patch adds !nosanitize metadata to FixedMetadataKinds.def, !nosanitize indicates that LLVM should not insert any sanitizer instrumentation.

Reviewed By: vitalybuka

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

2 years agoRevert "[Propeller] Promote functions with propeller profiles to .text.hot."
Rahman Lavaee [Fri, 27 May 2022 01:43:58 +0000 (18:43 -0700)]
Revert "[Propeller] Promote functions with propeller profiles to .text.hot."

This reverts commit 4d8d2580c53e130c3c3dd3877384301e3c495554.

2 years ago[RISCV] Simplify code after D125905
Fangrui Song [Fri, 27 May 2022 01:13:38 +0000 (18:13 -0700)]
[RISCV] Simplify code after D125905

2 years ago[mlir][sparse] Moving some functions around
wren romano [Thu, 26 May 2022 19:38:58 +0000 (12:38 -0700)]
[mlir][sparse] Moving some functions around

This is a followup to D126105 to move functions in SparseTensorUtils.cpp to match their locations in SparseTensorUtils.h

Reviewed By: aartbik

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

2 years ago[mlir][sparse] Improving ExecutionEngine/SparseTensorUtils.h
wren romano [Thu, 26 May 2022 19:31:58 +0000 (12:31 -0700)]
[mlir][sparse] Improving ExecutionEngine/SparseTensorUtils.h

This change makes the public API of SparseTensorUtils.cpp explicit, whereas before the publicity of these functions was only implicit.  Implicit publicity is sufficient for mlir-opt to generate calls to these functions, but it's not enough to enable C/C++ code to call them directly in the usual way (i.e., without going through codegen).  Thus, leaving the publicity implicit prevents development of other tools (e.g., microbenchmarks).

In addition this change also marks the functions MLIR_CRUNNERUTILS_EXPORT, which is required by the JIT under certain configurations (albeit not for anything in our test suite).

Reviewed By: aartbik

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

2 years ago[test/ClangScanDeps] Add a target triple for `macro-expansions.cpp`
Argyrios Kyrtzidis [Fri, 27 May 2022 00:18:32 +0000 (17:18 -0700)]
[test/ClangScanDeps] Add a target triple for `macro-expansions.cpp`

This should fix the `clang-ppc64-aix` builder.

2 years ago[lldb/fuzzer] Moving target fuzzer into separate subdirectory
Chelsea Cassanova [Thu, 26 May 2022 23:57:57 +0000 (16:57 -0700)]
[lldb/fuzzer] Moving target fuzzer into separate subdirectory

Moving lldb-target-fuzzer into its own subdirectory for better
organization and modularity.

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

2 years ago[flang] expand the this_image test coverage
Damian Rouson [Thu, 31 Mar 2022 20:55:43 +0000 (13:55 -0700)]
[flang] expand the this_image test coverage

Add a test with a range of this_image() intrinsic function
invocations, including a comprehensive set of standard-conforming
keyword and non-keyword arguments with and without optional
arguments present and with argument positions covering all
possible orderings.  Also test that several non-conforming
this_image() invocations generate the correct error messages.

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

2 years ago[Propeller] Promote functions with propeller profiles to .text.hot.
Rahman Lavaee [Tue, 24 May 2022 17:54:36 +0000 (10:54 -0700)]
[Propeller] Promote functions with propeller profiles to .text.hot.

Today, text section prefixes (none, .unlikely, .hot, and .unkown) are determined based on PGO profile. However, Propeller may deem a function hot when PGO doesn't. Besides, when `-Wl,-keep-text-section-prefix=true` Propeller cannot enforce a global section ordering as the linker can only reorder sections within each output section (.text, .text.hot, .text.unlikely).

This patch promotes all functions with Propeller profiles (functions listed in the basic-block-sections profile) to .text.hot. The feature is hidden behind the flag `--bbsections-guided-section-prefix` which defaults to `true`.

The new implementation refactors the parsing of basic block sections profile into a new `BasicBlockSectionsProfileReader` analysis pass. This allows us to use the information earlier in `CodeGenPrepare` in order to set the functions text prefix. `BasicBlockSectionsProfileReader` will be used both by `BasicBlockSections` pass and `CodeGenPrepare`.

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

2 years ago[NFC][JumpThreading] Remove InsertFreezeWhenUnfoldingSelect pass parameter
Arthur Eubanks [Thu, 26 May 2022 21:18:58 +0000 (14:18 -0700)]
[NFC][JumpThreading] Remove InsertFreezeWhenUnfoldingSelect pass parameter

All callers pass true.

select-unfold-freeze.ll is now a subset of select.ll so delete it.

Reviewed By: nikic

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

2 years ago[RISCV] Add a subtarget feature to enable unaligned scalar loads and stores
Philip Reames [Thu, 26 May 2022 22:24:41 +0000 (15:24 -0700)]
[RISCV] Add a subtarget feature to enable unaligned scalar loads and stores

A RISCV implementation can choose to implement unaligned load/store support. We currently don't have a way for such a processor to indicate a preference for unaligned load/stores, so add a subtarget feature.

There doesn't appear to be a formal extension for unaligned support. The RISCV Profiles (https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#rva20u64-profile) docs use the name Zicclsm, but a) that doesn't appear to actually been standardized, and b) isn't quite what we want here anyway due to the perf comment.

Instead, we can follow precedent from other backends and have a feature flag for the existence of misaligned load/stores with sufficient performance that user code should actually use them.

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

2 years ago[BOLT] Fix AND evaluation bug in shrink wrapping
Rafael Auler [Sat, 21 May 2022 00:42:58 +0000 (17:42 -0700)]
[BOLT] Fix AND evaluation bug in shrink wrapping

Fix a bug where shrink-wrapping would use wrong stack offsets
because the stack was being aligned with an AND instruction, hence,
making its true offsets only available during runtime (we can't
statically determine where are the stack elements and we must give up
on this case).

Reviewed By: Amir

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

2 years ago[lld][WebAssembly] Update test after 87628f5804e2
Sam Clegg [Thu, 26 May 2022 21:56:36 +0000 (14:56 -0700)]
[lld][WebAssembly] Update test after 87628f5804e2

2 years agoStore a by name list of signals with their actions in the Target
Jim Ingham [Wed, 18 May 2022 21:39:03 +0000 (14:39 -0700)]
Store a by name list of signals with their actions in the Target
so that they can be used to prime new Process runs.  "process handle"
was also changed to populate the dummy target if there's no selected
target, so that the settings will get copied into new targets.

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

2 years agoUse cmake Python3_EXECUTABLE variable instead of hardcoding
Matthias Braun [Thu, 26 May 2022 21:47:49 +0000 (14:47 -0700)]
Use cmake Python3_EXECUTABLE variable instead of hardcoding

2 years ago[lld][WebAssembly] Require double dash for modern linker flags
Sam Clegg [Thu, 26 May 2022 21:05:05 +0000 (14:05 -0700)]
[lld][WebAssembly] Require double dash for modern linker flags

This matches the behaviour of the ELF backend (in fact this change
is mostly just copying directly from ELF/Options.td).

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

2 years ago[Driver][test] Change -target i386-unknown-linux-gnu to --target=i386 and remove...
Fangrui Song [Thu, 26 May 2022 21:41:03 +0000 (14:41 -0700)]
[Driver][test] Change -target i386-unknown-linux-gnu to --target=i386 and remove unused -o %t.o

Use a generic ELF triple to demonstrate that these apply to all ELF OSes.
Also migrate away from the legacy `-target ` spelling.

2 years ago[DOC] Improve LangRef description of declare
Sebastian Peryt [Thu, 26 May 2022 21:27:25 +0000 (14:27 -0700)]
[DOC] Improve LangRef description of declare

This patch fixes formatting inside Functions section of declare
by making it consistent with the way how define is written.

Fixes #39844

Reviewed By: RKSimon

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

2 years ago[DOC] Refactor Functions section in LangRef
Sebastian Peryt [Thu, 26 May 2022 21:19:13 +0000 (14:19 -0700)]
[DOC] Refactor Functions section in LangRef

This change is a small refactor of Functions section
to update placement of define syntax.

Reviewed By: RKSimon

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

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC)
Mehdi Amini [Tue, 24 May 2022 00:20:55 +0000 (00:20 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in Bufferize.cpp ...
Mehdi Amini [Tue, 24 May 2022 00:02:05 +0000 (00:02 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in Bufferize.cpp (NFC)

2 years ago[Polly][Test] Fix race condition while printing dot files.
Michael Kruse [Thu, 26 May 2022 20:38:04 +0000 (15:38 -0500)]
[Polly][Test] Fix race condition while printing dot files.

The tests dot-scops.ll and dot-scops-npm.ll both wrote to the same file
scops.func.dot. If they are executed in parallel they will race for
the file. Fix by renaming func to func_npm in dot-scops-npm.ll so this
test writes dot scops.func_npm.dot.

Long-term, we will probably pass a file name (prefix) to the
printer pass such that we can use the guaranteed-unique LIT %t
placeholder in tests.

2 years ago[clang-format][NFC] Refactor UnwrappedLineParser::parseBlock()
owenca [Wed, 25 May 2022 07:55:03 +0000 (00:55 -0700)]
[clang-format][NFC] Refactor UnwrappedLineParser::parseBlock()

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

2 years ago[libc++][NFC] Fix whitespace
Louis Dionne [Thu, 26 May 2022 20:52:16 +0000 (16:52 -0400)]
[libc++][NFC] Fix whitespace

2 years ago[lld][WebAssembly] Avoid importing/exporting hidden symbols in shared libraries
Sam Clegg [Thu, 26 May 2022 17:32:04 +0000 (10:32 -0700)]
[lld][WebAssembly] Avoid importing/exporting hidden symbols in shared libraries

We have some special handling for weakly defined symbols where we both
import and export them, but this is not needed for hidden symbols which
should never be imported or exported.

See https://github.com/emscripten-core/emscripten/pull/16972

This should also help with:
https://github.com/emscripten-core/emscripten/issues/15487

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

2 years ago[clang-format] Fix an invalid code generation in RemoveBracesLLVM
owenca [Thu, 26 May 2022 02:27:54 +0000 (19:27 -0700)]
[clang-format] Fix an invalid code generation in RemoveBracesLLVM

Fixes #55706.

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

2 years ago[lld][WebAssemlby] Check for command line flags with missing arguments
Sam Clegg [Thu, 26 May 2022 20:11:20 +0000 (13:11 -0700)]
[lld][WebAssemlby] Check for command line flags with missing arguments

I'm really not sure how this was overlooked when we first ported lld
to Wasm.  The upstream code in the ELF backend has these two lines but
for some reason they never make it into the Wasm version.

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

2 years ago[ValueTracking] Added support to deduce PHI Nodes values being a power of 2
William Huang [Thu, 26 May 2022 20:15:00 +0000 (20:15 +0000)]
[ValueTracking] Added support to deduce PHI Nodes values being a power of 2

Add Value Tracking support to deduce induction variable being a power of 2, allowing urem optimizations

Reviewed By: davidxl

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

2 years ago[InstCombine] fold mul of signbit directly to X < 0 ? Y : 0
Sanjay Patel [Thu, 26 May 2022 18:28:05 +0000 (14:28 -0400)]
[InstCombine] fold mul of signbit directly to X < 0 ? Y : 0

This is effectively NFC (intentionally no test diffs)
because we already have the related fold that converts
the 'and' pattern to select. So this is just an efficiency
improvement.

2 years ago[InstCombine] add tests for mul with sign-splat operand; NFC
Sanjay Patel [Thu, 26 May 2022 18:03:51 +0000 (14:03 -0400)]
[InstCombine] add tests for mul with sign-splat operand; NFC

2 years ago[InstCombine] fold icmp equality with sdiv and SMIN
Sanjay Patel [Thu, 26 May 2022 16:21:48 +0000 (12:21 -0400)]
[InstCombine] fold icmp equality with sdiv and SMIN

This extends the fold from D126410 / 3952c905ef08
to allow for the only case where it works with signed
division:
https://alive2.llvm.org/ce/z/k7_ypu

(X s/ Y) == SMIN --> (X == SMIN) && (Y == 1)
(X s/ Y) != SMIN --> (X != SMIN) || (Y != 1)

This is another improvement based on #55695.

2 years ago[InstCombine] reduce code duplication in icmp+div folds; NFC
Sanjay Patel [Thu, 26 May 2022 16:02:30 +0000 (12:02 -0400)]
[InstCombine] reduce code duplication in icmp+div folds; NFC

2 years ago[InstCombine] add tests for icmp with sdiv operand; NFC
Sanjay Patel [Thu, 26 May 2022 15:29:59 +0000 (11:29 -0400)]
[InstCombine] add tests for icmp with sdiv operand; NFC

Adapted from unsigned division tests from:
ea6171c108c47c1ee4863

2 years ago[LegalizeTypes] Fix bug in expensive checks verification
Craig Topper [Thu, 26 May 2022 19:15:04 +0000 (12:15 -0700)]
[LegalizeTypes] Fix bug in expensive checks verification

With a fix for an expensive checks build failure exposed by new RISC-V tests.
Something about expanding two rotates in type legalization caused a change
in the remapping tables that the expensive checks verifying wasn't expecting.
See comment in the code for how it was fixed.

Tests came from this commit that exposed the bug
[RISCV] Add test cases showing failure to remove mask on rotate amounts.

If the masking AND has multiple users we fail to remove it.

Reviewed By: RKSimon

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

2 years ago[RISCV] Simplfy creation of IndexVT in lowerMaskedGather/lowerMaskedScatter. NFC
Craig Topper [Thu, 26 May 2022 19:13:37 +0000 (12:13 -0700)]
[RISCV] Simplfy creation of IndexVT in lowerMaskedGather/lowerMaskedScatter. NFC

The scalar element width is not a factor in how ContainerVT is
determined. We don't need to check the relative size of VT and
IndexVT.

2 years ago[gn build] Port b58a420ff4f9
LLVM GN Syncbot [Thu, 26 May 2022 20:01:22 +0000 (20:01 +0000)]
[gn build] Port b58a420ff4f9

2 years ago[Tooling/DependencyScanning & Preprocessor] Refactor dependency scanning to produce...
Argyrios Kyrtzidis [Thu, 12 May 2022 04:56:29 +0000 (21:56 -0700)]
[Tooling/DependencyScanning & Preprocessor] Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources

This is a commit with the following changes:

* Remove `ExcludedPreprocessorDirectiveSkipMapping` and related functionality

Removes `ExcludedPreprocessorDirectiveSkipMapping`; its intended benefit for fast skipping of excluded directived blocks
will be superseded by a follow-up patch in the series that will use dependency scanning lexing for the same purpose.

* Refactor dependency scanning to produce pre-lexed preprocessor directive tokens, instead of minimized sources

Replaces the "source minimization" mechanism with a mechanism that produces lexed dependency directives tokens.

* Make the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer`

This is bringing the following benefits:

    * Full access to the preprocessor state during dependency scanning. E.g. a component can see what includes were taken and where they were located in the actual sources.
    * Improved performance for dependency scanning. Measurements with a release+thin-LTO build shows ~ -11% reduction in wall time.
    * Opportunity to use dependency scanning lexing to speed-up skipping of excluded conditional blocks during normal preprocessing (as follow-up, not part of this patch).

For normal preprocessing measurements show differences are below the noise level.

Since, after this change, we don't minimize sources and pass them in place of the real sources, `DependencyScanningFilesystem` is not technically necessary, but it has valuable performance benefits for caching file `stat`s along with the results of scanning the sources. So the setup of using the `DependencyScanningFilesystem` during a dependency scan remains.

Differential Revision: https://reviews.llvm.org/D125486
Differential Revision: https://reviews.llvm.org/D125487
Differential Revision: https://reviews.llvm.org/D125488

2 years ago[Tooling/DependencyScanning] Rename refactorings towards transitioning dependency...
Argyrios Kyrtzidis [Thu, 12 May 2022 04:21:17 +0000 (21:21 -0700)]
[Tooling/DependencyScanning] Rename refactorings towards transitioning dependency scanning to use pre-lexed preprocessor directive tokens

This is first of a series of patches for making the special lexing for dependency scanning a first-class feature of the `Preprocessor` and `Lexer`.
This patch only includes NFC renaming changes to make reviewing of the functionality changing parts easier.

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

2 years ago[DirectX] Update test for dxil-dis.
python3kgae [Tue, 24 May 2022 18:04:51 +0000 (11:04 -0700)]
[DirectX] Update test for dxil-dis.

Update metadata index which changed for dx.valver.

Reviewed By: beanz

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

2 years ago[libunwind] Tidy-up the testing configuration for libunwind
Louis Dionne [Thu, 26 May 2022 14:19:25 +0000 (10:19 -0400)]
[libunwind] Tidy-up the testing configuration for libunwind

Start testing Apple backdeployment with older libunwinds, and stop
explicitly specifying the libunwind testing config, since it is
already selected correctly by default.

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

2 years ago[lldb] Fix enums-layout test on Windows
Stella Stamenova [Thu, 26 May 2022 19:16:24 +0000 (12:16 -0700)]
[lldb] Fix enums-layout test on Windows

The test was broken by: https://reviews.llvm.org/D125604

2 years ago[lldb] Fix broken bad-address-breakpoint test
Will Hawkins [Thu, 26 May 2022 19:14:22 +0000 (12:14 -0700)]
[lldb] Fix broken bad-address-breakpoint test

After changing the "fallback" behavior when a user sets a breakpoint
without specifying a module the bad-address-breakpoint test case failed
incorrectly. This patch updates that test case in order to more
thoroughly discover an illegal address and use that as the means for
testing whether a breakpoint set at an illegal address fails to resolve.

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

2 years ago[OpenMP] Extend omp teams to permit nested omp atomic
Joel E. Denny [Thu, 26 May 2022 18:59:16 +0000 (14:59 -0400)]
[OpenMP] Extend omp teams to permit nested omp atomic

OpenMP 5.2, sec. 10.2 "teams Construct", p. 232, L9-12 restricts what
regions can be strictly nested within a `teams` construct.  This patch
relaxes Clang's enforcement of this restriction in the case of nested
`atomic` constructs unless `-fno-openmp-extensions` is specified.
Cases like the following then seem to work fine with no additional
implementation changes:

```
 #pragma omp target teams map(tofrom:x)
 #pragma omp atomic update
 x++;
```

Reviewed By: ABataev

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

2 years ago[libc++] Time tests during CI
Louis Dionne [Thu, 26 May 2022 18:58:24 +0000 (14:58 -0400)]
[libc++] Time tests during CI

2 years agoFix break introduced by D124306
Mircea Trofin [Thu, 26 May 2022 18:48:29 +0000 (11:48 -0700)]
Fix break introduced by D124306

argparse.BooleanOptionalAction is not supported until python 3.9.

2 years agoRoll back use of #warning for header deprecations
Aaron Ballman [Thu, 26 May 2022 18:43:28 +0000 (14:43 -0400)]
Roll back use of #warning for header deprecations

e5ccd668019888de2704ae670da88a7be8cf7e0f and
5029dce492b3cf3ac191eda0b5bf268c3acac2e0 added deprecation warnings to
the <stdbool.h> and <stdnoreturn.h> headers, respectively, because the
headers are deprecated in C2x.

However, there are system headers that include these headers
unconditionally, and #warning diagnostics within system headers are
shown to users instead of suppressed, which means these deprecation
warnings are being triggered in circumstances that users have no
control over except to disable all the warnings through the
_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS macro or other means.

This removes the problematic #warning uses until we find a more
palatable solution.

2 years agoGive option to use isCopyInstr to determine which MI is
Adrian Tong [Wed, 4 May 2022 23:00:42 +0000 (23:00 +0000)]
Give option to use isCopyInstr to determine which MI is
treated as Copy instruction in MCP.

This is then used in AArch64 to remove copy instructions after taildup
ran in machine block placement

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

2 years agoOne further tweak for realpathing filepath to match dyld
Jason Molenda [Thu, 26 May 2022 18:24:13 +0000 (11:24 -0700)]
One further tweak for realpathing filepath to match dyld

I missed one place I need to realpath the build artifact path,
to make it match the path we get back from dyld.

2 years ago[Target] use getSubtarget<> instead of static_cast<>(getSubtarget())
Zongwei Lan [Thu, 26 May 2022 18:22:41 +0000 (11:22 -0700)]
[Target] use getSubtarget<> instead of static_cast<>(getSubtarget())

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

2 years agoCheck that a FileSpec has a Directory component before using
Jason Molenda [Thu, 26 May 2022 18:11:43 +0000 (11:11 -0700)]
Check that a FileSpec has a Directory component before using

A follow on to my patch for https://reviews.llvm.org/D126435
hit by an x86_64 linux bot; I assumed that a FileSpec had a
directory component and checked if the first character was a
'~'.  This was not a valid assumption.

2 years agoDefer source path remap tilde expansion until source file use
Jason Molenda [Thu, 26 May 2022 07:30:12 +0000 (00:30 -0700)]
Defer source path remap tilde expansion until source file use

When reading source path remappings out of a dSYM, lldb currently
does tilde expansion -- expanding the tilde-username and checking
that the destination pathname exists, for each dSYM with the path
remappings.  This cost happens during lldb's initial process launch
/ load, an especially perf-sensitive time.  Inside Apple, we have
dSYMs with source path remappings pointing to NFS directories where
these extra stats for every dSYM can be very expensive if the network
is slow.

This patch instead keeps the source path mapping in the original
tilde-username terms and does the tilde expansion when we need
to read a specific source file from one of the modules.  We'll
be stat'ing all of those inodes to load the source file anyway,
so the fact that we do the tilde expansion on every source file
we load, it doesn't cost us significantly.

Differential Revision: https://reviews.llvm.org/D126435
rdar://77091379

(cherry picked from commit c274b6e5830ea88d3f55d6dc1d2b99e38cf6595e)

2 years ago[Clang][CoverageMapping] Fix switch counter codegen compile time explosion
Bruno Cardoso Lopes [Tue, 24 May 2022 23:56:22 +0000 (16:56 -0700)]
[Clang][CoverageMapping] Fix switch counter codegen compile time explosion

C++ generated code with huge amount of switch cases chokes badly while emitting
coverage mapping, in our specific testcase (~72k cases), it won't stop after hours.
After this change, the frontend job now finishes in 4.5s and shrinks down `@__covrec_`
by 288k when compared to disabling simplification altogether.

There's probably no good way to create a testcase for this, but it's easy to
reproduce, just add thousands of cases in the below switch, and build with
`-fprofile-instr-generate -fcoverage-mapping`.

```
enum type : int {
 FEATURE_INVALID = 0,
 FEATURE_A = 1,
 ...
};

const char *to_string(type e) {
  switch (e) {
  case type::FEATURE_INVALID: return "FEATURE_INVALID";
  case type::FEATURE_A: return "FEATURE_A";}
  ...
  }

```

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

2 years ago[UpdateTestChecks] Auto-generate stub bodies for unused prefixes
Mircea Trofin [Fri, 22 Apr 2022 19:49:15 +0000 (12:49 -0700)]
[UpdateTestChecks] Auto-generate stub bodies for unused prefixes

This is scoped to autogenerated tests.

The goal is to support having each RUN line specify a list of
check-prefixes where one can specify potentially redundant prefixes. For example,
for X86, if one specified prefixes for  both AVX1 and AVX2, and the codegen happened to
match today, one of the prefixes would be used and the onther one not.
If the unused prefix were dropped, and later, codegen differences were
introduced, one would have to go figure out where to add what prefix
(paraphrasing
https://lists.llvm.org/pipermail/llvm-dev/2021-February/148326.html)

To avoid getting errors due to unused prefixes, whole directories can be
opted out (as discussed on that thread), but that means that tests that
aren't autogenerated in such directories could have undetected unused
prefix bugs.

This patch proposes an alternative that both avoids the above, dir-level
optout, and supports the main autogen scenario discussed first. The autogen
tool appends at the end of the test file the list of unused prefixes,
together with a note explaining that is the case. Each prefix is set up
to always pass.

This way, unexpected unused prefixes are easily discoverable, and
expected cases "just work".

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

2 years ago[SCEV] Collect conditions from assumes same way as for branches.
Florian Hahn [Thu, 26 May 2022 17:16:37 +0000 (18:16 +0100)]
[SCEV] Collect conditions from assumes same way as for branches.

Also collect conditions from assume up-front in applyLoopGuards.
This allows re-using the logic to handle logical ANDs as assume
conditions.

It should should pave the road for a fix for #55645.

2 years ago[ARM] Recognize t2LoopEnd for software pipelining
David Penry [Mon, 28 Mar 2022 19:18:37 +0000 (12:18 -0700)]
[ARM] Recognize t2LoopEnd for software pipelining

- Add t2LoopEnd to TargetInstrInfo::analyzeBranch and
  related functions.  As there are many side effects of
  analyzing a branch, only do so if software pipelining
  is enabled to maintain previous behavior when pipelining
  is not desired.
- Make sure that t2LoopEndDec is immediately followed by
  a t2B when it is synthesized from a t2LoopEnd. This is
  done because the t2LoopEnd might have acquired a
  fall-through path, but IfConversion assumes that
  fall-through are only possible on analyzable branches.

Reviewed By: dmgreen

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

2 years ago[OpenMP] Use the align clause value from 'omp allocate' for globals
Mike Rice [Wed, 25 May 2022 22:02:26 +0000 (15:02 -0700)]
[OpenMP] Use the align clause value from 'omp allocate' for globals

Refactor the code that handles the align clause of 'omp allocate' so
it can be used with globals as well as local variables.

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

2 years agoRevert "Replace the custom linked list in LeaderTableEntry with TinyPtrVector."
Owen Anderson [Thu, 26 May 2022 16:50:36 +0000 (09:50 -0700)]
Revert "Replace the custom linked list in LeaderTableEntry with TinyPtrVector."

This reverts commit 1e9114984490b83d4665f12a11f84c83f50ca8f0.

Pending further discussion.

2 years ago[RISCV] reorganize getFrameIndexReference to reduce code duplication [nfc]
Philip Reames [Thu, 26 May 2022 15:55:47 +0000 (08:55 -0700)]
[RISCV] reorganize getFrameIndexReference to reduce code duplication [nfc]

This change reorganizes the majority of frame index resolution into a two strep process.

    Step 1 - Select which base register we're going to use.
    Step 2 - Compute the offset from that base register.

The key point is that this allows us to share the step 2 logic for the SP case. This reduces the code duplication, and (I think) makes the code much easier to follow.

I also went ahead and added assertions into phase 2 to catch errors where we select an illegal base pointer. In general, we can't index from a base register to a stack location if that requires crossing a variable and unknown region. In practice, we have two such cases: dynamic stack realign and var sized objects. Note that crossing the scalable region is fine since while variable, it's a known variability which can be expressed in the offset.

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

2 years agoRevert "[runtimes] Detect changes to Tests.cmake"
Shoaib Meenai [Thu, 26 May 2022 16:34:18 +0000 (09:34 -0700)]
Revert "[runtimes] Detect changes to Tests.cmake"

This reverts commit ec10ac750a8ad96983d85263323635f3dabe92fd.

See https://discourse.llvm.org/t/cmake-regeneration-is-broken/62788.
This change caused Ninja's CMake regeneration to depend on the build,
which prevented CMake regeneration from functioning properly and caused
spurious build failures on incremental builds when a CMake change
occurred.

2 years ago[libunwind] Use process_vm_readv to avoid potential segfaults
Shoaib Meenai [Thu, 26 May 2022 04:39:12 +0000 (21:39 -0700)]
[libunwind] Use process_vm_readv to avoid potential segfaults

We've observed segfaults in libunwind when attempting to check for the
Linux aarch64 sigreturn frame, presumably because of bad unwind info
leading to an incorrect PC that we attempt to read from. Use
process_vm_readv to read the memory safely instead.

The s390x code path should likely follow suit, but I don't have the
hardware to be able to test that, so I didn't modify it here either.

Reviewed By: MaskRay, rprichard, #libunwind

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

2 years ago[libunwind] Factor out sigreturn check condition. NFC
Shoaib Meenai [Tue, 24 May 2022 05:11:34 +0000 (22:11 -0700)]
[libunwind] Factor out sigreturn check condition. NFC

Create a macro for this instead of duplicating the architecture checks
everywhere. (It's a little redundant to use it when we're checking for a
specific architecture, but I'm also applying it there for consistency.)

Reviewed By: rprichard, MaskRay, #libunwind

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

2 years ago[ControlHeightReduction] Use logical and
Nikita Popov [Thu, 26 May 2022 15:59:27 +0000 (17:59 +0200)]
[ControlHeightReduction] Use logical and

Use logical instead of bitwise and to combine conditions, to avoid
propagating poison from a later condition if an earlier one is
already false. This avoids introducing branch on poison.

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

2 years ago[RISCV] Allow compatible VTYPE in AVL Reg Forward cases
Philip Reames [Thu, 26 May 2022 14:56:38 +0000 (07:56 -0700)]
[RISCV] Allow compatible VTYPE in AVL Reg Forward cases

During insertion of VSETVLI, we have two related bits of code which decide whether we can reuse a previous vsetvli result. As was pointed out in the original review, these cases can allow any prior state for which we know that VL is the same for any value of AVL.

This was originally separated out of a desire for separate tests and review. As it turns out, finding a test case for this has been quite challenging. Most of the cases I tried, we manage to already get through other chains of logic. We do have one correct test change, but that only exercises one of the two changes.

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

2 years ago[SLP]Improve compile time, NFC.
Alexey Bataev [Wed, 25 May 2022 13:27:30 +0000 (06:27 -0700)]
[SLP]Improve compile time, NFC.

Patch improves compile time. For function calls, which cannot be
vectorized, create a unique group for each such a call instead of
subgroup. It prevents them from being grouped by a subgroups and
attempts for their vectorization.

Also, looks through casts operand to try to check their
groups/subgroups.

Reduces number of vectorization attempts. No changes in the statistics
for SPEC2017/2006/llvm-test-suite.

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

2 years ago[SLP]Fix PR55653: emit undefs where required, not poison.
Alexey Bataev [Tue, 24 May 2022 13:53:19 +0000 (06:53 -0700)]
[SLP]Fix PR55653: emit undefs where required, not poison.

Need to handle a corner case correctly, if all elements are Undefs/Poisons,
need to emit actual values, not just poisons.

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

2 years ago[DFAJumpThreading] Relax analysis to handle unpredictable initial values
Alex Zhikhartsev [Wed, 25 May 2022 23:10:57 +0000 (19:10 -0400)]
[DFAJumpThreading] Relax analysis to handle unpredictable initial values

Responding to a feature request from the Rust community:

https://github.com/rust-lang/rust/issues/80630

    void foo(X) {
      for (...)
switch (X)
  case A
    X = B
  case B
    X = C
    }

Even though the initial switch value is non-constant, the switch
statement can still be threaded: the initial value will hit the switch
statement but the rest of the state changes will proceed by jumping
unconditionally.

The early predictability check is relaxed to allow unpredictable values
anywhere, but later, after the paths through the switch statement have
been enumerated, no non-constant state values are allowed along the
paths. Any state value not along a path will be an initial switch value,
which can be safely ignored.

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

2 years ago[SCEV] Add test with loop guarded by assume with an AND condition.
Florian Hahn [Thu, 26 May 2022 15:08:31 +0000 (16:08 +0100)]
[SCEV] Add test with loop guarded by assume with an AND condition.

Show a missed case where the AND is currently blocks applying the
information from the assume.

2 years ago[ADT] Explicitly delete copy/move constructors and operator= in IntervalMap
Krzysztof Parzyszek [Wed, 25 May 2022 18:20:02 +0000 (11:20 -0700)]
[ADT] Explicitly delete copy/move constructors and operator= in IntervalMap

The default implementations will perform a shallow copy instead of a deep
copy, causing some internal data structures to be shared between different
objects. Disable these operations so they don't get accidentally used.

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

2 years ago[OpenCL][Doc] Misc improvements related to SPIR-V support.
Anastasia Stulova [Thu, 26 May 2022 14:47:56 +0000 (15:47 +0100)]
[OpenCL][Doc] Misc improvements related to SPIR-V support.

2 years ago[gn build] Port 0e3dc1a52ffe
LLVM GN Syncbot [Thu, 26 May 2022 14:50:15 +0000 (14:50 +0000)]
[gn build] Port 0e3dc1a52ffe

2 years ago[libc++] Implement ranges::{all, any, none}_of
Nikolas Klauser [Thu, 26 May 2022 14:42:46 +0000 (16:42 +0200)]
[libc++] Implement ranges::{all, any, none}_of

Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[SLP] Move canVectorizeLoads implementation to simplify the diff in D105986. NFC.
Simon Pilgrim [Thu, 26 May 2022 14:23:49 +0000 (15:23 +0100)]
[SLP] Move canVectorizeLoads implementation to simplify the diff in D105986. NFC.

2 years ago[PowerPC][Future] Add an ISA Future to go with mcpu=future.
Stefan Pintilie [Thu, 26 May 2022 13:35:59 +0000 (08:35 -0500)]
[PowerPC][Future] Add an ISA Future to go with mcpu=future.

On Power PC we have ISA3.0 for Power 9, ISA3.1 for Power 10.
This patchs adds an ISA for mcpu=future. The idea is to have a placeholder ISA
for work that is experimental and may not be supported by existing ISAs.

Reviewed By: lei

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

2 years ago[PS5] Allow dllimport/dllexport same as PS4
Paul Robinson [Wed, 25 May 2022 19:39:23 +0000 (12:39 -0700)]
[PS5] Allow dllimport/dllexport same as PS4

2 years ago[clang-format] Handle attributes in enum declaration.
Tyler Chatow [Thu, 26 May 2022 13:16:02 +0000 (15:16 +0200)]
[clang-format] Handle attributes in enum declaration.

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

Ensures that attributes in the enum declaration are interpreted
correctly, for instance:

```
enum class [[nodiscard]] E {
  a,
  b
};
```

Reviewed By: MyDeveloperDay, curdeius

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

2 years ago[clang][PR55406] CFG for coroutine
Nathan Sidwell [Wed, 25 May 2022 17:11:39 +0000 (10:11 -0700)]
[clang][PR55406] CFG for coroutine

CoreturnStmt needs to keep the operand value distinct from its use in
any return_value call, so that instantiation may rebuild the latter.
But it also needs to keep the operand value separate in the case of
calling return_void.  Code generation checks the operand value form to
determine whether it is a distincte entity to the promise call.  This
adds the same logic to CFG generation.

Reviewed By: bruno

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

2 years ago[bazel] Introduce "VE" CodeGen in LLVM.
NAKAMURA Takumi [Thu, 26 May 2022 13:37:14 +0000 (22:37 +0900)]
[bazel] Introduce "VE" CodeGen in LLVM.

2 years ago[libc++] Remove temporary workaround for existing CMake caches
Louis Dionne [Thu, 26 May 2022 13:35:01 +0000 (09:35 -0400)]
[libc++] Remove temporary workaround for existing CMake caches

If you are broken by this change, you should remove your CMake cache and
re-run the CMake generation step.

2 years ago[SLP]Fix crash on reordering of ScatterVectorize nodes.
Alexey Bataev [Wed, 25 May 2022 14:15:49 +0000 (07:15 -0700)]
[SLP]Fix crash on reordering of ScatterVectorize nodes.

ScatterVectorize nodes should be handled same way as gathers in
reorderBottomToTop function, since we can simple reorder the loads in
this node. Because of that need to include such nodes to the list of
gathered nodes to fix compiler crash.

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

2 years ago[flang][NFC] Make semantics test dosemantics03.f90 warning-correct
Emil Kieri [Sun, 22 May 2022 20:28:04 +0000 (22:28 +0200)]
[flang][NFC] Make semantics test dosemantics03.f90 warning-correct

This is a preparation for D125804, which makes test_errors.py test
warnings the same way it already tests errors, i.e., assert that the
emitted and expected errors are identical. The following changes are
made to the test:

 - Add the WARNING directive where warnings are expected.
 - Remove -Werror in the RUN line. It does not serve much purpose here:
   with -Werror flang makes compilation fail in the presence of
   warnings, but warnings are still printed as warnings and not as
   errors. And I anyway find it better to test the warnings as warnings
   instead of promoting them and test both warnings and errors as
   errors.
 - Update the header comment describing the test case, mostly in
   response to the removal of -Werror.
 - Remove the reference to 'issue 458', referring to
   https://github.com/flang-compiler/f18/issues/458, from the header.
   I think the relevant reference here is to C1120 of the standard,
   and references to bug trackers from other projects (from before
   upstreaming) can be confusing.

Reviewed By: PeteSteinfeld

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

2 years ago[Cuda] Use fallback method to mangle externalized decls if no CUID given
Joseph Huber [Wed, 18 May 2022 13:19:15 +0000 (09:19 -0400)]
[Cuda] Use fallback method to mangle externalized decls if no CUID given

CUDA requires that static variables be visible to the host when
offloading. However, The standard semantics of a stiatc variable dictate
that it should not be visible outside of the current file. In order to
access it from the host we need to perform "externalization" on the
static variable on the device. This requires generating a semi-unique
name that can be affixed to the variable as to not cause linker errors.

This is currently done using the CUID functionality, an MD5 hash value
set up by the clang driver. This allows us to achieve is mostly unique
ID that is unique even between multiple compilations of the same file.
However, this is not always availible. Instead, this patch uses the
unique ID from the file to generate a unique symbol name. This will
create a unique name that is consistent between the host and device side
compilations without requiring the CUID to be entered by the driver. The
one downside to this is that we are no longer stable under multiple
compilations of the same file. However, this is a very niche use-case
and is not supported by Nvidia's CUDA compiler so it likely to be good
enough.

Reviewed By: tra

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

2 years ago[InstCombine] fold icmp equality with udiv and large constant
Sanjay Patel [Thu, 26 May 2022 12:23:36 +0000 (08:23 -0400)]
[InstCombine] fold icmp equality with udiv and large constant

With large compare constant:
(X u/ Y) == C --> (X == C) && (Y == 1)
(X u/ Y) != C --> (X != C) || (Y != 1)

https://alive2.llvm.org/ce/z/EhKwh6

There are various potential missing icmp (div) transforms shown here:
https://github.com/llvm/llvm-project/issues/55695

This is a generalization for part of the udiv + equality.
I didn't check in detail, but some of those may only make sense as
codegen transforms.

This results in one extra instruction in IR, but it is better for
analysis, and looks much better in codegen on all targets that I tried.

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

2 years ago[InstCombine] add tests for icmp with udiv operand; NFC
Sanjay Patel [Wed, 25 May 2022 18:22:56 +0000 (14:22 -0400)]
[InstCombine] add tests for icmp with udiv operand; NFC

This covers a generalization of one of the transforms
suggested in #55695.

2 years ago[libc++abi] Use from-scratch testing configs for libc++abi by default
Louis Dionne [Mon, 9 May 2022 15:54:10 +0000 (11:54 -0400)]
[libc++abi] Use from-scratch testing configs for libc++abi by default

Like we have been doing for libc++ for a while now, start using
from-scratch testing configurations for libc++abi.

As a fly-by fix, remove the LIBCXXABI_NO_TIMER macro, which was defined
but never used.

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

2 years ago[DAG] Generalize (sra (trunc (sra x, c1)), c2) -> (trunc (sra x, c1 + c2)) constant...
Simon Pilgrim [Thu, 26 May 2022 13:05:00 +0000 (14:05 +0100)]
[DAG] Generalize (sra (trunc (sra x, c1)), c2) -> (trunc (sra x, c1 + c2)) constant folding

Remove local (uniform) constant folding and rely on getNode() to perform it

Minor cleanup step toward adding non-uniform shift amount support

2 years ago[clang-format] Fix QualifierAlignment with global namespace qualified types.
Marek Kurdej [Fri, 20 May 2022 22:05:51 +0000 (00:05 +0200)]
[clang-format] Fix QualifierAlignment with global namespace qualified types.

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

Reviewed By: MyDeveloperDay

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