platform/upstream/llvm.git
2 years agoRevert "[compiler-rt][cmake] Use HandleOutOfTreeLLVM like libcxx and friends"
David Tenty [Fri, 21 Jan 2022 17:20:28 +0000 (12:20 -0500)]
Revert "[compiler-rt][cmake] Use HandleOutOfTreeLLVM like libcxx and friends"

This reverts commit 8c9f62ea90c70d538766a81ef5980c9223b8566b, which is causing build failures on
the bots because it inadvertently changes the output directory of the compiler-rt libs when
built as a runtime.

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

2 years ago[clang-format] Fix comment in spaceRequiredBefore. NFC.
Marek Kurdej [Fri, 21 Jan 2022 17:17:55 +0000 (18:17 +0100)]
[clang-format] Fix comment in spaceRequiredBefore. NFC.

2 years agoRevert "[libc++] Use addressof in unordered_map."
Mark de Wever [Fri, 21 Jan 2022 16:59:07 +0000 (17:59 +0100)]
Revert "[libc++] Use addressof in unordered_map."

This reverts commit cab96169380296a496614f433507d86b743f0d02.

This breaks the CI.

2 years agoUpstream MLIR PyTACO implementation.
Bixia Zheng [Fri, 14 Jan 2022 00:27:28 +0000 (16:27 -0800)]
Upstream MLIR PyTACO implementation.

Add TACO tests to test/Integration/Dialect/SparseTensor/taco. Add the MLIR
PyTACO implementation as tools under the directory.

Reviewed By: aartbik, mehdi_amini

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

2 years ago[libc++] Use addressof in unordered_map.
Mark de Wever [Sun, 7 Nov 2021 18:44:59 +0000 (19:44 +0100)]
[libc++] Use addressof in unordered_map.

This addresses the usage of `operator&` in `<unordered_map>`.

(Note there are still more headers with the same issue.)

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[ifs] Use a tmp file instead of "-"
Jake Egan [Fri, 21 Jan 2022 16:18:48 +0000 (11:18 -0500)]
[ifs] Use a tmp file instead of "-"

Currently, Clang on AIX uses the system assembler to generate object files from assembly. The use of `-o -` results in a file named `-` instead of output to stdout. This patch uses a temporary object file instead.

Reviewed By: DiggerLin, hubert.reinterpretcast

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

2 years agoInclude missing "llvm/Support/Path.h" in "flang/lib/Frontend/CompilerInvocation.cpp"
serge-sans-paille [Fri, 21 Jan 2022 16:05:36 +0000 (17:05 +0100)]
Include missing "llvm/Support/Path.h" in "flang/lib/Frontend/CompilerInvocation.cpp"

2 years ago[ADT] [NFC] Add StringRef::detectEOL
Chris Bieneman [Wed, 19 Jan 2022 00:20:14 +0000 (18:20 -0600)]
[ADT] [NFC] Add StringRef::detectEOL

This change moves EOL detection out of the clang::InclusionRewriter into
llvm::StringRef so that it can be easily reused elsewhere. It also adds
additional explicit test cases to verify the correct and expected return
results.

Reviewed By: dblaikie

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

2 years ago[libcxx][doc][nfc] Fixed typo in doc
Vy Nguyen [Fri, 21 Jan 2022 15:17:28 +0000 (10:17 -0500)]
[libcxx][doc][nfc] Fixed typo in doc

2 years agoTry to unbreak build on Windows more after e9211e03937
Nico Weber [Fri, 21 Jan 2022 15:04:41 +0000 (10:04 -0500)]
Try to unbreak build on Windows more after e9211e03937

2 years agoAdd missing llvm/support/Regex.h include in polly/lib/Analysis/ScopDetection.cpp
serge-sans-paille [Fri, 21 Jan 2022 15:04:19 +0000 (16:04 +0100)]
Add missing llvm/support/Regex.h include in polly/lib/Analysis/ScopDetection.cpp

2 years agoTry to unbreak build on Windows after e9211e03937
Nico Weber [Fri, 21 Jan 2022 14:59:22 +0000 (09:59 -0500)]
Try to unbreak build on Windows after e9211e03937

2 years ago[clang-tidy] Avoid binding nullptr to a reference
Benjamin Kramer [Fri, 21 Jan 2022 14:54:33 +0000 (15:54 +0100)]
[clang-tidy] Avoid binding nullptr to a reference

That's undefined behavior. Found by -fsanitize=null.

2 years agoAdd security group 2021 transparency report.
Kristof Beyls [Wed, 12 Jan 2022 13:40:14 +0000 (14:40 +0100)]
Add security group 2021 transparency report.

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

2 years ago[InstCombine] Fold for masked gather when loading the same value each time.
Caroline Concatto [Mon, 13 Dec 2021 17:20:16 +0000 (17:20 +0000)]
[InstCombine] Fold for masked gather when loading the same value each time.

This patch checks in the masked gather when the first operand value is a
splat and the mask is all one, because the masked gather is reloading the
same value each time. This patch replaces this pattern of masked gather by
a scalar load of the value and splats it in a vector.

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

2 years agoRemove dependency from raw_ostream on <chrono>
serge-sans-paille [Thu, 20 Jan 2022 11:04:42 +0000 (12:04 +0100)]
Remove dependency from raw_ostream on <chrono>

The tryLockFor method from raw_fd_sotreamis the sole user of that
header, and it's not referenced in the mono repo. I still chose to keep
it (may be useful for downstream user) but added a transient type that's
forward declared to hold the duration parameter.

Notable changes:

- "llvm/Support/Duration.h" must be included in order to use tryLockFor.
- "llvm/Support/raw_ostream.h" no longer includes <chrono>

This sole change has an interesting impact on the number of processed
line, as measured by:

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Support/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l

