Mitch Phillips [Tue, 28 Feb 2023 22:05:42 +0000 (14:05 -0800)]
[GWP-ASan] Handle wild touches of the guarded pool.
AllocMeta could be null when returned from __gwp_asan_get_metadata() for
a bad access into the GuardedPagePool that was never allocated.
Currently, then we dereference the null pointer, oops.
Hoist the check up and print a message (only once in recoverable mode)
about the bad memory access.
Reviewed By: fmayer
Differential Revision: https://reviews.llvm.org/D144973
ManuelJBrito [Tue, 28 Feb 2023 21:50:36 +0000 (21:50 +0000)]
Revert "[X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS"
This reverts commit
9e58182d6446bb61dbd13c0e6314f291e50d4d7c.
ManuelJBrito [Tue, 28 Feb 2023 21:37:30 +0000 (21:37 +0000)]
[X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS
Ignoring freeze(undef) if it has multiple uses in LowerAVXCONCAT_VECTORS
causes the custom INSERT_SUBVECTOR for vector widening to be ignored.
Differential Revision: https://reviews.llvm.org/D14490
Jason Molenda [Tue, 28 Feb 2023 21:36:12 +0000 (13:36 -0800)]
Update debugserver xcode proj to build with c++17
Also a few small fixes for building debugserver on iOS
in c++17.
Jakub Kuderski [Tue, 28 Feb 2023 21:24:10 +0000 (16:24 -0500)]
[ADT] Fix const-correctness issues in `zippy`
This defines the iterator tuple based on the storage type of `zippy`,
instead of its type arguments. This way, we can support temporaries that
gets passed in and allow for them to be modified during iteration.
Because the iterator types to the tuple storage can have different types
when the storage is and isn't const, this defines a const iterator type
and non-const `begin`/`end` functions. This way we avoid unintentional
casts, e.g., trying to cast `vector<bool>::reference` to
`vector<bool>::const_reference`, which may be unrelated types that are
not convertible.
This patch is a general and free-standing improvement but my primary use
is in the implemention a version of `enumerate` that accepts multiple ranges:
D144583.
Reviewed By: dblaikie, zero9178
Differential Revision: https://reviews.llvm.org/D144834
Joseph Huber [Mon, 27 Feb 2023 16:35:30 +0000 (10:35 -0600)]
[clang-format] Only add pragma continuation indentation for 'omp' clauses
The patch in D136100 added custom handling for pragmas to assist in
formatting OpenMP clauses correctly. One of these changes added extra
indentation. This is desirable for OpenMP pragmas as they are several
complete tokens that would otherwise we on the exact same line. However,
this is not desired for the other pragmas.
This solution is extremely hacky, I'm not overly familiar with the
`clang-format` codebase. A better solution would probably require
actually parsing these as tokens, but I just wanted to propose a
solution.
Fixes https://github.com/llvm/llvm-project/issues/59473
Reviewed By: HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D144884
Peiming Liu [Tue, 28 Feb 2023 01:18:12 +0000 (01:18 +0000)]
[mlir][sparse] fix performance bug in matmul with a sparse rhs due to suboptimal iteration graphs.
While dense tensors support random accesses, it is critical to visit them in a row-major order for better cache locality. However, we previously consider dense inputs and outputs together when computing constraints for building iteration graph, it could lead us to less efficient iteration graphs.
This patch adds a new `SortMask::kIncludeDenseInput` to treat dense inputs/outputs separately when building iteration graph, thus increasing the chance for use to construct a better iteration graph.
A more fine-grained approach is to treat each input separately.
Note, related to:
https://github.com/llvm/llvm-project/issues/51651
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D144932
Med Ismail Bennani [Tue, 28 Feb 2023 20:52:21 +0000 (12:52 -0800)]
[lldb] Remove const qualifier on bool argument passed by value
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Siva Chandra Reddy [Mon, 27 Feb 2023 22:27:35 +0000 (22:27 +0000)]
[libc][NFC] Refactor internal errno.
This is in preparation for the transition to a solution to make libc tests
hermetic with respect to their use of errno. The implementation of strdup
has been switched over to libc_errno as an example of what the code looks
like in the new way.
See #61037 for more information.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D144928
Alexey Bataev [Tue, 28 Feb 2023 19:17:21 +0000 (11:17 -0800)]
[OpenMP]Emit captured decls for target data if no devices were specified.
If use_device_ptr/use_device_addr clauses are used on target data
directive and no device was specified during the compilation, only host
part should be emitted. But it still required to emit captured decls for
partially mapped data fields.
Differential Revision: https://reviews.llvm.org/D144993
Fangrui Song [Tue, 28 Feb 2023 20:16:28 +0000 (12:16 -0800)]
[test] Add missing -### to Driver/config-file3.c
Otherwise clang may invoke ld. If ld is a shell script using `~`, the
command will fail since `HOME` is changed.
Fangrui Song [Tue, 28 Feb 2023 20:06:36 +0000 (12:06 -0800)]
[Driver] Revert -mcpu=?/-mtune=? and make -mcpu=help/-mtune=help unnamed
Follow-up to D144914.
-mcpu=help seems fine as a Clang extension not in GCC, because llc supports -mcpu=help.
-mcpu=? is a bad choice as ? may be expanded by the shell.
Anshil Gandhi [Tue, 28 Feb 2023 20:03:44 +0000 (13:03 -0700)]
[AMDGPU] Replace LegacyDA with Uniformity Analysis in AnnotateUniformValues
Reviewed By: sameerds
Differential Revision: https://reviews.llvm.org/D144162
Mehdi Amini [Tue, 28 Feb 2023 20:00:45 +0000 (15:00 -0500)]
Fix SimplifyAllocConst pattern when we have alloc of negative sizes
This is UB, but we shouldn't crash the compiler either.
Fixes #61056
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D144978
Med Ismail Bennani [Tue, 28 Feb 2023 17:24:46 +0000 (09:24 -0800)]
[lldb] Fix {break,watch}point command function stopping behaviour
In order to run a {break,watch}point command, lldb can resolve to the
script interpreter to run an arbitrary piece of code or call into a
user-provided function. To do so, we will generate a wrapping function,
where we first copy lldb's internal dictionary keys into the
interpreter's global dictionary, copied inline the user code before
resetting the global dictionary to its previous state.
However, {break,watch}point commands can optionally return a value that
would tell lldb whether we should stop or not. This feature was
only implemented for breakpoint commands and since we inlined the user
code directly into the wrapping function, introducing an early return,
that caused lldb to let the interpreter global dictionary tinted with the
internal dictionary keys.
This patch fixes that issue while also adding the stopping behaviour to
watchpoint commands.
To do so, this patch refactors the {break,watch}point command creation
method, to let the lldb wrapper function generator know if the user code is
a function call or a arbitrary expression.
Then the wrapper generator, if the user input was a function call, the
wrapper function will call the user function and save the return value into
a variable. If the user input was an arbitrary expression, the wrapper will
inline it into a nested function, call the nested function and save the
return value into the same variable. After resetting the interpreter global
dictionary to its previous state, the generated wrapper function will return
the varible containing the return value.
rdar://
105461140
Differential Revision: https://reviews.llvm.org/D144688
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Valery N Dmitriev [Tue, 28 Feb 2023 18:55:00 +0000 (10:55 -0800)]
[SLP] Add banner argument to SLP costs debug printer method - NFC.
Removed unnecessary warning workaround.
Differential Revision: https://reviews.llvm.org/D144992
Sanjay Patel [Tue, 28 Feb 2023 19:18:28 +0000 (14:18 -0500)]
[InstCombine] reassociate subtract-from-constant to add-constant
(C - X) + Y --> (Y - X) + C
Moving the constant operand to an 'add' gives more
flexibility to subsequent reassociation patterns,
and it may be better for codegen on targets that
don't have subtract-from-immediate instructions.
Sanjay Patel [Tue, 28 Feb 2023 16:14:11 +0000 (11:14 -0500)]
[IR] fix spelling/formatting; NFC
Even within this file, the usual spelling is 'Opcode',
so make it consistent.
Sanjay Patel [Tue, 28 Feb 2023 15:07:54 +0000 (10:07 -0500)]
[InstCombine] simplify test for div/rem; NFC
This is too conservative as noted in the TODO comment.
Craig Topper [Tue, 28 Feb 2023 19:16:45 +0000 (11:16 -0800)]
[Sema] Add missing entries to the arrays in GetImplicitConversionName and GetConversionRank.
It appears that ICK_Zero_Queue_Conversion was inserted into the ICK
enum without updating this table. Easy to do since the table size
was set to ICK_Num_Conversion_Kinds.
I've used ICR_Exact_Match to match what was previously done for
ICK_Zero_Event_Conversion that last time someone noticed this had happened.
To prevent this from happening again, I've removed the explicit size
and used a static_assert to check the size against ICK_Num_Conversion_Kinds.
Differential Revision: https://reviews.llvm.org/D144990
Mark de Wever [Tue, 28 Feb 2023 19:03:54 +0000 (20:03 +0100)]
Revert "Revert "[Modules] Don't check [temp.friend]p9 in ASTContext::isSameEntity""
This fixes the Clang modular CI, but breaks other CIs.
This reverts commit
2ae39902506f38d6368a7dbe3d64109f57ad6f99.
Michael Jones [Tue, 28 Feb 2023 18:58:02 +0000 (10:58 -0800)]
[libc] fix strtofloat test with 128 bit floats
Differential Revision: https://reviews.llvm.org/D144991
Yitzhak Mandelbaum [Tue, 28 Feb 2023 18:19:40 +0000 (18:19 +0000)]
[clang][dataflow] Fix missed fields in field set construction.
When building the set of referenced fields for the `DataflowAnalysisContext`,
include fields referenced only in default member initializers. These
initializers are visited in the CFGs of constructors and so the fields must be
included when analysing constructor bodies.
Differential Revision: https://reviews.llvm.org/D144987
Michael Jones [Fri, 17 Feb 2023 19:14:37 +0000 (11:14 -0800)]
[libc] Refactor string to float return values
The internal implementation of the string to float function previously
used pointer arguments for returning several values. Additionally it
set errno in several unexpected places. Now all of that goes through
return structs. For readability I also moved the function away from raw
pointer arithmetic towards proper indexing. I also added support for
rounding modes.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D144597
Michael Maitland [Mon, 27 Feb 2023 21:54:06 +0000 (13:54 -0800)]
[Clang][Driver] Add -mcpu=help and -mtune=help to clang
Clang currently uses `-mcpu=?` and `-mtune=?`. The `?` causes errors on some
shells such as zsh since it is a special character. In order for it to work on
shells such as zsh, the option must be passed in quotes or escaped. This patch
adds `-mcpu=help` and `-mtune=help` as another alias for `--print-supported-cpus`.
In llc, `-mcpu=help` is an alias to print supported cpus.
Differential Revision: https://reviews.llvm.org/D144914
Mark de Wever [Tue, 28 Feb 2023 18:36:56 +0000 (19:36 +0100)]
Revert "[Modules] Don't check [temp.friend]p9 in ASTContext::isSameEntity"
This commits breaks the libc++ modular build in the precommit CI.
This reverts commit
74565c3add6d683559618973863e78a5e6836e48.
Nikolas Klauser [Sun, 5 Feb 2023 10:09:23 +0000 (11:09 +0100)]
[libc++] Run clang-tidy in all configurations that are run in the Docker container
Reviewed By: ldionne, Mordante, #libc
Spies: libcxx-commits, arichardson
Differential Revision: https://reviews.llvm.org/D143333
V Donaldson [Mon, 27 Feb 2023 22:05:53 +0000 (14:05 -0800)]
[flang] Block construct
A block construct is an execution control construct that supports
declaration scopes contained within a parent subprogram scope or another
block scope. (blocks may be nested.) This is implemented by applying
basic scope processing to the block level.
Name uniquing/mangling is extended to support this. The term "block" is
heavily overloaded in Fortran standards. Prior name uniquing used tag `B`
for common block objects. Existing tag choices were modified to free up `B`
for block construct entities, and `C` for common blocks, and resolve
additional issues with other tags. The "old tag -> new tag" changes can
be summarized as:
-> B -- block construct -> new
B -> C -- common block
C -> YI -- intrinsic type descriptor; not currently generated
CT -> Y -- nonintrinsic type descriptor; not currently generated
G -> N -- namelist group
L -> -- block data; not needed -> deleted
Existing name uniquing components consist of a tag followed by a name
from user source code, such as a module, subprogram, or variable name.
Block constructs are different in that they may be anonymous. (Like other
constructs, a block may have a `block-construct-name` that can be used
in exit statements, but this name is optional.) So blocks are given a
numeric compiler-generated preorder index starting with `B1`, `B2`,
and so on, on a per-procedure basis.
Name uniquing is also modified to include component names for all
containing procedures rather than for just the immediate host. This
fixes an existing name clash bug with same-named entities in same-named
host subprograms contained in different-named containing subprograms,
and variations of the bug involving modules and submodules.
F18 clause 9.7.3.1 (Deallocation of allocatable variables) paragraph 1
has a requirement that an allocated, unsaved allocatable local variable
must be deallocated on procedure exit. The following paragraph 2 states:
When a BLOCK construct terminates, any unsaved allocated allocatable
local variable of the construct is deallocated.
Similarly, F18 clause 7.5.6.3 (When finalization occurs) paragraph 3
has a requirement that a nonpointer, nonallocatable object must be
finalized on procedure exit. The following paragraph 4 states:
A nonpointer nonallocatable local variable of a BLOCK construct
is finalized immediately before it would become undefined due to
termination of the BLOCK construct.
These deallocation and finalization requirements, along with stack
restoration requirements, require knowledge of block exits. In addition
to normal block termination at an end-block-stmt, a block may be
terminated by executing a branching statement that targets a statement
outside of the block. This includes
Single-target branch statements:
- goto
- exit
- cycle
- return
Bounded multiple-target branch statements:
- arithmetic goto
- IO statement with END, EOR, or ERR specifiers
Unbounded multiple-target branch statements:
- call with alternate return specs
- computed goto
- assigned goto
Lowering code is extended to determine if one of these branches exits
one or more relevant blocks or other constructs, and adds a mechanism to
insert any necessary deallocation, finalization, or stack restoration
code at the source of the branch. For a single-target branch it suffices
to generate the exit code just prior to taking the indicated branch.
Each target of a multiple-target branch must be analyzed individually.
Where necessary, the code must first branch to an intermediate basic
block that contains exit code, followed by a branch to the original target
statement.
This patch implements an `activeConstructStack` construct exit mechanism
that queries a new `activeConstruct` PFT bit to insert stack restoration
code at block exits. It ties in to existing code in ConvertVariable.cpp
routine `instantiateLocal` which has code for finalization, making block
exit finalization on par with subprogram exit finalization. Deallocation
is as yet unimplemented for subprograms or blocks. This may result in
memory leaks for affected objects at either the subprogram or block level.
Deallocation cases can be addressed uniformly for both scopes in a future
patch, presumably with code insertion in routine `instantiateLocal`.
The exit code mechanism is not limited to block construct exits. It is
also available for use with other constructs. In particular, it is used
to replace custom deallocation code for a select case construct character
selector expression where applicable. This functionality is also added
to select type and associate constructs. It is available for use with
other constructs, such as select rank and image control constructs,
if that turns out to be necessary.
Overlapping nonfunctional changes include eliminating "FIR" from some
routine names and eliminating obsolete spaces in comments.
Yaxun (Sam) Liu [Fri, 24 Feb 2023 20:32:57 +0000 (15:32 -0500)]
[SimplifyCFG] Do not hoist/sink convergent function calls
Currently SimplifyCFG hoists/sink common instructions in then/else basic blocks
when certain options are enabled, which is the case for default clang optimization
pipelines for -O3. It tries to hoist/sink convergent function calls in divergent
control flow, which causes incorrect ISA generated for GPU, e.g.
https://github.com/ROCm-Developer-Tools/HIP/issues/3172
This patch fixes that by conservatively disable hoisting/sinking common
convergent function calls in then/else blocks.
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D144756
Arthur Eubanks [Tue, 28 Feb 2023 17:35:58 +0000 (09:35 -0800)]
[gn build] Manually port D140588
Mark de Wever [Sat, 21 Jan 2023 12:38:44 +0000 (13:38 +0100)]
[libc++] Addresses LWG3782.
3782. Should <math.h> declare ::lerp?
Libc++ doesn't declare ::lerp, adds tests to validate the requirement.
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D142817
Philip Reames [Tue, 28 Feb 2023 17:21:56 +0000 (09:21 -0800)]
[RISCV] Use !listremove for LMUL lists in V scheduling info [nfc]
Using listremove makes it easier to confirm that the code matches the comments. The only in tree users of these lists are not order sensative.
Arthur O'Dwyer [Fri, 20 Jan 2023 19:49:55 +0000 (14:49 -0500)]
[libc++] Refactor allocator_mismatch.compile.fail.cpp -> .verify.cpp
compile.fail.cpp tests are an anti-feature since they are too easy to
break when evolving code. This patch moves various allocator_mismatch
tests to .verify.cpp and normalizes the error messages from various
containers.
Differential Revision: https://reviews.llvm.org/D144913
Mark de Wever [Mon, 27 Feb 2023 18:35:20 +0000 (19:35 +0100)]
[clang] Documents clang-scan-deps requirements.
This was discussed in https://llvm.org/PR61006.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D144894
Sacha Ballantyne [Tue, 28 Feb 2023 16:42:18 +0000 (16:42 +0000)]
[flang] Fix a bug with simplified minloc that treated logicals with even values > 1 as 0
Previously the mask would be loaded as the appropriate integer type and cast to I1 to pass to
fir.if, however this truncates the integer and so would cast 6 to 0. By loading values as logicals
and casting to I1 this problem is avoided.
Reviewed By: Leporacanthicus
Differential Revision: https://reviews.llvm.org/D144974
Alex Brachet [Tue, 28 Feb 2023 17:09:33 +0000 (17:09 +0000)]
[X86] Add DwarfRegNums for segment registers
Differential Revision: https://reviews.llvm.org/D144900
Philip Reames [Tue, 28 Feb 2023 16:49:25 +0000 (08:49 -0800)]
[RISCV] Factor out multiclass definitions for V scheduling info [nfc]
Factoring out a shared multiclass imply makes it easier to see that all of these do the same thing, just on different lists. It also makes it easier to see differences - such as we don't define read related pieces for FWRed.
Differential Revision: https://reviews.llvm.org/D144899
Manupa Karunaratne [Tue, 28 Feb 2023 16:24:41 +0000 (16:24 +0000)]
[MLIR][AMDGPU][ROCDL] Adding raw.buffer.atomic.fmax/smax/umin support
This commit adds support for atomic fmax/smax/umin support
for AMDGPU dialect and the dependent dialects to allow such
a lowering.
Reviewed By: krzysz00
Differential Revision: https://reviews.llvm.org/D144097
Chia-hung Duan [Tue, 28 Feb 2023 03:28:12 +0000 (03:28 +0000)]
Revert "Revert "[scudo] Only prepare PageMap entry for partial region""
Fixed the bug in merging BatchGroups back to the FreeList. Added DCHECKs
to ensure the order of BatchGroups
This reverts commit
387452ec591c81def6d8869b23c2ab2f1c56f999.
Reviewed By: cferris
Differential Revision: https://reviews.llvm.org/D144920
Nikita Popov [Tue, 28 Feb 2023 16:41:43 +0000 (17:41 +0100)]
[Orc] Try to fix linker error
Try to fix flang-aarch64-sharedlibs build.
7344f8a8442a9c3cef159445f71b4f2886ed2798 introduced a use of
LLVMCreatePassBuilderOptions(), which is part of the Passes
library, while previously only InstCombine was linked.
ibricchi [Tue, 28 Feb 2023 16:19:48 +0000 (08:19 -0800)]
[unittest] Restructure plugin cmake target
Move plugin source and cmake files into separate directory.
Typically cmake targets in LLVM have a single target per directory.
This change brings this unittest more inline with that structure.
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D140588
bixia1 [Tue, 28 Feb 2023 15:45:27 +0000 (07:45 -0800)]
[mlir][sparse] Add runtime support for reading a COO tensor and writing the data to the given indices and values buffers.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D143862
Corentin Jabot [Fri, 17 Feb 2023 18:45:30 +0000 (19:45 +0100)]
[Clang] Implement CWG2518 - static_assert(false)
This allows `static_assert(false)` to not be ill-formed
in template definitions.
This change is applied as a DR in all C++ modes.
Of notes, a couple of tests were relying of the eager nature
of static_assert
* test/SemaTemplate/instantiation-dependence.cpp
* test/SemaTemplate/instantiate-var-template.cpp
I don't know if the changes to `static_assert`
still allow that sort of tests to be expressed.
Reviewed By: #clang-language-wg, erichkeane, aaron.ballman
Differential Revision: https://reviews.llvm.org/D144285
Nikita Popov [Tue, 28 Feb 2023 15:51:06 +0000 (16:51 +0100)]
[Orc] Use new pass manager in example
Invoke InstCombine via the new pass manager, instead of the
legacy pass manager.
Alexey Bataev [Tue, 28 Feb 2023 14:56:25 +0000 (06:56 -0800)]
[SLP]Fix PR61050: Assertion `I->use_empty() && "trying to erase instruction with users."
When gathering the counter for the reused scalars, need to use reduced
value, not the original reduced value. Same values counter is gathered
for reduced values, not original ones.
Peter Steinfeld [Fri, 24 Feb 2023 22:40:20 +0000 (14:40 -0800)]
[Flang] Fix ALLOCATE with MOLD for scalars
When we allocate a variable using a MOLD argument, the function that
applies the type of the MOLD argument first checks to see if the
variable is already allocated by looking at its descriptor. But in the
case of allocating a scalar, the descriptor was not yet been created and
the associated memory is uninitialized. This change fixes that.
Differential Revision: https://reviews.llvm.org/D144761
Paul Semel [Mon, 27 Feb 2023 18:15:39 +0000 (18:15 +0000)]
[clang][dataflow] unnamed bitfields should be discarded in InitListExpr
Differential Revision: https://reviews.llvm.org/D144892
Chuanqi Xu [Tue, 28 Feb 2023 15:14:51 +0000 (23:14 +0800)]
[C++20] [Modules] Trying to compare the trailing require clause from the primary template function
Close https://github.com/llvm/llvm-project/issues/60890.
For the following example:
```
export module a;
export template<typename T>
struct a {
friend void aa(a) requires(true) {
}
};
```
```
export module b;
import a;
struct b {
a<int> m;
};
```
```
export module c;
import a;
struct c {
void f() const {
aa(a<int>());
}
};
```
```
import a;
import b;
import c;
void d() {
aa(a<int>());
}
```
The current clang will reject this incorrectly. The reason is that the
require clause will be replaced with the evaluated version
(https://github.com/llvm/llvm-project/blob/
efae3174f09560353fb0f3d528bcbffe060d5438/clang/lib/Sema/SemaConcept.cpp#L664-L665).
In module 'b', the friend function is instantiated but not used so the
require clause of the friend function is `(true)`. However, in module
'c', the friend function is used so the require clause is `true`. So
deserializer classify these two function to two different functions
instead of one. Then here is the bug report.
The proposed solution is to try to compare the trailing require clause
of the primary template when performing ODR checking.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D144626
Timm Bäder [Mon, 6 Feb 2023 14:23:39 +0000 (15:23 +0100)]
[clang][Interp][NFC] Clean up InterpState.cpp
Remove unused includes, an unused using alias and braces in single-line
if statements.
Tom Eccles [Tue, 28 Feb 2023 15:21:00 +0000 (15:21 +0000)]
[flang] lower hlfir.transpose into fir runtime call
Depends on D144881
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D144882
Tom Eccles [Mon, 27 Feb 2023 14:31:39 +0000 (14:31 +0000)]
[flang] lower transpose intrinsic to hlfir.transpose operation
Depends on D144880
Differential Revision: https://reviews.llvm.org/D144881
Tom Eccles [Mon, 27 Feb 2023 13:49:29 +0000 (13:49 +0000)]
[flang] add hlfir.transpose operation
Add a HLFIR operation for the TRANSPOSE transformational intrinsic,
according to the design set out in flang/doc/HighLevelFIR.md
Differential Revision: https://reviews.llvm.org/D144880
Timm Bäder [Thu, 16 Feb 2023 07:22:26 +0000 (08:22 +0100)]
[clang][Interp][NFC] Use qualified name in Function::getName()
Sanjay Patel [Tue, 28 Feb 2023 14:15:24 +0000 (09:15 -0500)]
[InstCombine] use demanded vector elements to eliminate partially redundant instructions
In issue #60632, we have vector math ops that differ because an
operand is shuffled, but the math has limited demanded elements,
so it can be replaced by another instruction:
https://alive2.llvm.org/ce/z/TKqq7H
I don't think we have anything like this yet - it's like a
CSE/GVN fold, but driven by demanded elements of a vector op.
This is limited to splat-0 as a first step to keep it simple.
Differential Revision: https://reviews.llvm.org/D144760
David Truby [Tue, 28 Feb 2023 14:32:37 +0000 (14:32 +0000)]
[flang] Allow `to` argument of move_alloc to be class(*)
This patch expands the runtime check in move_alloc to allow the
destination to be unlimited polymorphic.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D143571
Nikita Popov [Tue, 28 Feb 2023 13:49:38 +0000 (14:49 +0100)]
[CGProfile] Don't fetch BFI without profile (NFCI)
Don't fetch BFI if the function has no entry count. Peculiarly,
the implementation was already doing this for the (no longer
existing) legacy PM implementation, but the same principle applies
to the new pass manager. The only reason why the new PM doesn't
have LazyBFI is that with the new pass manager all passes are
lazy.
This improves compile-time for non-PGO builds.
Jean Perier [Tue, 28 Feb 2023 14:15:29 +0000 (15:15 +0100)]
[flang][hlfir] Support type descriptor for initialized character component
These compiler generated component descriptor include designators packaged
as CLASS(*) for simplicity. HLFIR hit an assert in an std::get trying to
recover an Expr<SomeChar> while translating the expression type.
Use the dynamic type of the CLASS(*) expr in that case to recover the
compiler length.
Differential Revision: https://reviews.llvm.org/D144960
Adrian Vogelsgesang [Sat, 20 Aug 2022 20:27:32 +0000 (13:27 -0700)]
[libc++][spaceship] Implement `operator<=>` for `list`
Implements part of P1614R2 "The Mothership has Landed"
Differential Revision: https://reviews.llvm.org/D132312
David Sherwood [Tue, 31 Jan 2023 09:39:06 +0000 (09:39 +0000)]
[AArch64][SME2] Add multi-vector uunpk and sunpk intrinsics
This patch adds the LLVM IR intrinsics for the following:
* uunpk (2 and 4 vectors)
* sunpk (2 and 4 vectors)
I have named the tests sve2p1-intrinsics-* because although
the instructions are added as part of the SME2 feature they
only operate on SVE vectors.
NOTE: These intrinsics are still in development and are subject to future changes.
Differential Revision: https://reviews.llvm.org/D142964
Nikita Popov [Tue, 28 Feb 2023 13:49:38 +0000 (14:49 +0100)]
[CGProfile] Remove unnecessary analysis callbacks (NFC)
These were used to abstract between NewPM and LegacyPM. Now that
the LegacyPM implementation is gone, we can fetch the analyses
directly from the FAM.
Nikita Popov [Tue, 28 Feb 2023 13:21:46 +0000 (14:21 +0100)]
[LoopSink] Don't fetch analyses without profile data (NFCI)
The loop sink pass only does something if the function has
profile data. Move the check for that before analyses are fetched,
to avoid computing things like BFI or MSSA unnecessarily.
Valentin Clement [Tue, 28 Feb 2023 13:26:43 +0000 (14:26 +0100)]
[flang] Use unsigned to avoid comparison warning
Nicolas Vasilache [Mon, 27 Feb 2023 09:28:56 +0000 (01:28 -0800)]
[mlir][Linalg] Refactor HoistPadding and add support for hoisting in the absence of packing loops.
This revision cleans up the implementation of hoist padding and extends it to also work in the
absence of packing loops.
This allows better composition when hoisting the padded result of a DPS operation.
A systematic usage of RewriterBase is applied to the implementation.
Depends on: D144856
Differential Revision: https://reviews.llvm.org/D144855
Nikita Popov [Tue, 28 Feb 2023 10:49:26 +0000 (11:49 +0100)]
[LoopVectorize] Only fetch BFI if profile summary available
BlockFrequencyInfo should generally only be fetched in PGO builds
where a PSI profile summary is available. However, LoopVectorize
was fetching it unconditionally.
This results in a small compile-time improvement for non-PGO builds.
Differential Revision: https://reviews.llvm.org/D144953
Jean Perier [Tue, 28 Feb 2023 13:11:39 +0000 (14:11 +0100)]
[flang][hlfir] Support type bound procedure in type descriptors
In hlfir, procedure designators are propagated as fir.box_proc.
Derived type descriptors are compiler generated constant structure
constructors. They contain CFPTR components for the type bound
procedure addresses.
Before being cast to an integer type so that they can be stored
in the CFPTR components, the fir.box_proc addresses must be
obtained with a fir.box_addr.
Differential Revision: https://reviews.llvm.org/D144952
Jean Perier [Tue, 28 Feb 2023 13:09:27 +0000 (14:09 +0100)]
[flang][hlfir] Lower parent component references
Skip the parent components when they are not at the end of
designators.
Generate an hlfir.parent_comp for parent component at the end
of designators.
Differential Revision: https://reviews.llvm.org/D144948
Jean Perier [Tue, 28 Feb 2023 13:08:08 +0000 (14:08 +0100)]
[flang][hlfir] Add hlfir.parent_comp for leaf parent component references
In Fortran, it is possible to refer to the "parent part" of a derived
type as if it were a component:
```Fortran
type t1
integer :: i
end type
type t2
integer :: j
end type
type(t2) :: a
print *, a%t1%i ! "inner" parent component reference
print *, a%t1 ! "leaf" parent component reference
end
```
Inner parent component references can be dropped on the floor in
lowering: "a%t1%i" is equivalent to "a%i".
Leaf parent component references, however, must be taken care of. For
scalars, "a%t1" is a simple addressc ast to "t1", for arrays, however,
this creates an array section that must be represented with a descriptor
(fir.box).
hlfir.designate could have been extended to deal with this, but I think
it would make hlfir.designate too complex and hard to manipulate.
This patch adds an hlfir.parent_comp op that represents and implements
leaf parent component references.
Differential Revision: https://reviews.llvm.org/D144946
Valentin Clement [Tue, 28 Feb 2023 13:01:10 +0000 (14:01 +0100)]
[flang] Fix potential segfault in PointerAssociateRemapping
The bounds descriptor passed to the function is an array of [2, newRank]
size. Update the code so the rank is retrieved from the second dimension
and not the rank of the descriptor directly as it will be 2 in any case.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D144949
Ivan Kosarev [Tue, 28 Feb 2023 12:48:10 +0000 (12:48 +0000)]
[AMDGPU][AsmParser] Distinguish literal and modifier SMEM offsets.
Reviewed By: foad
Differential Revision: https://reviews.llvm.org/D144902
sgokhale [Tue, 28 Feb 2023 12:44:18 +0000 (18:14 +0530)]
[LV] Reland testcase in 0ec4cae
JP Lehr [Tue, 28 Feb 2023 12:15:22 +0000 (07:15 -0500)]
[OpenMP][AMDGPU] More detail in AMDGPU kernel launch info
Makes the info that is printed for kernel launches configurable for
different plugins. Adds all machinery to print the detailed launch
info that the current AMD plugin provides and includes e.g. register
spill counts.
The files msgpack.cpp, msgpack.def, and msgpack.h are copied from the old plugin
and are untouched. The contents of UtilitiesHSA.cpp and .h are copied together from
various files from the old plugin. The code was originally written by
Jon Chesterfield. I updated the function and type names visible to the outside, i.e.
in headers, to respect the LLVM conventions.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D144521
sgokhale [Tue, 28 Feb 2023 12:37:36 +0000 (18:07 +0530)]
[LV] Modify test case for commit 4f9a544
Was observing test failure. Relanding the test
Benjamin Kramer [Tue, 28 Feb 2023 12:22:10 +0000 (13:22 +0100)]
Revert "[mlir][linalg] Vectorize tensor.extract using contiguous loads"
This reverts commit
89b144ece330b363713bec369d2d89dc85f715f5. See
https://reviews.llvm.org/D141998 for a test case where this goes wrong.
Sacha Ballantyne [Tue, 28 Feb 2023 11:56:23 +0000 (11:56 +0000)]
[flang] Change COUNT intrinsic to support different kind logicals
Previously COUNT would cast the mask input to logical<4> before passing it
to the runtime function, this has been changed to allow different types of logical.
Reviewed By: tblah
Differential Revision: https://reviews.llvm.org/D144867
Ivan Kosarev [Tue, 28 Feb 2023 11:50:50 +0000 (11:50 +0000)]
[AMDGPU][NFC] Eliminate the u32imm operand definition.
It is only used to infer the types of offset parameters in isel patterns,
which we can specify directly.
Reviewed By: piotr
Differential Revision: https://reviews.llvm.org/D144890
dbakunevich [Mon, 20 Feb 2023 12:18:03 +0000 (19:18 +0700)]
[SCEV][NFC] Introduce utility function to get power of 2
The new function has been added to SCEV that allows to raise the number 2
to the desired power.
Authored-by: Dmitry Bakunevich
Differential Revision: https://reviews.llvm.org/D144381
sgokhale [Tue, 28 Feb 2023 12:02:39 +0000 (17:32 +0530)]
[LV] Reland "Update logic for calculating register usage due to invariants"
Previously, while calculating register usage due to invariants, it was assumed that invariant would always be part of widening
instructions. This resulted in calculating vector register types for vectors which cant be legalized(check the newly added test for more details).
An invariant might not always need a vector register. For e.g., invariant might just be used for iteration check.
This patch checks if the invariant is part of any widening instruction and considers register usage accordingly. Fixes issue 60493
Differential Revision: https://reviews.llvm.org/D143422
Nicolas Vasilache [Fri, 24 Feb 2023 11:59:08 +0000 (03:59 -0800)]
[mlir][Linalg] Refactor transform.structured.pad to separate out hoisting
Depends on: D144717
Differential Revision: https://reviews.llvm.org/D144856
Nicolas Vasilache [Fri, 24 Feb 2023 11:05:41 +0000 (03:05 -0800)]
[mlir][Linalg] NFC - Apply cleanups to transforms
Depends on: D144656
Differential Revision: https://reviews.llvm.org/D144717
Deniz Evrenci [Tue, 28 Feb 2023 10:36:46 +0000 (11:36 +0100)]
[Clang] Do not emit exception diagnostics from coroutines and coroutine lambdas
All exceptions thrown in coroutine bodies are caught and
unhandled_exception member of the coroutine promise type is called.
In accordance with the existing rules of diagnostics related to
exceptions thrown in functions marked noexcept, even if the promise
type's constructor, get_return_object, or unhandled_exception
throws, diagnostics should not be emitted.
Fixes #48797.
Differential Revision: https://reviews.llvm.org/D144352
Florian Hahn [Tue, 28 Feb 2023 10:40:36 +0000 (11:40 +0100)]
[GlobalOpt] Split CleanupPointerRootUsers test with constant exprs.
Split tests for D144468. Adding a test with an icmp constant expression
stopped CleanupPointerRootUsers from being called. Move it to a
separate test.
Nikita Popov [Tue, 28 Feb 2023 09:17:03 +0000 (10:17 +0100)]
[CHR] Do not fetch BFI without profile summary (NFCI)
Do not compute BFI if PGO is not used. This addresses the
compile-time regression from https://reviews.llvm.org/D144769.
sgokhale [Tue, 28 Feb 2023 10:16:59 +0000 (15:46 +0530)]
Revert "[LV] Update logic for calculating register usage due to invariants"
Observing test failure for llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll
This reverts commit
d1628266946fdddb44bdad2b3ccf3cd5fc769f42.
luxufan [Tue, 28 Feb 2023 09:59:02 +0000 (17:59 +0800)]
[Local][InstCombine] Handle MD_noundef in combineMetadataCSE
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D144942
Max Kazantsev [Tue, 28 Feb 2023 09:16:01 +0000 (16:16 +0700)]
[LICM][NFC] Don't preserve DT and loop analyzes separately
This is already implied by getLoopPassPreservedAnalyses.
Differential Revision: https://reviews.llvm.org/D144860
Reviewed By: nikic, skatkov
Dmitry Makogon [Tue, 28 Feb 2023 09:21:58 +0000 (16:21 +0700)]
[GuardWidening] Rename 'isAvailableAt' -> 'canBeHoistedTo' (NFC)
This better describes what this method does.
Dmitry Makogon [Tue, 28 Feb 2023 08:14:37 +0000 (15:14 +0700)]
[GuardWidening] Make sure widened condition operands are available at insertion point
This fixes a possible issue when we could hoist an instruction up to a widenable
condition intrinsic call without making sure its operands are available at
hoisiting point.
Recently insertion point finding algorithm changed a bit, so this availability
check became necessary.
Verifier would crash after we handled the following special case:
L >u C0 && L >u C1 -> L >u max(C0, C1),
Previously we would insert the new condition right before the widenable condition
branch where all L operands were available.
Now we may choose the widenable condition intrinsic call as insertion point and it may
happen so that the L operands are computed after the call, so we have to make sure that
L operands are available at the point we want to insert it.
Differential Revision: https://reviews.llvm.org/D144944
Haojian Wu [Tue, 28 Feb 2023 09:15:28 +0000 (10:15 +0100)]
[mlir] Fix the missing mlir test BUILD.bazel for
3948f0a0b5e5fecddf315b8de321c6a44ee7ff5c
Haojian Wu [Tue, 28 Feb 2023 08:32:30 +0000 (09:32 +0100)]
Matthias Springer [Mon, 27 Feb 2023 09:37:02 +0000 (10:37 +0100)]
[mlir][Affine][NFC] Improve FlatAffineValueConstraint dump
Improve indentation for better readability.
Before:
```
Domain: 0, Range: 2, Symbols: 2, Locals: 1
5 constraints
(None Value Value Value Local const)
1 1 0 -1 0 0 = 0
0 1 -1 0 0 0 >= 0
0 0 1 -1 2 2 >= 0
0 0 -1 1 -2 -1 >= 0
0 -1 1 0 2 0 >= 0
```
After:
```
Domain: 0, Range: 2, Symbols: 2, Locals: 1
5 constraints
(None Value Value Value Local const)
1 1 0 -1 0 0 = 0
0 1 -1 0 0 0 >= 0
0 0 1 -1 2 2 >= 0
0 0 -1 1 -2 -1 >= 0
0 -1 1 0 2 0 >= 0
```
Differential Revision: https://reviews.llvm.org/D144854
Dmitry Makogon [Tue, 28 Feb 2023 06:30:15 +0000 (13:30 +0700)]
[Test] Add test exposing hoisting bug in GuardWidening (NFC)
It hoits instruction without making sure its operands are
available at hoisiting point.
Tobias Gysi [Tue, 28 Feb 2023 07:44:57 +0000 (08:44 +0100)]
[mlir][llvm] Rename LLVMOpsInterfaces.td to LLVMInterfaces.td (NFC).
The revision renames LLVMOpsInterfaces.td since the the tablegen file
contains op and type interfaces.
Reviewed By: ftynse, Dinistro
Differential Revision: https://reviews.llvm.org/D144875
Jun Zhang [Sat, 25 Feb 2023 06:23:01 +0000 (14:23 +0800)]
[InstCombine] Fold signbit test of a pow2 or zero
(X & X) < 0 --> X == MinSignedC
(X & X) > -1 --> X != MinSignedC
Alive2: https://alive2.llvm.org/ce/z/_J5q3S
Closes: https://github.com/llvm/llvm-project/issues/60957
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D144777
Craig Topper [Tue, 28 Feb 2023 06:33:41 +0000 (22:33 -0800)]
[TableGen] Replace a StringMap keyed by Record name with a DenseMap.
We can use the Record* to uniquely identify the Record without using
its name.
LiaoChunyu [Tue, 28 Feb 2023 06:07:25 +0000 (14:07 +0800)]
[RISCV] Enable preferZeroCompareBranch to optimize branch on zero in codegenprepare
Similar to ARM and SystemZ.
Related Patchs: D101778(preferZeroCompareBranch)
https://reviews.llvm.org/rG9a9421a461166482465e786a46f8cced63cd2e9f ( == 0 to u< 1)
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D142071
Chuanqi Xu [Tue, 28 Feb 2023 06:37:08 +0000 (14:37 +0800)]
[NFC] Add a test about template pack for C++20 Modules
I found the issue in a donwstream project. But the case looks fine in
the upstream. Add the test to make sure that it wouldn't happen in the
upstream.
Sameer Sahasrabuddhe [Tue, 28 Feb 2023 05:59:19 +0000 (11:29 +0530)]
[llvm][Uniformity] provide overloads for Instruction* and Value*
Uniformity analysis is mainly concerned with the uniformity of values. But it is
sometimes useful to ask if an instruction is uniform, for example, if the
instruction is a terminator. On LLVM IR, every Instruction is a Value, so the
queries like isUniform() need to be overloaded so that the most derived class
always wins.
Reviewed By: ruiling
Differential Revision: https://reviews.llvm.org/D144699
sgokhale [Mon, 27 Feb 2023 07:50:52 +0000 (13:20 +0530)]
[LV] Update logic for calculating register usage due to invariants
Previously, while calculating register usage due to invariants, it was assumed that invariant would always be part of widening
instructions. This resulted in calculating vector register types for vectors which cant be legalized(check the newly added test for more details).
An invariant might not always need a vector register. For e.g., invariant might just be used for iteration check.
This patch checks if the invariant is part of any widening instruction and considers register usage accordingly. Fixes issue 60493
Differential Revision: https://reviews.llvm.org/D143422
Uday Bondhugula [Sun, 26 Feb 2023 14:56:08 +0000 (20:26 +0530)]
[MLIR] Fix bug in addAffineParallelOpDomain upper bound constraint
Fix upper bound constraint addition in addAffineParallelOpDomain; it was
off by one in the case of constants.
Differential Revision: https://reviews.llvm.org/D144836
Chia-hung Duan [Tue, 28 Feb 2023 03:20:38 +0000 (03:20 +0000)]
[scudo] Set name for reserved regions in SizeClassAllocator64
This improves the readability of address space
Reviewed By: enh
Differential Revision: https://reviews.llvm.org/D144898