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
serge-sans-paille [Fri, 21 Jan 2022 13:01:51 +0000 (14:01 +0100)]
Add missing header in Support/ConvertUTF.h
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
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
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
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
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>
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
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
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
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
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
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
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
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
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
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.
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
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.
serge-sans-paille [Fri, 21 Jan 2022 11:12:16 +0000 (12:12 +0100)]
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
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
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
Sebastian Neubauer [Mon, 20 Dec 2021 13:25:16 +0000 (14:25 +0100)]
[AMDGPU][NFC] Regenerate InstCombine test
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
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
Nikita Popov [Fri, 21 Jan 2022 10:19:54 +0000 (11:19 +0100)]
[Attributor] Avoid some pointer element type accesses
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
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.
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
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
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
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
Tres Popp [Fri, 21 Jan 2022 08:49:55 +0000 (09:49 +0100)]
Match bazel config with cmake after
f29256a64
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.
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.
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
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.
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.
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
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
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.
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
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
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
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.
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
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
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
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
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.
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
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
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.
Jonas Devlieghere [Fri, 21 Jan 2022 02:28:17 +0000 (18:28 -0800)]
[lldb] Update the modulemap
LLVM GN Syncbot [Fri, 21 Jan 2022 02:11:31 +0000 (02:11 +0000)]
[gn build] Port
1755f5b1d7b7
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
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
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
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
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
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
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
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
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
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.
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
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.
Johannes Doerfert [Fri, 21 Jan 2022 00:04:32 +0000 (18:04 -0600)]
[Attributor][NFC] Clang format
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
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
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
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
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
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
Paweł Bylica [Thu, 20 Jan 2022 20:16:46 +0000 (21:16 +0100)]
[test] Add tests for bswap combining. NFC
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
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.
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
Craig Topper [Thu, 20 Jan 2022 22:16:37 +0000 (14:16 -0800)]
[RISCV] Optimize vector_shuffles that are interleaving the lowest elements of two vectors.
RISCV only has a unary shuffle that requires places indices in a
register. For interleaving two vectors this means we need at least
two vrgathers and a vmerge to do a shuffle of two vectors.
This patch teaches shuffle lowering to use a widening addu followed
by a widening vmaccu to implement the interleave. First we extract
the low half of both V1 and V2. Then we implement
(zext(V1) + zext(V2)) + (zext(V2) * zext(2^eltbits - 1)) which
simplifies to (zext(V1) + zext(V2) * 2^eltbits). This further
simplifies to (zext(V1) + zext(V2) << eltbits). Then we bitcast the
result back to the original type splitting the wide elements in half.
We can only do this if we have a type with wider elements available.
Because we're using extends we also have to be careful with fractional
lmuls. Floating point types are supported by bitcasting to/from integer.
The tests test a varied combination of LMULs split across VLEN>=128 and
VLEN>=512 tests. There a few tests with shuffle indices commuted as well
as tests for undef indices. There's one test for a vXi64/vXf64 vector which
we can't optimize, but verifies we don't crash.
Reviewed By: rogfer01
Differential Revision: https://reviews.llvm.org/D117743
Rob Suderman [Thu, 20 Jan 2022 22:32:19 +0000 (14:32 -0800)]
[mlir][tosa] Limit right-shift to 31 bits
Right shift can occur that is a 32-bit right shift. This is undefined behavior.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D117732
owenca [Thu, 20 Jan 2022 09:59:52 +0000 (01:59 -0800)]
[clang-format][NFC] Clean up tryMergeLessLess()
Differential Revision: https://reviews.llvm.org/D117759
Nathan James [Thu, 20 Jan 2022 22:20:10 +0000 (22:20 +0000)]
[clang-tidy][NFC] Remove redundant string creation for comparison
Michael Kruse [Thu, 20 Jan 2022 16:42:17 +0000 (10:42 -0600)]
[OpenMPIRBuilder] Detect ambiguous InsertPoints for apply*WorkshareLoop. NFC.
Follow-up on D117226 for applyStaticWorkshareLoop and
applyDynamicWorkshareLoop checking for conflicting InertPoints via an
assert. There is no in-tree code that violates this assertion, hence
nothing changes.
Philip Reames [Thu, 20 Jan 2022 22:07:46 +0000 (14:07 -0800)]
[SLP] Remove stray semicolon to make bots happy
Certain bots (e.g. sanitizer-x86_64-linux-android) appear to be running with strict c++98 flags which disallow ; at global scope.
Stanislav Mekhanoshin [Wed, 1 Dec 2021 21:44:42 +0000 (13:44 -0800)]
[AMDGPU] Do not ignore exec use where exec is read as data
Compares, v_cndmask_b32, and v_readfirstlane_b32 use EXEC
in a way which modifies the result. This implicit EXEC use
shall not be ignored for the purposes of instruction moves.
Differential Revision: https://reviews.llvm.org/D117814
Philip Reames [Thu, 20 Jan 2022 21:58:13 +0000 (13:58 -0800)]
[SLP] Kill an unused param and use a for-loop in calculateDependencies [NFC]
Adrian Prantl [Thu, 20 Jan 2022 21:36:55 +0000 (13:36 -0800)]
Work around a module build failure on the bots.
This patch works around what looks like a bug in Clang itself.
The error on the bot is:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/40466/consoleText
In module 'LLVM_Utils' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h:18:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/Support/Error.h:720:3: error: 'llvm::Expected<bool>::(anonymous)' from module 'LLVM_Utils.Support.Error' is not present in definition of 'llvm::Expected<bool>' in module 'LLVM_Utils.Support.Error'
union {
^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/Support/Error.h:720:3: note: declaration of '' does not match
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/Support/Error.h:720:3: note: declaration of '' does not match
1 error generated.
The intention is to revert this as soon as a proper fix has been identified!
rdar://
87845391
John Ericson [Tue, 18 Jan 2022 23:34:54 +0000 (23:34 +0000)]
[cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm
We previously had a few varied definitions of this floating around. I made the one installed with LLVM handle all the cases, and then made the others use it.
This issue was reported to me in https://reviews.llvm.org/D116521#3248117 as
D116521 made clang and llvm use the common cmake utils.
Reviewed By: sebastian-ne, phosek, #libunwind, #libc, #libc_abi, ldionne
Differential Revision: https://reviews.llvm.org/D117537
John Ericson [Thu, 20 Jan 2022 19:04:15 +0000 (19:04 +0000)]
[compiler-rt][cmake] Use HandleOutOfTreeLLVM like libcxx and friends
This gives us the option of using CMake modules from LLVM, and other
things. We will use that to deduplicate code later.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D117815
Tue Ly [Thu, 20 Jan 2022 18:51:04 +0000 (13:51 -0500)]
[libc] Make log2f correctly rounded for all rounding modes when FMA is not available.
Add to log2f 2 more exceptional cases got when not using fma for polyeval.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D117812
River Riddle [Thu, 20 Jan 2022 20:54:03 +0000 (12:54 -0800)]
[mlir:TiingInterface] Remove unnecessary include of Tensor.h
Interfaces in Interfaces/ should not depend on any dialects, and this include
is unnecessary anyways.
Philip Reames [Thu, 20 Jan 2022 21:06:55 +0000 (13:06 -0800)]
[SLP] Extract formBundle helper for readability [NFC]
Sanjay Patel [Thu, 20 Jan 2022 19:51:45 +0000 (14:51 -0500)]
[InstCombine] convert mul with sexted bool and constant to select
We already have the related folds for zext-of-bool, so it
should make things more consistent to have this transform
to select for sext-of-bool too:
https://alive2.llvm.org/ce/z/YikdfA
Fixes #53319
Sanjay Patel [Thu, 20 Jan 2022 19:41:01 +0000 (14:41 -0500)]
[InstCombine] add/adjust tests for multiply with extended bool; NFC
Craig Topper [Thu, 20 Jan 2022 20:53:12 +0000 (12:53 -0800)]
[RISCV] Remove HadStdExtV and HasStdZve* Predicates from tablegen.
No instructions should be using these. Everything should use
HasVInstructions* Predicates. Remove them so that they can't be
used by accident.
Krzysztof Drewniak [Mon, 10 Jan 2022 23:53:58 +0000 (23:53 +0000)]
[MLIR][GPU] Add debug output to enable dumping GPU assembly
- Set the DEBUG_TYPE of SerializeToBlob to serialize-to-blob
- Add debug output to print the assembly or PTX for GPU modules before
they are assembled and linked
Note that, as SerializeToBlob is a superclass of SerializeToCubin and
SerializeToHsaco, --debug-only=serialize-to-blom will dump the
intermediate compiler result for both of these passes.
In addition, if LLVM options such as --stop-after are used to control
the GPU kernel compilation process, the debug output will contain the
appropriate intermediate IR.
Reviewed By: herhut
Differential Revision: https://reviews.llvm.org/D117519
Philip Reames [Thu, 20 Jan 2022 20:44:20 +0000 (12:44 -0800)]
[SLP] Use for loops for walking bundle elements
Craig Topper [Thu, 20 Jan 2022 19:49:35 +0000 (11:49 -0800)]
[RISCV] Remove Zvlsseg extension.
This string no longer appears in the Vector Extension specification.
The segment load/store instructions are just part of the vector
instruction set.
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D117724
Mogball [Thu, 20 Jan 2022 20:17:40 +0000 (20:17 +0000)]
[mlir][pdl] Make `pdl` the default dialect when parsing/printing
PDLDialect being a somewhat user-facing dialect and whose ops contain exclusively other PDL ops in their regions can take advantage of `OpAsmOpInterface` to provide nicer IR.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D117828