before: 7917500
after:  7835142

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831

2 years ago[SystemZ] Properly register machine passes.
Kai Nacke [Thu, 20 Jan 2022 19:28:18 +0000 (14:28 -0500)]
[SystemZ] Properly register machine passes.

Registering the passes enables use of -stop-before=/-stop-after
options.

Reviewed By: uweigand

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

2 years agoAdd apple-specific missing header in Support/GraphWriter.cpp
serge-sans-paille [Fri, 21 Jan 2022 13:59:11 +0000 (14:59 +0100)]
Add apple-specific missing header in Support/GraphWriter.cpp

2 years ago[llvm][ADT] Implement `BitVector::{pop_,}back`
Jan Svoboda [Wed, 12 Jan 2022 15:09:58 +0000 (16:09 +0100)]
[llvm][ADT] Implement `BitVector::{pop_,}back`

LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

Currently, some users of `std::vector<bool>` cannot switch to `llvm::BitVector` because it doesn't implement the `pop_back()` and `back()` functions.

To enable easy transition of `std::vector<bool>` users, this patch implements `llvm::BitVector::pop_back()` and `llvm::BitVector::back()`.

Reviewed By: dexonsmith

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

2 years agoAdd ms-specific missing header in Support/InitLLVM.cpp
serge-sans-paille [Fri, 21 Jan 2022 13:28:47 +0000 (14:28 +0100)]
Add ms-specific missing header in Support/InitLLVM.cpp

2 years agoAdd apple-specific missing include
serge-sans-paille [Fri, 21 Jan 2022 13:18:17 +0000 (14:18 +0100)]
Add apple-specific missing include

2 years ago[NFCI][Support] Avoid ASSERT_/EXPECT_TRUE(A <op> B)
Archibald Elliott [Fri, 21 Jan 2022 13:14:58 +0000 (13:14 +0000)]
[NFCI][Support] Avoid ASSERT_/EXPECT_TRUE(A <op> B)

The error messages in tests are far better when a test fails if the test
is written using ASSERT_/EXPECT_<operator>(A, B) rather than
ASSERT_/EXPECT_TRUE(A <operator> B).

This commit updates all of llvm/unittests/Support to use these macros
where possible.

This change has not been possible in:
- llvm/unittests/Support/FSUniqueIDTest.cpp - due to not overloading
  operators beyond ==, != and <.
- llvm/unittests/Support/BranchProbabilityTest.cpp - where the unchanged
  tests are of the operator overloads themselves.

There are other possibilities of this conversion not being valid, which
have not applied in these tests, as they do not use NULL (they use
nullptr), and they do not use const char* (they use std::string or
StringRef).

Reviewed By: mubashar_

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

2 years agoAdd missing header in Support/ConvertUTF.h
serge-sans-paille [Fri, 21 Jan 2022 13:01:51 +0000 (14:01 +0100)]
Add missing header in Support/ConvertUTF.h

2 years ago[llvm] Cleanup header dependencies in ADT and Support
serge-sans-paille [Thu, 20 Jan 2022 11:55:14 +0000 (12:55 +0100)]
[llvm] Cleanup header dependencies in ADT and Support

The cleanup was manual, but assisted by "include-what-you-use". It consists in

1. Removing unused forward declaration. No impact expected.
2. Removing unused headers in .cpp files. No impact expected.
3. Removing unused headers in .h files. This removes implicit dependencies and
   is generally considered a good thing, but this may break downstream builds.
   I've updated llvm, clang, lld, lldb and mlir deps, and included a list of the
   modification in the second part of the commit.
4. Replacing header inclusion by forward declaration. This has the same impact
   as 3.

Notable changes:

- llvm/Support/TargetParser.h no longer includes llvm/Support/AArch64TargetParser.h nor llvm/Support/ARMTargetParser.h
- llvm/Support/TypeSize.h no longer includes llvm/Support/WithColor.h
- llvm/Support/YAMLTraits.h no longer includes llvm/Support/Regex.h
- llvm/ADT/SmallVector.h no longer includes llvm/Support/MemAlloc.h nor llvm/Support/ErrorHandling.h

You may need to add some of these headers in your compilation units, if needs be.

As an hint to the impact of the cleanup, running

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Support/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l

before: 8000919 lines
after:  7917500 lines

Reduced dependencies also helps incremental rebuilds and is more ccache
friendly, something not shown by the above metric :-)

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831

2 years agoRevert rG4727d29d908f9dd608dd97a58c0af1ad579fd3ca "[X86] Remove __builtin_ia32_pabs...
Simon Pilgrim [Fri, 21 Jan 2022 12:35:36 +0000 (12:35 +0000)]
Revert rG4727d29d908f9dd608dd97a58c0af1ad579fd3ca "[X86] Remove __builtin_ia32_pabs intrinsics and use generic __builtin_elementwise_abs"

Some build bots are referencing the `__builtin_ia32_pabs` intrinsics via alternative headers

2 years agoRevert rG8ee135dcf8ff060656ad481c3e980fe8763576f5 "[X86] Remove `__builtin_ia32_pmax...
Simon Pilgrim [Fri, 21 Jan 2022 12:34:19 +0000 (12:34 +0000)]
Revert rG8ee135dcf8ff060656ad481c3e980fe8763576f5 "[X86] Remove `__builtin_ia32_pmax/min` intrinsics and use generic `__builtin_elementwise_max/min`"

Some build bots are referencing the `__builtin_ia32_pmax/min` intrinsics via alternative headers

