Kazushi (Jam) Marukawa [Sat, 5 Dec 2020 07:53:39 +0000 (16:53 +0900)]
[VE] Correct LVLGen (LVL instruction insert pass)
SX Aurora VE uses an intermediate representation similar to VP as its MIR.
VE itself uses invidiual VL register as its own vector length register at
the hardware level. So, LLVM needs to insert load VL (LVL) instruction just
before vector instructions if the value of VL is changed. This LVLGen pass
generates LVL instructions for such purpose. Previously, a bug is pointed
out in D91416. This patch correct this bug and add a regression test.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D92716
Fangrui Song [Tue, 8 Dec 2020 21:24:58 +0000 (13:24 -0800)]
[Driver] Add -gno-split-dwarf which can disable debug fission
Currently when -gsplit-dwarf is specified (could be buried in a build system),
there is no convenient way to cancel debug fission without affecting the debug
information amount (all of -g0, -g1 -fsplit-dwarf-inlining and -gline-directives-only
can, but they affect the debug information amount).
Reviewed By: #debug-info, dblaikie
Differential Revision: https://reviews.llvm.org/D92809
Siva Chandra Reddy [Tue, 8 Dec 2020 06:46:03 +0000 (22:46 -0800)]
[libc] Raise x87 exceptions by synchronizing with "fwait".
Couple of helper functions enableExcept and disableExcept have been
added. In a later round, they will be used to implemented the GNU
extension functions feenableexcept and fedisableexcept.
Differential Revision: https://reviews.llvm.org/D92821
Saleem Abdulrasool [Fri, 6 Nov 2020 00:01:20 +0000 (00:01 +0000)]
APINotes: add bitcode format schema definitions
This adds the bitcode format schema required for serialization of the
YAML data to a binary format. APINotes are pre-compiled and re-used in
the binary format from the frontend. These definitions provide the data
layout representation enabling writing (and eventually) reading of the
data in bitcode format.
This is extracted from the code contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.
Differential Revision: https://reviews.llvm.org/D91997
Reviewed By: Gabor Marton
Saleem Abdulrasool [Tue, 29 Sep 2020 21:16:02 +0000 (21:16 +0000)]
Bitcode: add some convenience helpers for streaming bitcode
This adds a set of metaprogramming helpers to help define records and
serialize them out. This is motivated by API Notes which use the
bitcode format to serialize out a binary representation of the data.
These helpers are generically useful though and could help simplify some
of the existing bitcode consumers as well.
This is extracted from the code contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.
Differential Revision: https://reviews.llvm.org/D88582
Fangrui Song [Tue, 8 Dec 2020 21:14:34 +0000 (13:14 -0800)]
[Driver] Don't make -gsplit-dwarf imply -g2
RFC: http://lists.llvm.org/pipermail/cfe-dev/2020-May/065430.html
Agreement from GCC: https://sourceware.org/pipermail/gcc-patches/2020-May/545688.html
g_flags_Group options generally don't affect the amount of debugging
information. -gsplit-dwarf is an exception. Its order dependency with
other gN_Group options make it inconvenient in a build system:
* -g0 -gsplit-dwarf -> level 2
-gsplit-dwarf "upgrades" the amount of debugging information despite
the previous intention (-g0) to drop debugging information
* -g1 -gsplit-dwarf -> level 2
-gsplit-dwarf "upgrades" the amount of debugging information.
* If we have a higher-level -gN, -gN -gsplit-dwarf will supposedly decrease the
amount of debugging information. This happens with GCC -g3.
The non-orthogonality has confused many users. GCC 11 will change the semantics
(-gsplit-dwarf no longer implies -g2) despite the backwards compatibility break.
This patch matches its behavior.
New semantics:
* If there is a g_Group, allow split DWARF if useful
(none of: -g0, -gline-directives-only, -g1 -fno-split-dwarf-inlining)
* Otherwise, no-op.
To restore the original behavior, replace -gsplit-dwarf with -gsplit-dwarf -g.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D80391
Florian Hahn [Tue, 8 Dec 2020 20:20:17 +0000 (20:20 +0000)]
[AArch64] Fix rottype use in complex instr defs.
It seems like the order here is wrong. Types like i32 do not take any
arguments.
Currently this is not a problem, because the patterns are not actually
used with any nodes, but will fail once it is used with real ISD nodes.
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D91345
Harald van Dijk [Tue, 8 Dec 2020 21:06:00 +0000 (21:06 +0000)]
[X86] Handle localdynamic TLS model in x32 mode
D92346 added TLS_(base_)addrX32 to handle TLS in x32 mode, but missed the
different TLS models. This diff fixes the logic for the local dynamic model
where `RAX` was used when `EAX` should be, and extends the tests to cover
all four TLS models.
Fixes https://bugs.llvm.org/show_bug.cgi?id=26472.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D92737
Duncan P. N. Exon Smith [Tue, 10 Nov 2020 15:25:48 +0000 (10:25 -0500)]
Frontend: Clarify logic for using the preamble in ASTUnit::CodeComplete, almost NFC
Clarify the logic for using the preamble (and overriding the main file
buffer) in `ASTUnit::CodeComplete` by factoring out a couple of lambdas
(`getUniqueID` and `hasSameUniqueID`). While refactoring the logic,
hoist the check for `Line > 1` and locally check if the filenames are
equal (both to avoid unnecessary `stat` calls) and skip copying out the
filenames to `std::string`.
Besides fewer calls to `stat`, there's no functionality change here.
Differential Revision: https://reviews.llvm.org/D91296
Louis Dionne [Tue, 8 Dec 2020 20:45:57 +0000 (15:45 -0500)]
[libc++] Implement missing feature-test macro __cpp_lib_shared_ptr_arrays
This was forgotten when we implemented support for arrays in std::shared_ptr
in https://reviews.llvm.org/D62259.
Louis Dionne [Tue, 8 Dec 2020 20:42:33 +0000 (15:42 -0500)]
[libc++] NFC: Indent feature-test macro script consistently
Nathan James [Tue, 8 Dec 2020 20:28:42 +0000 (20:28 +0000)]
[clang-tidy] Add support for diagnostics with no location
Add methods for emitting diagnostics with no location as well as a special diagnostic for configuration errors.
These show up in the errors as [clang-tidy-config].
The reason to use a custom name rather than the check name is to distinguish the error isn't the same category as the check that reported it.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D91885
Austin Kerbow [Fri, 6 Nov 2020 07:43:58 +0000 (23:43 -0800)]
[AMDGPU] Add new pseudos for indirect addressing with VGPR Indexing
It is possible for copies or spills to be inserted in the middle of indirect
addressing sequences which use VGPR indexing. Spills to accvgprs could be
effected by the indexing mode.
Add new pseudo instructions that are expanded after register allocation to avoid
the problematic spill or copy placement.
Differential Revision: https://reviews.llvm.org/D91048
Craig Topper [Tue, 8 Dec 2020 19:29:05 +0000 (11:29 -0800)]
[RISCV] Add isel patterns for SBCLRI/SBSETI/SBINVI(W) instruction
We can use these instructions for single bit immediates that are too large for ANDI/ORI/CLRI.
The _10 test cases are to make sure that we still use ANDI/ORI/CLRI for small immediates.
Differential Revision: https://reviews.llvm.org/D92262
LLVM GN Syncbot [Tue, 8 Dec 2020 20:15:45 +0000 (20:15 +0000)]
[gn build] Port
39431e479ff
LLVM GN Syncbot [Tue, 8 Dec 2020 20:15:44 +0000 (20:15 +0000)]
[gn build] Port
1821265db68
Valentin Clement [Tue, 8 Dec 2020 20:14:24 +0000 (15:14 -0500)]
[flang][openacc] Avoid use of init, shutdown and set in compute construct
init, shutdown and set directive are not allowed in compute construct.
Reviewed By: SouraVX
Differential Revision: https://reviews.llvm.org/D92443
Roman Lebedev [Tue, 8 Dec 2020 19:54:56 +0000 (22:54 +0300)]
[clang-tidy] Introduce misc No Integer To Pointer Cast check
While casting an (integral) pointer to an integer is obvious - you just get
the integral value of the pointer, casting an integer to an (integral) pointer
is deceivingly different. While you will get a pointer with that integral value,
if you got that integral value via a pointer-to-integer cast originally,
the new pointer will lack the provenance information from the original pointer.
So while (integral) pointer to integer casts are effectively no-ops,
and are transparent to the optimizer, integer to (integral) pointer casts
are *NOT* transparent, and may conceal information from optimizer.
While that may be the intention, it is not always so. For example,
let's take a look at a routine to align the pointer up to the multiple of 16:
The obvious, naive implementation for that is:
```
char* src(char* maybe_underbiased_ptr) {
uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
return (char*)aligned_intptr; // warning: avoid integer to pointer casts [misc-no-inttoptr]
}
```
The check will rightfully diagnose that cast.
But when provenance concealment is not the goal of the code, but an accident,
this example can be rewritten as follows, without using integer to pointer cast:
```
char*
tgt(char* maybe_underbiased_ptr) {
uintptr_t maybe_underbiased_intptr = (uintptr_t)maybe_underbiased_ptr;
uintptr_t aligned_biased_intptr = maybe_underbiased_intptr + 15;
uintptr_t aligned_intptr = aligned_biased_intptr & (~15);
uintptr_t bias = aligned_intptr - maybe_underbiased_intptr;
return maybe_underbiased_ptr + bias;
}
```
See also:
* D71499
* [[ https://www.cs.utah.edu/~regehr/oopsla18.pdf | Juneyoung Lee, Chung-Kil Hur, Ralf Jung, Zhengyang Liu, John Regehr, and Nuno P. Lopes. 2018. Reconciling High-Level Optimizations and Low-Level Code in LLVM. Proc. ACM Program. Lang. 2, OOPSLA, Article 125 (November 2018), 28 pages. ]]
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D91055
Chih-Ping Chen [Tue, 8 Dec 2020 18:34:33 +0000 (13:34 -0500)]
[DebugInfo] Add handling of stringLengthExp operand of DIStringType.
This patch makes DWARF writer emit DW_AT_string_length using
the stringLengthExp operand of DIStringType.
This is part of the effort to add debug info support for
Fortran deferred length strings.
Also updated the tests to exercise the change.
Differential Revision: https://reviews.llvm.org/D92412
Arthur Eubanks [Tue, 8 Dec 2020 18:30:45 +0000 (10:30 -0800)]
[llvm-lto2] Use NPM with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D92870
Raphael Isemann [Tue, 8 Dec 2020 19:40:59 +0000 (20:40 +0100)]
[cmake] Make ExecutionEngine/Orc/Shared depend on intrinsics_gen to fix modules build
The LLVM_ENABLE_MODULES builds currently randomly fail due depending on the
headers generated by the intrinsics_gen target, but the current dependency only model
the non-modules dependencies:
```
While building module 'LLVM_ExecutionEngine' imported from llvm-project/llvm/lib/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.cpp:13:
While building module 'LLVM_intrinsic_gen' imported from llvm-project/llvm/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h:17:
In file included from <module-includes>:1:
In file included from llvm-project/llvm/include/llvm/IR/Argument.h:18:
llvm/include/llvm/IR/Attributes.h:75:14: fatal error: 'llvm/IR/Attributes.inc' file not found
#include "llvm/IR/Attributes.inc"
^~~~~~~~~~~~~~~~~~~~~~~~
```
Depending on whether intrinsics_gen runs before compiling Orc/Shared files we either fail or include an outdated Attributes.inc
in module builds. The Clang modules require these additional dependencies as including/importing one module requires all
includes headers by that module to be parsable.
Differential Revision: https://reviews.llvm.org/D92873
Valentin Clement [Tue, 8 Dec 2020 19:36:24 +0000 (14:36 -0500)]
[flang][openacc] Update reference to OpenACC 3.1 specification
Update all reference from the specification to the new OpenACC 3.1
document.
Reviewed By: SouraVX
Differential Revision: https://reviews.llvm.org/D92120
Arthur Eubanks [Tue, 8 Dec 2020 19:33:45 +0000 (11:33 -0800)]
[gn build] Move ScalarizeMaskedMemIntrin.cpp
Craig Topper [Tue, 8 Dec 2020 18:31:30 +0000 (10:31 -0800)]
[RISCV] Detect more errors when parsing vsetvli in the assembler
-Reject an "mf1" lmul
-Make sure tail agnostic is exactly "tu" or "ta" not just that it starts with "tu" or "ta"
-Make sure mask agnostic is exactly "mu" or "ma" not just that it starts with "mu" or "ma"
Differential Revision: https://reviews.llvm.org/D92805
Craig Topper [Tue, 8 Dec 2020 18:30:06 +0000 (10:30 -0800)]
[RISCV] When parsing vsetvli in the assembler, use StringRef::getAsInteger instead of APInt's string constructor
APInt's string constructor asserts on error. Since this is the parser and we don't yet know if the string is a valid integer we shouldn't use that.
Instead use StringRef::getAsInteger which returns a bool to indicate success or failure.
Since we no longer need APInt, use 'unsigned' instead.
Differential Revision: https://reviews.llvm.org/D92801
Masoud Ataei [Tue, 8 Dec 2020 19:21:02 +0000 (19:21 +0000)]
[PPC] Fixing a typo in altivec.h. Commenting out an unnecessary macro
Valentin Clement [Tue, 8 Dec 2020 19:11:18 +0000 (14:11 -0500)]
[flang][openacc] Add missing loop construct restriction and validity tests
Add restriction on loop construct associated with DO CONCURRENT. Add couple of tests to ensure
clause validity checks.
Reviewed By: sameeranjoshi
Differential Revision: https://reviews.llvm.org/D92533
Adam Czachorowski [Tue, 1 Dec 2020 15:53:21 +0000 (16:53 +0100)]
[clangd] ExpandAutoType: Do not offer code action on lambdas.
We can't expand lambda types anyway. Now we simply not offer the code
action instead of showing it and then returning an error in apply().
Differential Revision: https://reviews.llvm.org/D92847
Jessica Paquette [Tue, 8 Dec 2020 18:20:44 +0000 (10:20 -0800)]
[AArch64][GlobalISel] Fold G_SELECT cc, %t, (G_ADD %x, 1) -> CSINC %t, %x, cc
This implements
```
G_SELECT cc, %true, (G_ADD %x, 1) -> CSINC %true, %x, cc
G_SELECT cc, (G_ADD %x, 1), %false -> CSINC %x, %false, inv_cc
```
Godbolt example: https://godbolt.org/z/eoPqKq
Differential Revision: https://reviews.llvm.org/D92868
Matt Morehouse [Tue, 8 Dec 2020 18:47:49 +0000 (10:47 -0800)]
[DFSan] Add several math functions to ABI list.
These are all straightforward functional entries.
Reviewed By: stephan.yichao.zhao
Differential Revision: https://reviews.llvm.org/D92791
Yuriy Chernyshov [Tue, 8 Dec 2020 18:39:56 +0000 (13:39 -0500)]
[libc++] Add std::hash<char8_t> specialization if char8_t is enabled
Differential Revision: https://reviews.llvm.org/D92325
Jessica Paquette [Tue, 8 Dec 2020 17:34:42 +0000 (09:34 -0800)]
[AArch64][GlobalISel] Fold binops on the true side of G_SELECT
This implements the following folds:
```
G_SELECT cc, (G_SUB 0, %x), %false -> CSNEG %x, %false, inv_cc
G_SELECT cc, (G_XOR x, -1), %false -> CSINV %x, %false, inv_cc
```
This is similar to the folds introduced in
5bc0bd05e6a8d788e08cdf3d154f3a33202aee53.
In
5bc0bd05e6a8d788e08cdf3d154f3a33202aee53 I mentioned that we may prefer to do
this in AArch64PostLegalizerLowering.
I think that it's probably better to do this in the selector. The way we select
G_SELECT depends on what register banks end up being assigned to it. If we did
this in AArch64PostLegalizerLowering, then we'd end up checking *every* G_SELECT
to see if it's worth swapping operands. Doing it in the selector allows us to
restrict the optimization to only relevant G_SELECTs.
Also fix up some comments in `TryFoldBinOpIntoSelect` which are kind of
confusing IMO.
Example IR: https://godbolt.org/z/3qPGca
Differential Revision: https://reviews.llvm.org/D92860
Jessica Paquette [Wed, 2 Dec 2020 00:21:41 +0000 (16:21 -0800)]
[AArch64][GlobalISel] Don't explicitly write to the zero register in emitCMN
This case was missed in
78ccb0359d8da3269636d85933dd8afe50a2211f.
Differential Revision: https://reviews.llvm.org/D92438
Nuno Lopes [Tue, 8 Dec 2020 18:36:24 +0000 (18:36 +0000)]
DenseMap: fix build with clang in C++20 mode
clang was complaing about this code:
llvm/include/llvm/IR/PassManager.h:715:17: error: ISO C++20 considers use of overloaded operator '!=' to be ambiguous despite there being a unique best viable function with non-reversed arguments [-Werror,-Wambiguous-reversed-operator]
if (IMapI != IsResultInvalidated.end())
~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
llvm/include/llvm/ADT/DenseMap.h:1253:8: note: candidate function with non-reversed arguments
bool operator!=(const ConstIterator &RHS) const {
^
llvm/include/llvm/ADT/DenseMap.h:1246:8: note: ambiguous candidate function with reversed arguments
bool operator==(const ConstIterator &RHS) const {
^
The warning is triggered when the DenseMapIterator (lhs) is not const and so
the == operator is applied to different types on lhs/rhs.
Using a template allows the function to be available for both const/non-const
iterator types and gets rid of the warning
Jez Ng [Wed, 2 Dec 2020 22:12:51 +0000 (14:12 -0800)]
[lld-macho] Support parsing of bitcode within archives
Also error out if we find anything other than an object or bitcode file
in the archive.
Note that we were previously inserting the symbols and sections of the
unpacked ObjFile into the containing ArchiveFile. This was actually
unnecessary -- we can just insert the ObjectFile (or BitcodeFile) into
the `inputFiles` vector. This is the approach taken by LLD-ELF.
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D92539
Jez Ng [Wed, 2 Dec 2020 03:57:37 +0000 (19:57 -0800)]
[lld-macho][nfc] Move some methods from InputFile to ObjFile
Additionally:
1. Move the helper functions in InputSection.h below the definition of
`InputSection`, so the important stuff is on top
2. Remove unnecessary `explicit`
Reviewed By: #lld-macho, compnerd
Differential Revision: https://reviews.llvm.org/D92453
Eugene Zhulenev [Tue, 8 Dec 2020 12:35:27 +0000 (04:35 -0800)]
[mlir] Async: Add numWorkerThreads argument to createAsyncParallelForPass
Add an option to pass the number of worker threads to select the number of async regions for parallel for transformation.
```
std::unique_ptr<OperationPass<FuncOp>> createAsyncParallelForPass(int numWorkerThreads);
```
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D92835
peter klausler [Mon, 7 Dec 2020 22:46:24 +0000 (14:46 -0800)]
[flang] Implement derived type description table encoding
Define Fortran derived types that describe the characteristics
of derived types, and instantiations of parameterized derived
types, that are of relevance to the runtime language support
library. Define a suite of corresponding C++ structure types
for the runtime library to use to interpret instances of the
descriptions.
Create instances of these description types in Semantics as
static initializers for compiler-created objects in the scopes
that define or instantiate user derived types.
Delete obsolete code from earlier attempts to package runtime
type information.
Differential Revision: https://reviews.llvm.org/D92802
Craig Topper [Tue, 8 Dec 2020 17:55:27 +0000 (09:55 -0800)]
[RISCV] Replace custom isel code for RISCVISD::READ_CYCLE_WIDE with isel pattern
This node returns 2 results and uses a chain. As long as we use a DAG as part of the pseudo instruction definition where we can use the "set" operator, it looks like tablegen can handle use a pattern for this without a problem. I believe the original implementation was copied from PowerPC.
This also fixes the pseudo instruction so that it is marked as having side effects to match the definition of CSRRS and the RV64 instruction. And we don't need to explicitly clear mayLoad/mayStore since those can be inferred now.
Differential Revision: https://reviews.llvm.org/D92786
Yuanfang Chen [Wed, 2 Dec 2020 18:18:18 +0000 (10:18 -0800)]
[Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation
Currently, -ftime-report + new pass manager emits one line of report for each
pass run. This potentially causes huge output text especially with regular LTO
or large single file (Obeserved in private tests and was reported in D51276).
The behaviour of -ftime-report + legacy pass manager is
emitting one line of report for each pass object which has relatively reasonable
text output size. This patch adds a flag `-ftime-report=` to control time report
aggregation for new pass manager.
The flag is for new pass manager only. Using it with legacy pass manager gives
an error. It is a driver and cc1 flag. `per-pass` is the new default so
`-ftime-report` is aliased to `-ftime-report=per-pass`. Before this patch,
functionality-wise `-ftime-report` is aliased to `-ftime-report=per-pass-run`.
* Adds an boolean variable TimePassesHandler::PerRun to control per-pass vs per-pass-run.
* Adds a new clang CodeGen flag CodeGenOptions::TimePassesPerRun to work with the existing CodeGenOptions::TimePasses.
* Remove FrontendOptions::ShowTimers, its uses are replaced by the existing CodeGenOptions::TimePasses.
* Remove FrontendTimesIsEnabled (It was introduced in D45619 which was largely reverted.)
Differential Revision: https://reviews.llvm.org/D92436
Eric Seidel [Tue, 8 Dec 2020 18:09:12 +0000 (13:09 -0500)]
cppcoreguidelines Narrowing Conversions Check: detect narrowing conversions involving typedefs
The check 'cppcoreguidelines-narrowing-conversions' does not detect conversions
involving typedef. This notably includes the standard fixed-width integer types
like int32_t, uint64_t, etc. Now look through the typedefs at the desugared type.
Jeroen Dobbelaere [Tue, 8 Dec 2020 16:33:14 +0000 (08:33 -0800)]
[compiler-rt santizer] Use clock_gettime instead of timespec_get
On RH66, timespec_get is not available. Use clock_gettime instead.
This problem was introduced with D87120
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D91687
Benjamin Kramer [Tue, 8 Dec 2020 18:08:09 +0000 (19:08 +0100)]
Move createScalarizeMaskedMemIntrinPass to Scalar.h
Benjamin Kramer [Tue, 8 Dec 2020 18:03:56 +0000 (19:03 +0100)]
Remove unused include. NFC.
This is also a layering violation.
Arthur Eubanks [Tue, 8 Dec 2020 02:57:20 +0000 (18:57 -0800)]
[test] Rewrite phi-empty.ll into a unittest
phi-empty.ll does not pass under the new PM because the NPM runs
-loop-simplify. Running -loop-simplify ends up not reproing
https://llvm.org/PR48296.
Verified that this test fails when
9eb2c011 is reverted.
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D92807
Sanjay Patel [Tue, 8 Dec 2020 16:21:08 +0000 (11:21 -0500)]
[VectorCombine] add tests for load of insert/extract; NFC
Huihui Zhang [Tue, 8 Dec 2020 17:32:33 +0000 (09:32 -0800)]
[AArch64][SVE] Add lowering for llvm.maxnum|minnum for scalable type.
LLVM intrinsic llvm.maxnum|minnum is overloaded intrinsic, can be used on any
floating-point or vector of floating-point type.
This patch extends current infrastructure to support scalable vector type.
This patch also fix a warning message of incorrect use of EVT::getVectorNumElements()
for scalable type, when DAGCombiner trying to split scalable vector.
Reviewed By: sdesmalen
Differential Revision: https://reviews.llvm.org/D92607
Bardia Mahjour [Tue, 8 Dec 2020 17:21:26 +0000 (12:21 -0500)]
[LV] Make optimal-epilog-vectorization-profitability.ll more robust
Add a CHECK to properly limit the scope of CHECK-NOTs
Nigel Perks [Tue, 8 Dec 2020 17:33:59 +0000 (12:33 -0500)]
Fix inconsistent availability attribute message string literal check.
Function Parser::ParseAvailabilityAttribute checks that the message string of
an availability attribute is not a wide string literal. Test case
clang/test/Parser/attr-availability.c specifies that a string literal is
expected.
The code checked that the first token in a string concatenation is a string
literal, and then that the concatenated string consists of 1-byte characters.
On a target where wide character is 1 byte, a string concatenation "a" L"b"
passes both those checks, but L"b" alone is rejected. More generally, "a" u8"b"
passes the checks, but u8"b" alone is rejected.
So check isAscii() instead of character size.
Anna Thomas [Wed, 2 Dec 2020 20:07:09 +0000 (15:07 -0500)]
[ScalarizeMaskedMemIntrinsic] Move from CodeGen into Transforms
ScalarizeMaskedMemIntrinsic is currently a codeGen level pass. The pass
is actually operating on IR level and does not use any code gen specific
passes. It is useful to move it into transforms directory so that it
can be more widely used as a mid-level transform as well (apart from
usage in codegen pipeline).
In particular, we have a usecase downstream where we would like to use
this pass in our mid-level pipeline which operates on IR level.
The next change will be to add support for new PM.
Reviewers: craig.topper, apilipenko, skatkov
Reviewed-By: skatkov
Differential Revision: https://reviews.llvm.org/D92407
Jessica Paquette [Thu, 3 Dec 2020 22:31:43 +0000 (14:31 -0800)]
[AArch64][GlobalISel] Select G_SADDO and G_SSUBO
We didn't have selector support for these.
Selection code is similar to `getAArch64XALUOOp` in AArch64ISelLowering. Similar
to that code, this returns the AArch64CC and the instruction produced. In SDAG,
this is used to optimize select + overflow and condition branch + overflow
pairs. (See `AArch64TargetLowering::LowerBR_CC` and
`AArch64TargetLowering::LowerSelect`)
(G_USUBO should be easy to add here, but it isn't legalized right now.)
This also factors out the existing G_UADDO selection code, and removes an
unnecessary check for s32/s64. AFAIK, we shouldn't ever get anything other than
s32/s64. It makes more sense for this to be handled by the type assertion in
`emitAddSub`.
Differential Revision: https://reviews.llvm.org/D92610
Nathan James [Tue, 8 Dec 2020 17:12:55 +0000 (17:12 +0000)]
[clangd][NFC] Small tweak to combined provider
This should address the FIXME about clang3.9 dervied to base unique_ptr constructor not working.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D91925
Marek Kurdej [Tue, 8 Dec 2020 17:07:25 +0000 (18:07 +0100)]
[libc++] [LWG3221] Add tests for wrapping operator+(year_month, months).
The behaviour didn't change since commit
5b08c1742a536f54bd5e270b00ff851cbc7314ef (Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang.)
* http://wg21.link/lwg3221
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D92730
Xun Li [Tue, 8 Dec 2020 16:50:30 +0000 (08:50 -0800)]
[coroutine] should disable inline before calling coro split
This is a rework of D85812, which didn't land.
When callee coroutine function is inlined into caller coroutine function before coro-split pass, llvm will emits "coroutine should have exactly one defining @llvm.coro.begin". It seems that coro-early pass can not handle this quiet well.
So we believe that unsplited coroutine function should not be inlined.
This patch fix such issue by not inlining function if it has attribute "coroutine.presplit" (it means the function has not been splited) to fix this issue
test plan: check-llvm, check-clang
In D85812, there was suggestions on moving the macros to Attributes.td to avoid circular header dependency issue.
I believe it's not worth doing just to be able to use one constant string in one place.
Today, there are already 3 possible attribute values for "coroutine.presplit": https://github.com/llvm/llvm-project/blob/
c6543cc6b8f107b58e7205d8fc64865a508bacba/llvm/lib/Transforms/Coroutines/CoroInternal.h#L40-L42
If we move them into Attributes.td, we would be adding 3 new attributes to EnumAttr, just to support this, which I think is an overkill.
Instead, I think the best way to do this is to add an API in Function class that checks whether this function is a coroutine, by checking the attribute by name directly.
Differential Revision: https://reviews.llvm.org/D92706
Nico Weber [Thu, 19 Nov 2020 19:24:27 +0000 (14:24 -0500)]
[gn build] (manually) port
db61b1844e11f
Christian Sigg [Tue, 8 Dec 2020 16:38:23 +0000 (17:38 +0100)]
[mlir] Revert "Tighten access of RewritePattern methods."
This reverts commit
02c9050155dff70497b3423ae95ed7d2ab7675a8.
Painted myself into a corner with -Wvirtual_overload, private access, and final.
Differential Revision: https://reviews.llvm.org/D92855
Simon Pilgrim [Tue, 8 Dec 2020 16:37:05 +0000 (16:37 +0000)]
SemaType.cpp - use castAs<> instead of getAs<> for dereferenced pointers
Fix static analyzer warnings - castAs<> will assert the type is correct, but getAs<> just returns null, which would just result in a dereferenced null pointer.
Tres Popp [Fri, 4 Dec 2020 21:13:14 +0000 (22:13 +0100)]
[mlir] Use rewriting infrastructure in AsyncToLLVM
This is needed so a listener hears all changes during the dialect
conversion to allow correct rollbacks upon failure.
Differential Revision: https://reviews.llvm.org/D92685
Arthur O'Dwyer [Tue, 8 Dec 2020 04:42:47 +0000 (23:42 -0500)]
[libc++] ADL-proof <iterator>. `__convert_to_integral` is not a customization point.
The interesting change here is that we no longer consider `__convert_to_integral`
an ADL customization point for the user's types. I think the new behavior
is defensible. The old behavior had come from D7449, where Marshall explicitly
said "people can't define their own [`__convert_to_integral` overloads]."
Differential Revision: https://reviews.llvm.org/D92814
Frederik Gossen [Tue, 8 Dec 2020 16:02:18 +0000 (17:02 +0100)]
Add sqrt lowering from standard to NVVM
Differential Revision: https://reviews.llvm.org/D92850
Louis Dionne [Mon, 7 Dec 2020 23:20:35 +0000 (18:20 -0500)]
[libc++] Add a CI job to backdeploy to macOS 10.14
It adds coverage for back-deploying to a system that contains the
filesystem library, which 10.9 (currently our only back-deployment
target in the CI) does not have.
Differential Revision: https://reviews.llvm.org/D92794
Benjamin Kramer [Tue, 8 Dec 2020 14:37:32 +0000 (15:37 +0100)]
[mlir][Shape] Canonicalize assume_all with one input and tensor_cast of constant_shape
This allows simplifying some more complicated shape expressions
Differential Revision: https://reviews.llvm.org/D92843
Gabor Marton [Mon, 7 Dec 2020 17:35:26 +0000 (18:35 +0100)]
[analyzer][StdLibraryFunctionsChecker] Add more return value contraints
This time, we add contraints to functions that either return with [0, -1] or
with a file descriptor.
Differential Revision: https://reviews.llvm.org/D92771
Gabor Marton [Mon, 7 Dec 2020 15:10:40 +0000 (16:10 +0100)]
[analyzer][StdLibraryFunctionsChecker] Make close and mmap to accept -1 as fd
close:
It is quite often that users chose to call close even if the fd is
negative. Theoretically, it would be nicer to close only valid fds, but
in practice the implementations of close just returns with EBADF in case
of a non-valid fd param. So, we can eliminate many false positives if we
let close to take -1 as an fd. Other negative values are very unlikely,
because open and other fd factories return with -1 in case of failure.
mmap:
In the case of MAP_ANONYMOUS flag (which is supported e.g. in Linux) the
mapping is not backed by any file; its contents are initialized to zero.
The fd argument is ignored; however, some implementations require fd to
be -1 if MAP_ANONYMOUS (or MAP_ANON) is specified, and portable
applications should ensure this.
Consequently, we must allow -1 as the 4th arg.
Differential Revision: https://reviews.llvm.org/D92764
Valentin Clement [Tue, 8 Dec 2020 15:36:34 +0000 (10:36 -0500)]
[flang][openacc] Add clause validity tests for the update directive
Add couple of clause validity tests for the update directive and check for
the restriction where at least self, host or device clause must appear on the directive.
Reviewed By: sameeranjoshi
Differential Revision: https://reviews.llvm.org/D92447
Teresa Johnson [Tue, 8 Dec 2020 01:13:49 +0000 (17:13 -0800)]
[ICP] Don't promote when target not defined in module
This guards against cases where the symbol was dead code eliminated in
the binary by ThinLTO, and we have a sample profile collected for one
binary but used to optimize another.
Most of the benefit from ICP comes from inlining the target, which we
can't do with only a declaration anyway. If this is in the pre-ThinLTO
link step (e.g. for instrumentation based PGO), we will attempt the
promotion again in the ThinLTO backend after importing anyway, and we
don't need the early promotion to facilitate that.
Differential Revision: https://reviews.llvm.org/D92804
Christian Sigg [Fri, 4 Dec 2020 18:12:02 +0000 (19:12 +0100)]
[mlir] Tighten access of RewritePattern methods.
In RewritePattern, only expose `matchAndRewrite` as a public function. `match` can be protected (but needs to be protected because we want to call it from an override of `matchAndRewrite`). `rewrite` can be private.
For classes deriving from RewritePattern, all 3 functions can be private.
Side note: I didn't understand the need for the `using RewritePattern::matchAndRewrite` in derived classes, and started poking around. They are gone now, and I think the result is (only very slightly) cleaner.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D92670
Stefan Pintilie [Tue, 8 Dec 2020 14:57:37 +0000 (08:57 -0600)]
[PowerPC] Fix missing nop after call to weak callee.
Weak functions can be replaced by other functions at link time. Previously it
was assumed that no matter what the weak callee function was replaced with it
would still share the same TOC as the caller. This is no longer true as a weak
callee with a TOC setup can be replaced by another function that was compiled
with PC Relative and does not have a TOC at all.
This patch makes sure that all calls to functions defined as weak from a caller
that has a valid TOC have a nop after the call to allow a place for the linker
to restore the TOC.
Reviewed By: NeHuang
Differential Revision: https://reviews.llvm.org/D91983
Simon Pilgrim [Tue, 8 Dec 2020 15:24:34 +0000 (15:24 +0000)]
[X86] Regenerate vector-shift-*.ll tests
Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests
Simon Pilgrim [Tue, 8 Dec 2020 14:48:24 +0000 (14:48 +0000)]
[X86] Regenerate store-narrow.ll tests
Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests
Simon Pilgrim [Tue, 8 Dec 2020 14:47:00 +0000 (14:47 +0000)]
[X86] Regenerate bmi-intrinsics-fast-isel.ll tests
Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests
Simon Pilgrim [Tue, 8 Dec 2020 14:45:59 +0000 (14:45 +0000)]
[X86] Regenerate addcarry2.ll tests
Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests
Simon Pilgrim [Tue, 8 Dec 2020 14:44:49 +0000 (14:44 +0000)]
[X86] Regenerate sttni.ll tests
Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests
Simon Pilgrim [Tue, 8 Dec 2020 14:43:52 +0000 (14:43 +0000)]
[X86] Regenerate clzero.ll tests
Replace X32 check prefixes with X86 - X32 is generally used for gnux triple tests
Chris Kennelly [Thu, 29 Oct 2020 02:45:09 +0000 (22:45 -0400)]
[clang-tidy] Omit std::make_unique/make_shared for default initialization.
This extends the check for default initialization in arrays added in
547f89d6070 to include scalar types and exclude them from the suggested fix for
make_unique/make_shared.
Rewriting std::unique_ptr<int>(new int) as std::make_unique<int>() (or for
other, similar trivial T) switches from default initialization to value
initialization, a performance regression for trivial T. For these use cases,
std::make_unique_for_overwrite is more suitable alternative.
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D90392
David Green [Tue, 8 Dec 2020 15:22:46 +0000 (15:22 +0000)]
[ARM] Turn pred_cast(xor(x, -1)) into xor(pred_cast(x), -1)
This folds a not (an xor -1) though a predicate_cast, so that it can be
turned into a VPNOT and potentially be folded away as an else predicate
inside a VPT block.
Differential Revision: https://reviews.llvm.org/D92235
Kevin P. Neal [Tue, 8 Dec 2020 15:15:08 +0000 (10:15 -0500)]
[FPEnv] Correct constrained metadata in fp16-ops-strict.c
This test shows we're in some cases not getting strictfp information from
the AST. Correct that.
Differential Revision: https://reviews.llvm.org/D92596
Chris Kennelly [Sun, 6 Dec 2020 16:26:31 +0000 (11:26 -0500)]
[clang-tidy] Recognize single character needles for absl::StrContains.
Commit
fbdff6f3ae0b in the Abseil tree adds an overload for
absl::StrContains to accept a single character needle for optimized
lookups.
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D92810
Adam Czachorowski [Tue, 1 Dec 2020 18:04:42 +0000 (19:04 +0100)]
[clangd] ExtractFunction: disable on regions that sometimes, but not always return.
apply() will fail in those cases, so it's better to detect it in
prepare() already and hide code action from the user.
This was especially annoying on code bases that use a lot of
RETURN_IF_ERROR-like macros.
Differential Revision: https://reviews.llvm.org/D92408
Adhemerval Zanella [Tue, 8 Dec 2020 13:26:18 +0000 (10:26 -0300)]
[compiler-rt] [builtins] Support conversion between fp16 and fp128
This patch adds both extendhftf2 and trunctfhf2 to support
conversion between half-precision and quad-precision floating-point
values. They are built iff the compiler supports _Float16.
Some notes on ARM plaforms: while fp16 is supported on all
architectures, _Float16 is supported only for 32-bit ARM, 64-bit ARM,
and SPIR (as indicated by clang/docs/LanguageExtensions.rst). Also,
fp16 is a storage format and 64-bit ARM supports floating-point
convert precision to half as base armv8-a instruction.
This patch does not change the ABI for 32-bit ARM, it will continue
to pass _Float16 as uint16.
This re-enabled revert done by https://reviews.llvm.org/rGb534beabeed3ba1777cd0ff9ce552d077e496726
Differential Revision: https://reviews.llvm.org/D92242
David Sherwood [Tue, 8 Dec 2020 14:38:12 +0000 (14:38 +0000)]
[SVE] Remove duplicate assert in DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR
Jay Foad [Tue, 8 Dec 2020 13:13:13 +0000 (13:13 +0000)]
[AMDGPU] Add occupancy level tests for GFX10.3. NFC.
getMaxWavesPerEU and getVGPRAllocGranule both changed in GFX10.3 and
they both affect the occupancy calculation.
Differential Revision: https://reviews.llvm.org/D92839
ergawy [Tue, 8 Dec 2020 14:02:02 +0000 (09:02 -0500)]
[MLIR][SPIRV] Add initial support for OpSpecConstantOp.
This commit adds initial support for SPIR-V OpSpecConstantOp
instruction. The following is introdcued:
- A new `spv.specConstantOperation` operation consisting of a single
region and of 2 operations within that regions (more details in the
docs of the op itself).
- A new `spv.yield` instruction that acts a terminator for
`spv.specConstantOperation`.
For now, the generic form of the new op is supported (i.e. no custom
parsing or printing). This will be done in a follow up patch.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D92232
David Green [Tue, 8 Dec 2020 14:05:07 +0000 (14:05 +0000)]
[ARM] Remove dead instructions before creating VPT block bundles
We remove VPNOT instructions in VPT blocks as we create them, turning
them into else predicates. We don't remove the dead instructions until
after the block has been created though. Because the VPNOT will have
killed the vpr register it used, this makes finalizeBundle add internal
flags to the vpr uses of any instructions after the VPNOT. These
incorrect flags can then confuse what is alive and what is not, leading
to machine verifier problems.
This patch removes them earlier instead, before the bundle is finalized
so that kill flags remain valid.
Differential Revision: https://reviews.llvm.org/D92227
David Sherwood [Tue, 1 Dec 2020 13:15:57 +0000 (13:15 +0000)]
[SVE] Fix crashes with inline assembly
All the crashes found compiling inline assembly are fixed in this
patch by changing AArch64TargetLowering::getRegForInlineAsmConstraint
to be more resilient to mismatched value and register types. For
example, it makes no sense to request a predicate register for
a nxv2i64 type and so on.
Tests have been added here:
test/CodeGen/AArch64/inline-asm-constraints-bad-sve.ll
Differential Revision: https://reviews.llvm.org/D92554
Frederik Gossen [Tue, 8 Dec 2020 12:57:54 +0000 (13:57 +0100)]
Add rsqrt lowering from standard to NVVM
Differential Revision: https://reviews.llvm.org/D92838
Jan Svoboda [Mon, 7 Dec 2020 13:22:23 +0000 (14:22 +0100)]
[clang][cli] Unify boolean marshalling
Use lambdas with captures to replace the redundant infrastructure for marshalling of two boolean flags that control the same keypath.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D92773
Simon Pilgrim [Tue, 8 Dec 2020 12:19:43 +0000 (12:19 +0000)]
[SLP][X86] Extend PR46983 tests to include SSE2,SSE42,AVX512BW test coverage
Noticed while reviewing D92824
Raphael Isemann [Tue, 8 Dec 2020 12:33:14 +0000 (13:33 +0100)]
[lldb][import-std-module] Add a test for typedef'd std types
Nigel Perks [Tue, 8 Dec 2020 12:19:20 +0000 (12:19 +0000)]
[XCore][docs] Fix XCore compiler writer documentation links.
Fix links to XMOS website. Add link for XS2 architecture.
Reviewed By: jryans
Differential Revision: https://reviews.llvm.org/D92019
Sjoerd Meijer [Tue, 8 Dec 2020 11:39:46 +0000 (11:39 +0000)]
[LICM][docs] Document that LICM is also a canonicalization transform. NFC.
This documents that LICM is a canonicalization transform, which we discussed
recently in:
http://lists.llvm.org/pipermail/llvm-dev/2020-December/147184.html
but which was also discused earlier, e.g. in:
http://lists.llvm.org/pipermail/llvm-dev/2019-September/135058.html
David Green [Tue, 8 Dec 2020 11:54:39 +0000 (11:54 +0000)]
[NFC] Chec[^k] -> Check
Some test updates all appearing to use the wrong spelling of CHECK.
Hafiz Abid Qadeer [Tue, 8 Dec 2020 11:46:36 +0000 (11:46 +0000)]
[compiler-rt] Allow appending to 'target_cflags' value from lit_config.
This patch is similar to D84708. When testing compiler-rt on different
baremetal targets, it helps to have the ability to pass some more parameters
at test time that allows you to build the test executable for a
given target. For an example, you may need a different linker command
file for different targets.
This patch will allows to do things like
$ llvm-lit --param=append_target_cflags="-T simulator.ld"
or
$ llvm-lit --param=append_target_cflags="-T hardware.ld"
In this way, you can run tests on different targets without having to run
cmake again.
Reviewed By: delcypher
Differential Revision: https://reviews.llvm.org/D91783
Jeremy Morse [Tue, 8 Dec 2020 10:55:47 +0000 (10:55 +0000)]
[DebugInfo][Docs] Document MIR language debug-info constructs
This patch documents the MIR syntax for a number of things relevant to
debugging information:
* Trailing 'debug-location' metadata that becomes a DebugLoc,
* Variable location metadata for stack slots,
* Syntax for DBG_VALUE metainstructions,
* Syntax for DBG_INSTR_REF, including trailing instruction numbers
attached to MIR instructions.
Differential Revision: https://reviews.llvm.org/D89337
Pan, Tao [Tue, 8 Dec 2020 09:57:03 +0000 (17:57 +0800)]
[CodeGen] Add text section prefix for COFF object file
Text section prefix is created in CodeGenPrepare, it's file format independent implementation, text section name is written into object file in TargetLoweringObjectFile, it's file format dependent implementation, port code of adding text section prefix to text section name from ELF to COFF.
Different with ELF that use '.' as concatenation character, COFF use '$' as concatenation character. That is, concatenation character is variable, so split concatenation character from text section prefix.
Text section prefix is existing feature of ELF, it can help to reduce icache and itlb misses, it's also make possible aggregate other compilers e.g. v8 created same prefix sections. Furthermore, the recent feature Machine Function Splitter (basic block level text prefix section) is based on text section prefix.
Reviewed By: pengfei, rnk
Differential Revision: https://reviews.llvm.org/D92073
Cullen Rhodes [Thu, 3 Dec 2020 11:05:51 +0000 (11:05 +0000)]
[IR] Remove CastInst::isCastable since it is not used
It was removed back in 2013 (f63dfbb) by Matt Arsenault but then
reverted since DragonEgg used it, but that project is no longer
maintained.
Reviewed By: ldionne, dexonsmith
Differential Revision: https://reviews.llvm.org/D92571
Tim Northover [Wed, 21 Oct 2020 09:11:25 +0000 (10:11 +0100)]
UBSAN: emit distinctive traps
Sometimes people get minimal crash reports after a UBSAN incident. This change
tags each trap with an integer representing the kind of failure encountered,
which can aid in tracking down the root cause of the problem.
Stefan Gränitz [Tue, 8 Dec 2020 09:56:50 +0000 (10:56 +0100)]
[Orc] Two small fixes in TPCDynamicLibrarySearchGenerator
There is one result per lookup symbol, so we have to advance the result iterator no matter whether it's NULL or not.
MissingSymbols variable is unused.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D91707
Stefan Gränitz [Tue, 8 Dec 2020 09:53:50 +0000 (10:53 +0100)]
[JITLink][ELF] Route objects to their matching linker backends based on header info
Distinguish objects by target properties address size, endian and machine architecture. So far we only
support x86-64 (ELFCLASS64, ELFDATA2LSB, EM_X86_64).
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D90860
Evgeniy Brevnov [Fri, 4 Dec 2020 09:53:17 +0000 (16:53 +0700)]
[DSE][NFC] Need to be carefull mixing signed and unsigned types
Currently in some places we use signed type to represent size of an access and put explicit casts from unsigned to signed.
For example: int64_t EarlierSize = int64_t(Loc.Size.getValue());
Even though it doesn't loos bits (immidiatly) it may overflow and we end up with negative size. Potentially that cause later code to work incorrectly. A simple expample is a check that size is not negative.
I think it would be safer and clearer if we use unsigned type for the size and handle it appropriately.
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D92648