2 years ago[X86] Remove `__builtin_ia32_pmax/min` intrinsics and use generic `__builtin_elementw...
Simon Pilgrim [Fri, 21 Jan 2022 12:24:32 +0000 (12:24 +0000)]
[X86] Remove `__builtin_ia32_pmax/min` intrinsics and use generic `__builtin_elementwise_max/min`

D111985 added the generic `__builtin_elementwise_max` and `__builtin_elementwise_min` intrinsics with the same integer behaviour as the SSE/AVX instructions

This patch removes the `__builtin_ia32_pmax/min` intrinsics and just uses `__builtin_elementwise_max/min` - the existing tests see no changes:
```
__m256i test_mm256_max_epu32(__m256i a, __m256i b) {
  // CHECK-LABEL: test_mm256_max_epu32
  // CHECK: call <8 x i32> @llvm.umax.v8i32(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
  return _mm256_max_epu32(a, b);
}
```
This requires us to add a `__v64qs` explicitly signed char vector type (we already have `__v16qs` and `__v32qs`).

Sibling patch to D117791

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

2 years ago[flang] Update tco tool pipline and add translation to LLVM IR
Valentin Clement [Fri, 21 Jan 2022 12:14:39 +0000 (13:14 +0100)]
[flang] Update tco tool pipline and add translation to LLVM IR

tco is a tool to test the FIR to LLVM IR pipeline of the Flang compiler.

This patch update tco pipelines and adds the translation to LLVM IR.

A simple test is added to make sure the tool is working with a simple
FIR program.
More tests will be upstream in follow up patch from the fir-dev branch.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz, mehdi_amini

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com>
2 years ago[clang][deps] Handle symlinks in minimizing FS
Jan Svoboda [Fri, 21 Jan 2022 10:18:22 +0000 (11:18 +0100)]
[clang][deps] Handle symlinks in minimizing FS

The minimizing and caching filesystem used by the dependency scanner can be configured to **not** minimize some files. That's necessary when scanning a TU with prebuilt inputs (i.e. PCH) that refer to the original (non-minimized) files. Minimizing such files in the dependency scanner would cause discrepancy between the current perceived state of the filesystem and the file sizes stored in the AST file. By not minimizing such files, we avoid creating the discrepancy.

The problem with the current approach is that files that should not be minimized are identified by their path. This breaks down when the prebuilt input (PCH) and the current TU refer to the same file via different paths (i.e. symlinks). This patch switches from paths to `llvm::sys::fs::UniqueID` when identifying ignored files. This is consistent with how the rest of Clang treats files.

Depends on D114966.

Reviewed By: dexonsmith, arphaman

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

2 years ago[clang][deps] Ensure filesystem cache consistency
Jan Svoboda [Fri, 21 Jan 2022 09:55:34 +0000 (10:55 +0100)]
[clang][deps] Ensure filesystem cache consistency

The minimizing filesystem used by the dependency scanner isn't great when it comes to the consistency of its caches. There are two problems that can be exposed by a filesystem that changes during dependency scan:
1. In-memory cache entries for original and minimized files are distinct, populated at different times using separate stat/open syscalls. This means that when a file is read with minimization disabled, its contents might be inconsistent when the same file is read with minimization enabled at later point (and vice versa).
2. In-memory cache entries are indexed by filename. This is problematic for symlinks, where the contents of the symlink might be inconsistent with contents of the original file (for the same reason as in problem 1).

This patch ensures consistency by always stating/reading a file exactly once. The original contents are always cached and minimized contents are derived from that on demand. The cache entries are now indexed by their `UniqueID` ensuring consistency for symlinks too. Moreover, the stat/read syscalls are now issued outside of critical section.

Depends on D115935.

Reviewed By: dexonsmith

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

2 years ago[clang][deps] NFC: Simplify handling of cached FS errors
Jan Svoboda [Fri, 21 Jan 2022 09:54:27 +0000 (10:54 +0100)]
[clang][deps] NFC: Simplify handling of cached FS errors

The return types of some `CachedFileSystemEntry` member function are needlessly complex.

This patch attempts to simplify the code by unwrapping cached entries that represent errors early, and then asserting `!isError()`.

Reviewed By: dexonsmith

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

2 years ago[X86] Remove __builtin_ia32_pabs intrinsics and use generic __builtin_elementwise_abs
Simon Pilgrim [Fri, 21 Jan 2022 11:55:40 +0000 (11:55 +0000)]
[X86] Remove __builtin_ia32_pabs intrinsics and use generic __builtin_elementwise_abs

D111986 added the generic `__builtin_elementwise_abs()` intrinsic with the same integer absolute behaviour as the SSE/AVX instructions (abs(INT_MIN) == INT_MIN)

This patch removes the `__builtin_ia32_pabs*` intrinsics and just uses `__builtin_elementwise_abs` - the existing tests see no changes:
```
__m256i test_mm256_abs_epi8(__m256i a) {
  // CHECK-LABEL: test_mm256_abs_epi8
  // CHECK: [[ABS:%.*]] = call <32 x i8> @llvm.abs.v32i8(<32 x i8> %{{.*}}, i1 false)
  return _mm256_abs_epi8(a);
}
```
This requires us to add a `__v64qs` explicitly signed char vector type (we already have `__v16qs` and `__v32qs`).

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

2 years ago[clangd] Fail inlayHints requests on content changes
Kadir Cetinkaya [Thu, 20 Jan 2022 13:11:15 +0000 (14:11 +0100)]
[clangd] Fail inlayHints requests on content changes

This should improve the overall UX by making the labels less jumpy.

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

2 years ago[RISCV] Enable CGP to sink splat operands of VP intrinsics
Fraser Cormack [Wed, 19 Jan 2022 17:49:33 +0000 (17:49 +0000)]
[RISCV] Enable CGP to sink splat operands of VP intrinsics

This patch brings better splat-matching to our VP support, by sinking
splat operands of VP intrinsics back into the same block as the VP
operation. The list of VP intrinsics we are interested in matches that
of the regular instructions.

Some optimization is still lacking. For instance, our VL nodes aren't
recognized as commutative, so splats must be on the RHS. Because of
this, we limit our sinking of splats to just the RHS operand for now.
Improvement in this regard can come in another patch.

Reviewed By: craig.topper

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

2 years ago[mlir][LangRef] Add top-level production to the MLIR grammar
Siddharth Bhat [Fri, 21 Jan 2022 11:32:39 +0000 (17:02 +0530)]
[mlir][LangRef] Add top-level production to the MLIR grammar

The LangRef currently lacks a top-level production, leaving the productions attribute-alias-def and type-alias-defunused. Clarify the situation by declaring what is to be parsed by an MLIR parser at the toplevel.

Reviewed By: mehdi_amini

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

2 years ago[DWARF][DebugInfo] Fix off-by-one error in size of DW_TAG_base_type types
OCHyams [Fri, 21 Jan 2022 10:54:53 +0000 (10:54 +0000)]
[DWARF][DebugInfo] Fix off-by-one error in size of DW_TAG_base_type types

Fix PR53163 by rounding the byte size of DW_TAG_base_type types up. Without
this fix we risk emitting types with a truncated size (including rounding
less-than-byte-sized types' sizes down to zero).

Reviewed By: probinson

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

2 years ago[clangd][Background] Make index validation logs verbose
Kadir Cetinkaya [Thu, 20 Jan 2022 16:22:09 +0000 (17:22 +0100)]
[clangd][Background] Make index validation logs verbose

These errors are non-harmful and should be transient. They either
imply:
- compilation database returned stale results for TUs and it'll be fixed once
  it's updated to match project state.
- a TUs dependencies has changed and some headers no longer exist. this should
  be fixed with the next indexing cycle.

In either case the user will have some stale symbols in their index until clangd
restarts and the underlying issue is resolved. On the downside these logs are
confusing users when there's another issue.

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

2 years ago[Coroutines] Avoid some pointer element type accesses
Nikita Popov [Fri, 21 Jan 2022 11:34:35 +0000 (12:34 +0100)]
[Coroutines] Avoid some pointer element type accesses

These are just verifying that pointer types are correct, which is
no longer relevant under opaque pointers.

2 years ago[llvm-mca] Improve barriers for strict region marking (PR52198)
Simon Pilgrim [Fri, 21 Jan 2022 11:22:36 +0000 (11:22 +0000)]
[llvm-mca] Improve barriers for strict region marking (PR52198)

As suggested on the bug, to help (but not completely....) stop folded instructions crossing the inline asm barriers used for llvm-mca analysis, we should recommend tagging with memory captures/attributes.

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

2 years ago[CoroSplit] Avoid pointer element type accesses
Nikita Popov [Fri, 21 Jan 2022 11:20:23 +0000 (12:20 +0100)]
[CoroSplit] Avoid pointer element type accesses

Use isOpaqueOrPointeeTypeMatches() for the assertions instead.

2 years agoFix 1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d
serge-sans-paille [Fri, 21 Jan 2022 11:12:16 +0000 (12:12 +0100)]
Fix 1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d

Part 2

2 years ago[AMDGPU] Remove lz and nomip combine from codegen
Sebastian Neubauer [Tue, 21 Dec 2021 16:31:24 +0000 (17:31 +0100)]
[AMDGPU] Remove lz and nomip combine from codegen

These combines have been moved into the IR combiner in D116042.

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

2 years ago[AMDGPU][InstCombine] Remove zero LOD bias
Sebastian Neubauer [Tue, 21 Dec 2021 16:27:14 +0000 (17:27 +0100)]
[AMDGPU][InstCombine] Remove zero LOD bias

If the bias is zero, we can remove it from the image instruction.
Also copy other image optimizations (l->lz, mip->nomip) to IR combines.

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

2 years ago[AMDGPU] Fix LOD bias in A16 combine
Sebastian Neubauer [Mon, 20 Dec 2021 14:11:01 +0000 (15:11 +0100)]
[AMDGPU] Fix LOD bias in A16 combine

As the codegen fix in D111754, the LOD bias needs to be converted to 16
bits. Fix this in the combine.

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

2 years ago[AMDGPU][NFC] Regenerate InstCombine test
Sebastian Neubauer [Mon, 20 Dec 2021 13:25:16 +0000 (14:25 +0100)]
[AMDGPU][NFC] Regenerate InstCombine test

2 years ago[ORC][docs] Describe removing JITDylibs, using custom program representations.
Sameer Rahmani [Fri, 21 Jan 2022 10:27:55 +0000 (21:27 +1100)]
[ORC][docs] Describe removing JITDylibs, using custom program representations.

Add documentation around:
* Removing JITDylib from the session
* Add support for custom program representation

Reviewed By: lhames

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

2 years agoFix 1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d
serge-sans-paille [Fri, 21 Jan 2022 10:56:32 +0000 (11:56 +0100)]
Fix 1f9e18b6565fd1bb69c4b649b9efd3467b3c7c7d

Don't assume iterator on std::array<char, ...> are char*, use .data() instead

2 years ago[Attributor] Avoid some pointer element type accesses
Nikita Popov [Fri, 21 Jan 2022 10:19:54 +0000 (11:19 +0100)]
[Attributor] Avoid some pointer element type accesses

2 years ago[llvm] Remove (some) LLVMDemangle header dependencies
serge-sans-paille [Thu, 20 Jan 2022 10:21:47 +0000 (11:21 +0100)]
[llvm] Remove (some) LLVMDemangle header dependencies

- Avoid using <iterator> for std::end on a plain array (using <array> instead)
- Avoid using <algorithm> for std::min and std::equal (using alternate logic and std::strcmp instead)

As an hint to the impact of the cleanup, running

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Demangle/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l

before:  203965 lines
after:   169704 lines

2 years ago[VPlan] Move ::isCanonical outside ifdef.
Florian Hahn [Fri, 21 Jan 2022 09:44:31 +0000 (09:44 +0000)]
[VPlan] Move ::isCanonical outside ifdef.

This fixes a build failure with assertions disabled.

2 years ago[VPlan] Add VPWidenIntOrFpInductionRecipe::isCanonical, use it (NFCI).
Florian Hahn [Fri, 21 Jan 2022 09:34:38 +0000 (09:34 +0000)]
[VPlan] Add VPWidenIntOrFpInductionRecipe::isCanonical, use it (NFCI).

This patch adds VPWidenIntOrFpInductionRecipe::isCanonical to check if
an induction recipe is canonical. The code is also updated to use it
instead of isCanonicalID.

Reviewed By: Ayal

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

2 years ago[llvm] Remove unused headers in LLVMDemangle
serge-sans-paille [Thu, 20 Jan 2022 10:08:24 +0000 (11:08 +0100)]
[llvm] Remove unused headers in LLVMDemangle

As an hint to the impact of the cleanup, running

clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Demangle/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l

before: 208053 lines
after:  203965 lines

2 years ago[mlir] Fully qualify return types in OpAsmInterface.td and FunctionInterfaces.td
Markus Böck [Fri, 21 Jan 2022 09:03:48 +0000 (10:03 +0100)]
[mlir] Fully qualify return types in OpAsmInterface.td and FunctionInterfaces.td

2 years ago[fir] Add array operations documentation
Valentin Clement (バレンタイン クレメン) [Fri, 21 Jan 2022 08:56:26 +0000 (09:56 +0100)]
[fir] Add array operations documentation

This patch adds documentation on FIR array operations
and their usage.

Reviewed By: schweitz

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

2 years agoMatch bazel config with cmake after f29256a64
Tres Popp [Fri, 21 Jan 2022 08:49:55 +0000 (09:49 +0100)]
Match bazel config with cmake after f29256a64

2 years ago[ConstantFold] Allow all float types in reinterpret load folding
Nikita Popov [Fri, 21 Jan 2022 08:23:41 +0000 (09:23 +0100)]
[ConstantFold] Allow all float types in reinterpret load folding

Rather than hardcoding just half, float and double, allow all
floating point types.

2 years ago[InstSimplify] Add tests for reinterpret load of floats (NFC)
Nikita Popov [Fri, 21 Jan 2022 08:20:54 +0000 (09:20 +0100)]
[InstSimplify] Add tests for reinterpret load of floats (NFC)

Add tests for currently unsupported float types.

2 years ago[VE][NFC] Factor out helper functions
Simon Moll [Fri, 21 Jan 2022 08:15:50 +0000 (09:15 +0100)]
[VE][NFC] Factor out helper functions

Factor out some helper functions to cleanup VEISelLowering.

Reviewed By: kaz7

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

2 years ago[ConstantFold] Support pointers in reinterpret load folding
Nikita Popov [Thu, 20 Jan 2022 15:48:19 +0000 (16:48 +0100)]
[ConstantFold] Support pointers in reinterpret load folding

Peculiarly, the necessary code to handle pointers (including the
check for non-integral address spaces) is already in place,
because we were already allowing vectors of pointers here, just
not plain pointers.

2 years ago[ConstantFold] Simplify type check in reinterpret load folding (NFC)
Nikita Popov [Fri, 21 Jan 2022 08:06:35 +0000 (09:06 +0100)]
[ConstantFold] Simplify type check in reinterpret load folding (NFC)

Keep a list of allowed types, but then always construct the map
type the same way. We need an integer with the same width as the
original type.

2 years ago[mlir][Linalg] Avoid generating illegal operations during elementwise fusion.
MaheshRavishankar [Fri, 21 Jan 2022 06:27:06 +0000 (22:27 -0800)]
[mlir][Linalg] Avoid generating illegal operations during elementwise fusion.

In some cases, fusion can produce illegal operations if after fusion
the range of some of the loops cannot be computed from shapes of its
operands. Check for this case and abort the fusion if this happens.

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

2 years ago[RISCV] Bump rvv-related extensions from 0.10 to 1.0
eopXD [Thu, 20 Jan 2022 10:24:10 +0000 (02:24 -0800)]
[RISCV] Bump rvv-related extensions from 0.10 to 1.0

Reviewed By: craig.topper

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

2 years ago[libc][NFC] Add 'struct_' prefix to type headers defining struct types.
Siva Chandra Reddy [Fri, 21 Jan 2022 06:28:42 +0000 (06:28 +0000)]
[libc][NFC] Add 'struct_' prefix to type headers defining struct types.

This allows header generator to generate type inclusion boiler plate in
a straightforward manner.

2 years ago[DebugInfo][NFC] Do not call 'isRootFile' for DWARF Version < 5
Igor Kudrin [Fri, 21 Jan 2022 06:04:44 +0000 (13:04 +0700)]
[DebugInfo][NFC] Do not call 'isRootFile' for DWARF Version < 5

A quicker comparison should be done first.

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

2 years ago[DebugInfo] Fix handling '# line "file"' for DWARFv5
Igor Kudrin [Fri, 21 Jan 2022 06:04:32 +0000 (13:04 +0700)]
[DebugInfo] Fix handling '# line "file"' for DWARFv5

`CppHashInfo.Filename` is a `StringRef` that references a part of the
source file and it is not null-terminated at the end of the file name.
`AsmParser::parseAndMatchAndEmitTargetInstruction()` passes it to
`getStreamer().emitDwarfFileDirective()`, and it eventually comes to
`isRootFile()`. The comparison fails because `FileName.data()` is not
properly terminated.

In addition, the old code might cause a significant speed degradation
for long source files. The `operator!=()` for `std::string` and
`const char *` can be implemented in a way that it finds the length of
the second argument first, which slows the comparison for long data.
`parseAndMatchAndEmitTargetInstruction()` calls
`emitDwarfFileDirective()` every time if `CppHashInfo.Filename` is not
empty. As a result, the longer the source file is, the slower the
compilation wend, and for a very long file, it might take hours instead
of a couple of seconds normally.

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

2 years ago[RISCV] Set CostPerUse to 1 iff RVC is enabled
wangpc [Fri, 21 Jan 2022 05:54:09 +0000 (13:54 +0800)]
[RISCV] Set CostPerUse to 1 iff RVC is enabled

After D86836, we can define multiple cost values for
different cost models. So here we set CostPerUse to
1 iff RVC is enabled to avoid potential impact on RA.

Reviewed By: craig.topper

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

2 years ago[CSKY] Add codegen support of GlobalTLSAddress lowering
Zi Xuan Wu [Thu, 20 Jan 2022 09:44:53 +0000 (17:44 +0800)]
[CSKY] Add codegen support of GlobalTLSAddress lowering

There are static and dynamic TLS address lowering in DAG stage according to different TLS model.
It needs PseudoTLSLA32 pseudo to get address of TLS-related entry which resides in constant pool.

2 years ago[clang-tidy] Fix wrong FixIt in performance-move-const-arg
Sockke [Fri, 21 Jan 2022 06:23:52 +0000 (14:23 +0800)]
[clang-tidy] Fix wrong FixIt in performance-move-const-arg

There are incorrect Fixit and missing warnings:
case :
A trivially-copyable object wrapped by std::move is passed to the function with rvalue reference parameters. Removing std::move will cause compilation errors.
```
void showInt(int&&) {}
void testInt() {
    int a = 10;
    // expect: warning + nofix
    showInt(std::move(a));  // showInt(a) <--- wrong fix
}

struct Tmp {};
void showTmp(Tmp&&) {}
void testTmp() {
    Tmp t;
    // expect: warning + nofix
    showTmp(std::move(t));  // showTmp(t) <--- wrong fix
}
```

Reviewed By: aaron.ballman, Quuxplusone

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

2 years agoRemove obsolete `getAsmResultNames` from OpAsmDialectInterface
Mehdi Amini [Fri, 21 Jan 2022 05:45:48 +0000 (05:45 +0000)]
Remove obsolete `getAsmResultNames` from OpAsmDialectInterface

This is superseded by the same method on OpAsmOpInterface, which is
available on the Dialect through the Fallback mechanism,

Reviewed By: rriddle

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

2 years ago[mlir][python] 8b/16b DenseIntElements access
Rahul Kayaith [Fri, 21 Jan 2022 05:21:00 +0000 (05:21 +0000)]
[mlir][python] 8b/16b DenseIntElements access

This extends dense attribute element access to support 8b and 16b ints.
Also extends the corresponding parts of the C api.

Reviewed By: ftynse

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

2 years agoPrint the `// ----` separator between modules when using -split-input-file with mlir-opt
Mehdi Amini [Fri, 21 Jan 2022 05:15:46 +0000 (05:15 +0000)]
Print the `// ----` separator between modules when using -split-input-file with mlir-opt

This allows to pipe sequences of `mlir-opt -split-input-file | mlir-opt -split-input-file`.

Depends On D117750

Reviewed By: rriddle

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

2 years ago[RISCV] Add isel patterns for grevi, shfli, and unshfli to brev8/zip/unzip instructions.
Craig Topper [Fri, 21 Jan 2022 04:43:48 +0000 (20:43 -0800)]
[RISCV] Add isel patterns for grevi, shfli, and unshfli to brev8/zip/unzip instructions.

Zbkb supports some encodings of the general grevi, shfli, and
unshfli instructions legal, so we added separate instructions for
those encodings to improve the diagnostics for assembler and
disassembler. To be consistent we should always use these separate
instructions whenever those specific encodings of grevi/shfli/unshfli
occur. So this patch adds specific isel patterns to override the generic
isel patterns for these cases. Similar was done for rev8 and zext.h
for Zbb previously.

2 years ago[RISCV][RFC] add inst support of zbkb
Wu Xinlong [Thu, 20 Jan 2022 08:35:55 +0000 (16:35 +0800)]
[RISCV][RFC] add inst support of zbkb

This commit add instructions supports of `zbkb` which defined in scalar cryptography extension version v1.0.0 (has been ratified already).

Most of the zbkb directives reuse parts of the zbp and zbb directives, so this patch just modified some of the inst aliases and predicates.

Reviewed By: craig.topper

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

2 years ago[X86] Enable ibt-seal optimization when LTO is used in Kernel
Joao Moreira [Fri, 21 Jan 2022 01:31:21 +0000 (09:31 +0800)]
[X86] Enable ibt-seal optimization when LTO is used in Kernel

Intel's CET/IBT requires every indirect branch target to be an ENDBR instruction. Because of that, the compiler needs to correctly emit these instruction on function's prologues. Because this is a security feature, it is desirable that only actual indirect-branch-targeted functions are emitted with ENDBRs. While it is possible to identify address-taken functions through LTO, minimizing these ENDBR instructions remains a hard task for user-space binaries because exported functions may end being reachable through PLT entries, that will use an indirect branch for such. Because this cannot be determined during compilation-time, the compiler currently emits ENDBRs to every non-local-linkage function.

Despite the challenge presented for user-space, the kernel landscape is different as no PLTs are used. With the intent of providing the most fit ENDBR emission for the kernel, kernel developers proposed an optimization named "ibt-seal" which replaces the ENDBRs for NOPs directly in the binary. The discussion of this feature can be seen in [1].

This diff brings the enablement of the flag -mibt-seal, which in combination with LTO enforces a different policy for ENDBR placement in when the code-model is set to "kernel". In this scenario, the compiler will only emit ENDBRs to address taken functions, ignoring non-address taken functions that are don't have local linkage.

A comparison between an LTO-compiled kernel binaries without and with the -mibt-seal feature enabled shows that when -mibt-seal was used, the number of ENDBRs in the vmlinux.o binary patched by objtool decreased from 44383 to 33192, and that the number of superfluous ENDBR instructions nopped-out decreased from 11730 to 540.

The 540 missed superfluous ENDBRs need to be investigated further, but hypotheses are: assembly code not being taken care of by the compiler, kernel exported symbols mechanisms creating bogus address taken situations or even these being removed due to other binary optimizations like kernel's static_calls. For now, I assume that the large drop in the number of ENDBR instructions already justifies the feature being merged.

[1] - https://lkml.org/lkml/2021/11/22/591

Reviewed By: xiangzhangllvm

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

2 years agoRevert "[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs."
John Ericson [Fri, 21 Jan 2022 02:48:10 +0000 (02:48 +0000)]
Revert "[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs."

https://lab.llvm.org/buildbot/#/builders/36/builds/16668 was the sort of
thing I saw before when this was part of D99484, and it makes some sense
now this would have something to do with it.

This reverts commit 58580e922a69d94859a2506c3053d8c066a1e38c.

2 years ago[lldb] Update the modulemap
Jonas Devlieghere [Fri, 21 Jan 2022 02:28:17 +0000 (18:28 -0800)]
[lldb] Update the modulemap

2 years ago[gn build] Port 1755f5b1d7b7
LLVM GN Syncbot [Fri, 21 Jan 2022 02:11:31 +0000 (02:11 +0000)]
[gn build] Port 1755f5b1d7b7

2 years ago[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs.
John Ericson [Thu, 20 Jan 2022 22:20:24 +0000 (22:20 +0000)]
[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs.

If `CMAKE_INSTALL_BINDIR` is a different absolute path per project, as
it is with NixOS when we install every package to its own prefix, the
old way fails when the absolute path gets prepended.

There are still some issues with dowstream packages using `LLVM_TOOLS_INSTALL_DIR` which also may be absolute and just for LLVM proper, but that will be addressed in a future commit.

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

2 years ago[Libomptarget] Change visibility to hidden for device RTL
Joseph Huber [Thu, 20 Jan 2022 18:06:22 +0000 (13:06 -0500)]
[Libomptarget] Change visibility to hidden for device RTL

This patch changes the visibility for all construct in the new device
RTL to be hidden by default. This is done after the changes introduced
in D117806 changed the visibility from being hidden by default for all
device compilations. This asserts that the visibility for the device
runtime library will be hidden except for the internal environment
variable. This is done to aid optimization and linking of the device
library.

Reviewed By: JonChesterfield

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

2 years ago[OpenMP] Change default visibility to protected for device declarations
Joseph Huber [Thu, 20 Jan 2022 17:06:47 +0000 (12:06 -0500)]
[OpenMP] Change default visibility to protected for device declarations

This patch changes the special-case handling of visibility when
compiling for an OpenMP target offloading device. This was orignally
added as a precaution against the bug encountered in PR41826 when
symbols in the device were being preempted by shared library symbols.
This should instead be done by making the visibility protected by default.
With protected visibility we are asserting that the symbols on the device
will never be preempted or preempt another symbol pending a shared library
load.

Reviewed By: JonChesterfield

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

2 years ago[lldb] Instrument SB API with signposts
Jonas Devlieghere [Thu, 20 Jan 2022 23:50:27 +0000 (15:50 -0800)]
[lldb] Instrument SB API with signposts

Instrument the SB API with signposts on Darwin. This gives us a time
profile on whose behalf LLDB spends time (particularly when run via the
SBAPI from an IDE).

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

2 years ago[lldb] Decouple instrumentation from the reproducers
Jonas Devlieghere [Wed, 19 Jan 2022 19:38:26 +0000 (11:38 -0800)]
[lldb] Decouple instrumentation from the reproducers

Remove the last remaining references to the reproducers from the
instrumentation. This patch renames the relevant files and macros.

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

2 years ago[lldb] Revive lldb-instr
Jonas Devlieghere [Thu, 20 Jan 2022 20:08:20 +0000 (12:08 -0800)]
[lldb] Revive lldb-instr

I revived lldb-instr to update the macros for D117712. I think the new
macros are simple enough that we add them by hand, but this tool can do
it automatically for you.

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

2 years ago[RISCV] Fix the bug in the register allocator caused by reserved BP.
Hsiangkai Wang [Wed, 19 Jan 2022 11:32:27 +0000 (11:32 +0000)]
[RISCV] Fix the bug in the register allocator caused by reserved BP.

Originally, hasRVVFrameObject() will scan all the stack objects to check
whether if there is any scalable vector object on the stack or not.
However, it causes errors in the register allocator. In issue 53016, it
returns false before RA because there is no RVV stack objects. After RA,
it returns true because there are spilling slots for RVV values during RA.
The compiler will not reserve BP during register allocation and generate BP
access in the PEI pass due to the inconsistent behavior of the function.

The function is changed to use hasStdExtV() as the return value. It is
not precise, but it can make the register allocation correct.

Refer to https://github.com/llvm/llvm-project/issues/53016.

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

2 years ago[flang] Extension: skip over NAMELIST groups
Peter Klausler [Thu, 13 Jan 2022 01:34:52 +0000 (17:34 -0800)]
[flang] Extension: skip over NAMELIST groups

Implements a near-universal extension in which NAMELIST
input will skip over unrelated namelist groups in the
input stream until the group with the requested name appears.

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

2 years ago[flang] Allow explicit '+' in NAMELIST input subscripts
Peter Klausler [Wed, 12 Jan 2022 23:10:20 +0000 (15:10 -0800)]
[flang] Allow explicit '+' in NAMELIST input subscripts

Array subscripts and substring limits in NAMELIST input are
allowed to bear an explicit plus sign.

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

2 years ago[RISCV] Factor Zve32 support into RISCVSubtarget::getMaxELENForFixedLengthVectors.
Craig Topper [Thu, 20 Jan 2022 23:24:06 +0000 (15:24 -0800)]
[RISCV] Factor Zve32 support into RISCVSubtarget::getMaxELENForFixedLengthVectors.

This is needed to properly limit fractional LMULs for Zve32.

Add new RUN Zve32 RUN lines to the existing tests for the
-riscv-v-fixed-length-vector-elen-max command line option.

2 years ago[InstCombine] Simplify bswap -> shift
Pawe Bylica [Thu, 20 Jan 2022 23:56:38 +0000 (00:56 +0100)]
[InstCombine] Simplify bswap -> shift

Simplify bswap(x) to shl(x) or lshr(x) if x has exactly one
"active byte", i.e. all active bits are contained in boundaries
of a single byte of x.

https://alive2.llvm.org/ce/z/nvbbU5
https://alive2.llvm.org/ce/z/KiiL3J

Reviewed By: spatel, craig.topper, lebedev.ri

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

2 years ago[Attributor][FIX] AAValueConstantRange should not loop unconstrained
Johannes Doerfert [Thu, 20 Jan 2022 23:52:41 +0000 (17:52 -0600)]
[Attributor][FIX] AAValueConstantRange should not loop unconstrained

The old method to avoid unconstrained expansion of the constant range in
a loop did not work as soon as there were multiple instructions in
between the phi and its input. We now take a generic approach and limit
the number of updates as a fallback. The old method is kept as it
catches "the common case" early.

2 years ago[Attributor][NFC] Clang format
Johannes Doerfert [Fri, 21 Jan 2022 00:04:32 +0000 (18:04 -0600)]
[Attributor][NFC] Clang format

2 years ago[clang-tidy] Include constructor initializers in `bugprone-exception-escape` check
Fabian Wolff [Thu, 20 Jan 2022 21:51:53 +0000 (22:51 +0100)]
[clang-tidy] Include constructor initializers in `bugprone-exception-escape` check

Fixes PR#52435.

Reviewed By: aaron.ballman

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

2 years ago[OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images
Dave Airlie [Thu, 20 Jan 2022 23:49:41 +0000 (09:49 +1000)]
[OpenCL] opencl-c.h: add __opencl_c_images and  __opencl_c_read_write_images

This wraps the image and rw images usages in the correct macros

Reviewed By: Anastasia

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

2 years ago[flang] Handle FLUSH(unknown unit)
Peter Klausler [Wed, 12 Jan 2022 23:48:06 +0000 (15:48 -0800)]
[flang] Handle FLUSH(unknown unit)

The unit number passed to a FLUSH statement is not required to
be a valid open unit; nothing happens (esp. not the creation of
an empty fort.n file) in this case.

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

2 years ago[flang] Fix OPEN/WRITE(SIGN='SUPPRESS')
Peter Klausler [Tue, 11 Jan 2022 22:54:31 +0000 (14:54 -0800)]
[flang] Fix OPEN/WRITE(SIGN='SUPPRESS')

The keyword value was misspelled in the runtime.

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

2 years ago[libc] Use __builtin_clz to find leading 1 in hypot
Clint Caywood [Thu, 20 Jan 2022 23:27:05 +0000 (23:27 +0000)]
[libc] Use __builtin_clz to find leading 1 in hypot

This is an optimization that using a single CPU instruction on supported
architectures (amd64 and aarch64, but possibly others) to replace what was
previously an iterative look-up-table algorithm.

Originally I suggested using inline assembly for this in
https://reviews.llvm.org/D117584.

Reviewed By: lntue, sivachandra

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

2 years ago[lld][WebAssembly] Remove redundant config setting
Sam Clegg [Thu, 20 Jan 2022 02:17:08 +0000 (18:17 -0800)]
[lld][WebAssembly] Remove redundant config setting

Unresolved symbols are not currently reported when building with
`-shared` or `-pie` so setting unresolvedSymbols doesn't have any
effect.

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

2 years ago[test] Add tests for bswap combining. NFC
Paweł Bylica [Thu, 20 Jan 2022 20:16:46 +0000 (21:16 +0100)]
[test] Add tests for bswap combining. NFC

2 years ago[clang-tidy] Update bugprone-stringview-nullptr to consistently prefer the empty...
CJ Johnson [Thu, 20 Jan 2022 23:05:07 +0000 (18:05 -0500)]
[clang-tidy] Update bugprone-stringview-nullptr to consistently prefer the empty string when passing arguments to constructors/functions

Previously, function(nullptr) would have been fixed with function({}). This unfortunately can change overload resolution and even become ambiguous. T(nullptr) was already being fixed with T(""), so this change just brings function calls in line with that.

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

2 years ago[RISCV] Remove RISCVSubtarget::hasStdExtV() and hasStdExtZve*(). NFC
Craig Topper [Thu, 20 Jan 2022 22:57:31 +0000 (14:57 -0800)]
[RISCV] Remove RISCVSubtarget::hasStdExtV() and hasStdExtZve*(). NFC

All code should use one of the cleaner named hasVInstructions*
functions. Fix the two uses that weren't and delete the methods
so no new uses can be created.

2 years ago[libc] Move the remaining public types to their own type headers.
Siva Chandra Reddy [Thu, 20 Jan 2022 08:11:54 +0000 (08:11 +0000)]
[libc] Move the remaining public types to their own type headers.

Reviewed By: michaelrj

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