platform/upstream/llvm.git
2 years ago[flang][runtime] Catch input error case of missing integer value
Peter Klausler [Sun, 14 Aug 2022 17:29:21 +0000 (10:29 -0700)]
[flang][runtime] Catch input error case of missing integer value

Formatted input allows for an empty numeric input field, which
signifies a zero value, but list-directed and NAMELIST input does
not -- apart from the special case of a NAMELIST array.

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

2 years ago[gn build] Port ad8eb85545c5
LLVM GN Syncbot [Thu, 18 Aug 2022 22:43:34 +0000 (22:43 +0000)]
[gn build] Port ad8eb85545c5

2 years ago[flang][runtime] Handle endian-swapped record headers & footers on input
Peter Klausler [Thu, 18 Aug 2022 16:52:17 +0000 (09:52 -0700)]
[flang][runtime] Handle endian-swapped record headers & footers on input

The runtime I/O library correctly handles endianness conversions on payload
data I/O and on the output of sequential record headers and footers, but
does not swap endianness when required when reading sequential record headers
and footers back in for READ and BACKSPACE statements.  Mea culpa.  Fix.

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

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

2 years ago[flang] Support for character array formats
Peter Klausler [Thu, 18 Aug 2022 17:52:59 +0000 (10:52 -0700)]
[flang] Support for character array formats

A character array can be used as a format in an I/O data transfer
statement, with the interpretation that its elements are concatenated
in element order to constitute the format.

Support in the runtime with an extra optional descriptor argument
to six I/O API calls; support in semantics by removing an earlier
check for a simply contiguous array presented as a format.

Some work needs to be done in lowering to pass a character array
descriptor to the I/O runtime API when present

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

2 years ago[NFC][MLGO] ML Regalloc Priority Advisor
Eric Wang [Thu, 18 Aug 2022 22:27:38 +0000 (15:27 -0700)]
[NFC][MLGO] ML Regalloc Priority Advisor

This patch introduces the priority analysis and the priority advisor,
the default implementation, and the scaffolding for introducing the
other implementations of the advisor.

Reviewed By: mtrofin

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

2 years ago[flang] Accept a null pointer as a NULL(MOLD=...) actual argument
Peter Klausler [Thu, 18 Aug 2022 17:50:53 +0000 (10:50 -0700)]
[flang] Accept a null pointer as a NULL(MOLD=...) actual argument

The MOLD= argument to NULL() is allowed to be a null pointer itself --
for example, NULL(MOLD=NULL(MOLD=...)) should not raise spurious semantic
errors.

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

2 years ago[flang] Improve error message for attempted assignment to a procedure
Peter Klausler [Wed, 17 Aug 2022 19:17:41 +0000 (12:17 -0700)]
[flang] Improve error message for attempted assignment to a procedure

Emit a "Assignment to procedure 'foo' is not allowed" error message
for more cases of 'foo' than just declaraed subprograms, rather than
assuming that those additional cases were named constants.

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

2 years ago[flang] Use naive algorithm for folding complex division when it doesn't over/underflow
Peter Klausler [Wed, 17 Aug 2022 18:34:20 +0000 (11:34 -0700)]
[flang] Use naive algorithm for folding complex division when it doesn't over/underflow

f18 unconditionally uses a scaling algorithm for complex/complex division
that avoids needless overflows and underflows when computing the sum of
the squares of the components of the denominator -- but testing has shown
some 1 ULP differences relative to the naive calculation due to the
extra operations and roundings.  So use the scaling algorithm only when
the naive calculation actually would overflow or underflow.

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

2 years ago[flang] Be more persistent in search for non-intrinsic module file
Peter Klausler [Tue, 16 Aug 2022 21:16:29 +0000 (14:16 -0700)]
[flang] Be more persistent in search for non-intrinsic module file

When a particular module name has been brought into a compilation
as an intrinsic module via USE,INTRINSIC, perhaps indirectly via
an enclosing USE statement, f18 will resolve later USE statements
to it unless they are USE,NON_INTRINSIC.  This is not entirely
correct -- a bare USE statement for a module name that happens to
match that of an intrinsic module should still search the search
paths for a non-intrinsic module file of the same name.

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

2 years ago[flang] Avoid spurious error message in function result compatibility
Peter Klausler [Thu, 18 Aug 2022 17:44:50 +0000 (10:44 -0700)]
[flang] Avoid spurious error message in function result compatibility

When checking function interface compatibility for procedure pointer
assignment/initialization or actual/dummy procedure association, don't
emit a diagnositic about function result shape incompatibility unless
the interfaces differ in rank or have distinct constant extents on a
dimension.  Function results whose dimensions are determined by dummy
arguments or host-associated variables are not necessarily incompatible.

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

2 years ago[flang] Compile-time checks for shape conformance on assignments
Peter Klausler [Mon, 15 Aug 2022 20:24:46 +0000 (13:24 -0700)]
[flang] Compile-time checks for shape conformance on assignments

Assignment statements need to check for array shape conformance
errors that are discernable at compilation time.

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

2 years ago[flang][runtime] Don't raise internal error in user error recovery situation
Peter Klausler [Sun, 14 Aug 2022 17:49:19 +0000 (10:49 -0700)]
[flang][runtime] Don't raise internal error in user error recovery situation

In the case of a data transfer I/O statement with an illegal unit number and
error recovery, ensure that data transfer API calls don't raise internal
errors due to the I/O statement representation unexpectedly being something
other than a data transfer statement.

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

2 years ago[libc++] Implement `operator<=>` for `filesystem::directory_entry`
Adrian Vogelsgesang [Sun, 31 Jul 2022 22:57:10 +0000 (15:57 -0700)]
[libc++] Implement `operator<=>` for `filesystem::directory_entry`

Implements part of P1614R2 "The Mothership has Landed"

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

2 years ago[flang][runtime] Fix error message
Peter Klausler [Sun, 14 Aug 2022 17:02:30 +0000 (10:02 -0700)]
[flang][runtime] Fix error message

A literal % character in an error message needs to be doubled
so that it appears in the output of snprintf().

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

2 years ago[flang][runtime] Catch input error on missing NAMELIST scalar
Peter Klausler [Sun, 14 Aug 2022 16:56:31 +0000 (09:56 -0700)]
[flang][runtime] Catch input error on missing NAMELIST scalar

While a NAMELIST input group item for an array can have fewer
values than expected, or none, an input group item for a scalar
must have a value.

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

2 years ago[flang][runtime] Fix return value for MINVAL/MAXVAL for CHARACTER(kind > 1)
Peter Klausler [Thu, 18 Aug 2022 17:31:13 +0000 (10:31 -0700)]
[flang][runtime] Fix return value for MINVAL/MAXVAL for CHARACTER(kind > 1)

CharacterExtremumAccumulator::GetResult() needs to use byte counts, not wide
character counts, when calling memcpy() & memset().

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

2 years ago[flang] Fold SPACING() correctly when result is subnormal
Peter Klausler [Fri, 12 Aug 2022 20:20:08 +0000 (13:20 -0700)]
[flang] Fold SPACING() correctly when result is subnormal

The intrinsic function SPACING() was being folded to the smallest
normal number (TINY(x)) rather than to a smaller subnormal result
when that result really was subnormal.

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

2 years ago[gn build] Port 0ac597f3cacf
LLVM GN Syncbot [Thu, 18 Aug 2022 21:18:53 +0000 (21:18 +0000)]
[gn build] Port 0ac597f3cacf

2 years ago[flang] Legacy extension intrinsic functions IMAG, IZEXT, JZEXT
Peter Klausler [Fri, 12 Aug 2022 19:28:44 +0000 (12:28 -0700)]
[flang] Legacy extension intrinsic functions IMAG, IZEXT, JZEXT

Support these legacy extension intrinsic functions with unambiguous
semantics in those existing compilers that support them by means
of recognizing them as aliases for standard intrinsics (IMAG) or
with simple rewrites (IZEXT, JZEXT).  Note that ZEXT has different
semantics in different existing compilers, so we will not support it
due to lack of a broad unambiguous precedent.

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

2 years ago[InstCombine] fold bitwise logic or+or+xor+not
Sanjay Patel [Thu, 18 Aug 2022 19:26:32 +0000 (15:26 -0400)]
[InstCombine] fold bitwise logic or+or+xor+not

(~A | C) | (A ^ B) --> ~(A & B) | C
https://alive2.llvm.org/ce/z/Qw3aiJ

This extends the existing fold (just above the new match)
to peek through another 'or' instruction.

This should let the motivating case from issue #57174
simplify completely.

2 years ago[InstCombine] add tests for or-xor-not patterns; NFC
Sanjay Patel [Thu, 18 Aug 2022 17:58:17 +0000 (13:58 -0400)]
[InstCombine] add tests for or-xor-not patterns; NFC

2 years ago[libc++] Implement `operator<=>` for `filesystem::path`
Adrian Vogelsgesang [Sun, 31 Jul 2022 22:21:01 +0000 (15:21 -0700)]
[libc++] Implement `operator<=>` for `filesystem::path`

Implements part of P1614R2 "The Mothership has Landed"

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

2 years ago[llvm] Remove std::clamp equivalent in `Transforms/Utils/MisExpect.cpp`
Joe Loser [Mon, 15 Aug 2022 03:14:18 +0000 (21:14 -0600)]
[llvm] Remove std::clamp equivalent in `Transforms/Utils/MisExpect.cpp`

Use `std::clamp` directly from the standard library now that LLVM is built with
C++17 standards mode.

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

2 years ago[flang][runtime] Improve Fortran I/O behavior when main program is C/C++
Peter Klausler [Fri, 12 Aug 2022 00:16:10 +0000 (17:16 -0700)]
[flang][runtime] Improve Fortran I/O behavior when main program is C/C++

Ensure that I/O buffers are flushed at the end of the program,
and properly detect ttys for predefined units so that Fortran
output is interspersed with output from non-Fortran code.

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

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

Update: fix typo in comment

2 years ago[NFC] Move DXC driver tests
Chris Bieneman [Thu, 18 Aug 2022 20:22:04 +0000 (15:22 -0500)]
[NFC] Move DXC driver tests

The DXC driver tests don't really belong mixed in with the toolchain
tests. This pulls them out to their own file and moves the
SimpleDiagnosticConsumer into a header so it can be used by both DXC and
toolchain tests.

fast-forwarded.

2 years ago[clang][test] Recognize leading unscore for macos
Alex Brachet [Thu, 18 Aug 2022 21:02:35 +0000 (21:02 +0000)]
[clang][test] Recognize leading unscore for macos

Additionally mark this test unsupported for ps5 in addition
to ps4, niether support -fuse-ld=

2 years ago[Hexagon] Add defaulted operator= to classes with defaulted copy ctor
Krzysztof Parzyszek [Thu, 18 Aug 2022 20:50:20 +0000 (13:50 -0700)]
[Hexagon] Add defaulted operator= to classes with defaulted copy ctor

This avoids deprecation warning:
```
warning: definition of implicit copy assignment operator for 'AddrInfo'
is deprecated because it has a user-declared copy constructor
[-Wdeprecated-copy]
```

This fixes https://github.com/llvm/llvm-project/issues/57229

2 years ago[libc++] Make <ranges> non-experimental
Louis Dionne [Thu, 18 Aug 2022 18:06:40 +0000 (14:06 -0400)]
[libc++] Make <ranges> non-experimental

When we ship LLVM 16, <ranges> won't be considered experimental anymore.
We might as well do this sooner rather than later.

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

2 years ago[flang][runtime] Improve error message for incompatible MATMUL arguments
Peter Klausler [Fri, 12 Aug 2022 16:17:09 +0000 (09:17 -0700)]
[flang][runtime] Improve error message for incompatible MATMUL arguments

Print the full shapes of both argument when the dimensions that must
match do not do so.

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

2 years ago[LoopVectorize][LoopAccessAnalysis] add newline to debug message
Michael Maitland [Thu, 18 Aug 2022 20:43:28 +0000 (13:43 -0700)]
[LoopVectorize][LoopAccessAnalysis] add newline to debug message

A debug message in `LoopAccessAnalysis` did not have a newline in it, causing printed debug messages to be formatted incorrectly.

Reviewed By: craig.topper

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

2 years agoRevert "[compiler-rt] Fix check for cross-compiling"
Ellis Hoag [Thu, 18 Aug 2022 20:41:46 +0000 (13:41 -0700)]
Revert "[compiler-rt] Fix check for cross-compiling"

This reverts commit ee80903a2ceb03f4617550eba55881f7b80ebb8e.

This seems to have broke builds

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

2 years ago[libc++] Mark everything inside vector as _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser [Wed, 17 Aug 2022 09:17:34 +0000 (11:17 +0200)]
[libc++] Mark everything inside vector as _LIBCPP_HIDE_FROM_ABI

Reviewed By: ldionne, huixie90, #libc

Spies: libcxx-commits

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

2 years ago[compiler-rt] Fix check for cross-compiling
Ellis Hoag [Thu, 18 Aug 2022 12:58:56 +0000 (05:58 -0700)]
[compiler-rt] Fix check for cross-compiling

When checking if we are cross-compiling, use `CMAKE_HOST_SYSTEM_NAME`
rather than `CMAKE_HOST_SYSTEM` which seems to have the full version
number attached.

Reviewed By: smeenai

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

2 years ago[mlir][shape] add value_of op
Jacques Pienaar [Thu, 18 Aug 2022 18:27:00 +0000 (11:27 -0700)]
[mlir][shape] add value_of op

Reviewed By: jpienaar

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

2 years ago[clang][Driver] Pass correct reproduce flag to lld-link
Alex Brachet [Thu, 18 Aug 2022 20:11:22 +0000 (20:11 +0000)]
[clang][Driver] Pass correct reproduce flag to lld-link

Additionally, the explicit linux target has been removed from the test.

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

2 years ago[RISCV] Use VScaleForTuning in costing of operations whose cost depends on VL
Philip Reames [Thu, 18 Aug 2022 19:56:54 +0000 (12:56 -0700)]
[RISCV] Use VScaleForTuning in costing of operations whose cost depends on VL

On known hardware, reductions, gather, and scatter operations have execution latencies which correlated with the vector length (VL) of the operation. Most other operations (e.g. simply arithmetic) don't correlated in this way, and instead essentially fixed cost as VL varies.

When I'd implemented initial scalable cost model support for reductions, gather, and scatter operations, I had used an upper bound on the statically unknown VL. The argument at the time was that this prevented falsely low costs, and biased the vectorizer away from generating bad (on some hardware) code. Unfortunately, practical experience shows we were a bit too effective at that goal, and the high costs defacto prevents vectorization using these constructs at all.

This patch reverses course, and ties the returned cost not to the maximum possible VL, but the VL which would correspond to VScaleForTuning. This parameter is the same one the vectorizer uses when normalizing loop costs, so the term effectively cancels out. The result is that the vectorizer now sees these constructs as comparable in cost to their fixed length variants.

This does introduce the possibility of the cost for these operations being a significant under estimate on platforms where actual VLEN is far from that implied by VScaleForTuning. On such platforms, we might make poor heuristic choices. Probably not in LV itself (due to the cancellation mentioned above), but possibly during e.g. lowering. I'm not currently aware of any concrete examples of this, but this patch does open a concern which did not previously exist.

Previously, we had the problem of overestimating costs causing the same problem on machines much closer to default values for vscale for tuning. With this patch, we still have that problem potentially if vscale for tuning is set high (manually), and then the code is run on a narrow VLEN machine.

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

2 years ago[gn build] port f7a33090a910
Nico Weber [Thu, 18 Aug 2022 19:48:22 +0000 (15:48 -0400)]
[gn build] port f7a33090a910

2 years ago[OMPIRBuilder] Add support for safelen clause
Prabhdeep Singh Soni [Thu, 18 Aug 2022 19:43:08 +0000 (15:43 -0400)]
[OMPIRBuilder] Add support for safelen clause

This patch adds OMPIRBuilder support for the safelen clause for the
simd directive.

Reviewed By: shraiysh, Meinersbur

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

2 years ago[cmake] Use `CMAKE_INSTALL_LIBDIR` too
John Ericson [Sun, 4 Apr 2021 17:13:19 +0000 (13:13 -0400)]
[cmake] Use `CMAKE_INSTALL_LIBDIR` too

We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it.
Now we return this.

`LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set
`CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed
entirely.

I imagine this is too potentially-breaking to make LLVM 15. That's fine.
I have a more minimal version of this in the disto (NixOS) patches for
LLVM 15 (like previous versions). This more expansive version I will
test harder after the release is cut.

Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi

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

2 years ago[MLIR] DynamicMemRefType: iteration and access by indices
Michele Scuttari [Thu, 18 Aug 2022 19:29:42 +0000 (21:29 +0200)]
[MLIR] DynamicMemRefType: iteration and access by indices

The methods to perform such operations have been implemented for the DynamicMemRefType in a way that is similar to the implementation for StridedMemRefType. Up until here one could pass an unranked memref to the library, and thus obtain a “dynamic” memref descriptor, but then there would have been no possibility to operate on its content.

2 years ago[flang][nfc] Update expected warning message in test
Emil Kieri [Thu, 18 Aug 2022 19:01:58 +0000 (21:01 +0200)]
[flang][nfc] Update expected warning message in test

to match the emitted warning, which has changed. I push this without
review as it is a one-line NFC. I have discussed it in D130386, which
altered the warning in question.

2 years ago[LinkerWrapper][NFC] Clean-up error handling
Joseph Huber [Thu, 18 Aug 2022 18:59:34 +0000 (14:59 -0400)]
[LinkerWrapper][NFC] Clean-up error handling

Summary:
We should return and propagate these errors instead of reporting them
immediately. Also use llvm::copy instead.

2 years ago[HLSL] Set main as default entry.
Xiang Li [Sat, 6 Aug 2022 08:17:09 +0000 (01:17 -0700)]
[HLSL] Set main as default entry.

When there's no -E option, use main as entry function.

Reviewed By: beanz

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

2 years ago[Inlining] Add a clang option to limit inlining of functions
Wolfgang Pieb [Tue, 5 Jul 2022 16:15:33 +0000 (09:15 -0700)]
[Inlining] Add a clang option to limit inlining of functions

Add the clang option -finline-max-stacksize=<N> to suppress inlining
of functions whose stack size exceeds the given value.

Reviewed By: aeubanks

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

2 years ago[mlir][LLVMIR] "Modernize" LLVM insert/extract element operations
Jeff Niu [Tue, 16 Aug 2022 15:30:55 +0000 (11:30 -0400)]
[mlir][LLVMIR] "Modernize" LLVM insert/extract element operations

This patch "modernizes" the implementation of these operations by
switching them to assembly formats and type inference traits.

Reviewed By: rriddle

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

2 years ago[mlir][memref] Remove extra brackets in doc
Peiming Liu [Thu, 18 Aug 2022 18:03:40 +0000 (18:03 +0000)]
[mlir][memref] Remove extra brackets in doc

There is an (probably) unintended bracket in the documentation for `memref.subview`. See https://mlir.llvm.org/docs/Dialects/MemRef/#memrefsubview-mlirmemrefsubviewop below Example 5.

Reviewed By: aartbik

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

2 years ago[flang] Make sure dynamic extents and length are rounded to 0 if negative
Valentin Clement [Thu, 18 Aug 2022 18:23:09 +0000 (20:23 +0200)]
[flang] Make sure dynamic extents and length are rounded to 0 if negative

Function returning CHARACTER with adjustable length or dynamic arrays
can have negative length or extents passed to them. This patch makes sure
any negative inputs is rounded to 0.

Reviewed By: vdonaldson

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

2 years ago[flang] Set attribute at the correct position
Valentin Clement [Thu, 18 Aug 2022 18:21:21 +0000 (20:21 +0200)]
[flang] Set attribute at the correct position

The TargetRewrite pass can change the number of argument of a function.
An extra llvm.nest attribute is added and was not set at the correct position
if an extra argument was inserted before.

Reviewed By: PeteSteinfeld

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

2 years ago[LV] Support fixed order recurrences.
Florian Hahn [Thu, 18 Aug 2022 18:15:51 +0000 (19:15 +0100)]
[LV] Support fixed order recurrences.

If the incoming previous value of a fixed-order recurrence is a phi in
the header, go through incoming values from the latch until we find a
non-phi value. Use this as the new Previous, all uses in the header
will be dominated by the original phi, but need to be moved after
the non-phi previous value.

At the moment, fixed-order recurrences are modeled as a chain of
first-order recurrences.

Reviewed By: Ayal

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

2 years ago[LV-L] Add const and move method body out of line [nfc]
Philip Reames [Thu, 18 Aug 2022 18:10:11 +0000 (11:10 -0700)]
[LV-L] Add const and move method body out of line [nfc]

2 years ago[libc++] Replace _LIBCPP_INLINE_VISIBILITY and mark all functions _LIBCPP_HIDE_FROM_A...
Nikolas Klauser [Wed, 17 Aug 2022 14:35:57 +0000 (16:35 +0200)]
[libc++] Replace _LIBCPP_INLINE_VISIBILITY and mark all functions _LIBCPP_HIDE_FROM_ABI in __split_buffer

Reviewed By: ldionne, huixie90, #libc

Spies: libcxx-commits

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

2 years ago[LV] Use early continue to simplify code [nfc]
Philip Reames [Thu, 18 Aug 2022 17:31:43 +0000 (10:31 -0700)]
[LV] Use early continue to simplify code [nfc]

2 years ago[test][mlir] Disable tests with HWASAN
Vitaly Buka [Thu, 18 Aug 2022 17:15:41 +0000 (10:15 -0700)]
[test][mlir] Disable tests with HWASAN

Re-enable after fixing https://github.com/llvm/llvm-project/issues/57231

2 years ago[test] Disable DynamicLibrary with HWASAN
Vitaly Buka [Thu, 18 Aug 2022 16:59:46 +0000 (09:59 -0700)]
[test] Disable DynamicLibrary with HWASAN

Re-enabled when https://github.com/llvm/llvm-project/issues/57206 fixed.

2 years ago[NFC][libc] Detect HWASAN support macro
Vitaly Buka [Thu, 18 Aug 2022 16:57:56 +0000 (09:57 -0700)]
[NFC][libc] Detect HWASAN support macro

2 years ago[flang][test] Fix semantics tests with respect to warnings
Emil Kieri [Wed, 17 Aug 2022 17:56:03 +0000 (19:56 +0200)]
[flang][test] Fix semantics tests with respect to warnings

Make tests expect the (correctly) emitted warnings using the WARNING
directive. This directive is non-functional now, but will be recognised
by test_errors.py when D125804 is landed. This patch is a preparation
for D125804.

For most tests, we add missing WARNING directives for emitted warnings,
but there are exceptions:

 - for int-literals.f90 and resolve31.f90 we pass -pedantic to the
   frontend driver, so that the expected warnings are actually emitted.

 - for block-data01.f90 and resolve42.f90 we change the tests so that
   warnings, which appear unintentional, are not emitted. While testing
   the warning in question (padding added for alignment in common block)
   would be desired, that is beyond the scope of this patch. This
   warning is target-dependent.

Reviewed By: PeteSteinfeld

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

2 years ago[mlir][LLVMIR] Fix syntax in integration tests (NFC)
Jeff Niu [Thu, 18 Aug 2022 17:09:12 +0000 (13:09 -0400)]
[mlir][LLVMIR] Fix syntax in integration tests (NFC)

2 years ago[SVE] Extend findMoreOptimalIndexType so BUILD_VECTORs do not force 64bit indices.
Paul Walker [Sun, 24 Jul 2022 12:30:56 +0000 (13:30 +0100)]
[SVE] Extend findMoreOptimalIndexType so BUILD_VECTORs do not force 64bit indices.

Extends findMoreOptimalIndexType to allow ISD::BUILD_VECTOR based
indices to be truncated when such truncation is lossless. This can
enable the use of 32bit gather/scatter indices thus making it less
likely to have to split a gather/scatter in two.

Depends on D125194

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

2 years ago[CostModel][X86] Add explicit int/fp arithmetic test coverage for avx512/slm/glm...
Simon Pilgrim [Thu, 18 Aug 2022 16:46:45 +0000 (17:46 +0100)]
[CostModel][X86] Add explicit int/fp arithmetic test coverage for avx512/slm/glm targets

2 years ago[mlir][LLVMIR] Change ShuffleVectorOp to use assembly format
Jeff Niu [Wed, 17 Aug 2022 16:22:20 +0000 (12:22 -0400)]
[mlir][LLVMIR] Change ShuffleVectorOp to use assembly format

This patch moves `LLVM::ShuffleVectorOp` to assembly format and in the
process drops the extra type that can be inferred (both operand types
are required to be the same) and switches to a dense integer array.

The syntax change:

```
// Before
%0 = llvm.shufflevector %0, %1 [0 : i32, 0 : i32, 0 : i32, 0 : i32] : vector<4xf32>, vector<4xf32>
// After
%0 = llvm.shufflevector %0, %1 [0, 0, 0, 0] : vector<4xf32>
```

Reviewed By: dcaballe

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

2 years ago[clangd] Fix a tsan failure in PreambleThrottle tests
Kadir Cetinkaya [Thu, 18 Aug 2022 16:34:21 +0000 (18:34 +0200)]
[clangd] Fix a tsan failure in PreambleThrottle tests

2 years agoUse a SmallPtrSet rather than a SmallVector in ClusterManager.
Jim Ingham [Tue, 16 Aug 2022 21:07:28 +0000 (14:07 -0700)]
Use a SmallPtrSet rather than a SmallVector in ClusterManager.

The m_objects store in this class is only used to check whether
this ClusterManager already owns this pointer.  With a SmallVector
the is_contained call was non-linear in number of children, and for
instance printing all the elements of a 16M element std::vector
didn't complete in the time I was willing to wait for it (hours).

Since we are only doing insert & contains, some kind of set is a
better data structure.  In this patch I used SmallPtrSet.  With
that, the same array prints out in 30 seconds.  I also tried a
std::unordered_set but that was slightly slower and used a fair bit
more memory.

Other than performance, this is NFC.

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

2 years agoRevert "[FindGRPC.cmake] Use `llvm_add_library()` for the custom proto target instead...
Argyrios Kyrtzidis [Thu, 18 Aug 2022 15:17:45 +0000 (08:17 -0700)]
Revert "[FindGRPC.cmake] Use `llvm_add_library()` for the custom proto target instead of `add_llvm_library()`"

Breaks configuring `clangd` with `-DCLANGD_ENABLE_REMOTE=On` (https://github.com/llvm/llvm-project/issues/57213)

This reverts commit ba688024077c3e51c6a0949246b2a1b76284e681.

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

2 years ago[CostModel][X86] Add explicit cmp/select test coverage for slm/glm targets
Simon Pilgrim [Thu, 18 Aug 2022 16:05:30 +0000 (17:05 +0100)]
[CostModel][X86] Add explicit cmp/select test coverage for slm/glm targets

2 years ago[CostModel][X86] Adjust SLM select costs to match poor throughput of pblendvb/blendvp...
Simon Pilgrim [Thu, 18 Aug 2022 15:53:17 +0000 (16:53 +0100)]
[CostModel][X86] Adjust SLM select costs to match poor throughput of pblendvb/blendvpd/blendvps

2 years ago[AMDGPU] Update comment on shrinking dpp. NFC
Joe Nash [Thu, 18 Aug 2022 14:58:54 +0000 (10:58 -0400)]
[AMDGPU] Update comment on shrinking dpp. NFC

2 years ago[flang] Enable SimplifyIntrinsics pass in driver.
Slava Zakharin [Wed, 17 Aug 2022 20:00:57 +0000 (13:00 -0700)]
[flang] Enable SimplifyIntrinsics pass in driver.

The pass is enabled for O1/O2/O3 optlevels now.

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

2 years ago[NFC][libc++] Fixes a typo.
Mark de Wever [Thu, 18 Aug 2022 15:27:43 +0000 (17:27 +0200)]
[NFC][libc++] Fixes a typo.

Discovered by phosek in D126971.

2 years ago[BOLT][AArch64] Ignore functions with islandsInfo during VeneerEliminarion and ICF
Denis Revunov [Fri, 29 Jul 2022 13:01:00 +0000 (09:01 -0400)]
[BOLT][AArch64] Ignore functions with islandsInfo during VeneerEliminarion and ICF

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

Reviewed By: yota9

2 years ago[InstCombine] Fix freeze instruction getting inserted before landingpad
Danila Malyutin [Thu, 18 Aug 2022 06:51:06 +0000 (09:51 +0300)]
[InstCombine] Fix freeze instruction getting inserted before landingpad

The code would use first non-phi instruction as an insertion point, however
this could lead to freeze getting inserted between phi and landingpad
causing a verifier assert.

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

2 years ago[Flang][OpenMP] Provide an error when the minus operator is used in a reduction
Kiran Chandramohan [Thu, 18 Aug 2022 14:34:45 +0000 (14:34 +0000)]
[Flang][OpenMP] Provide an error when the minus operator is used in a reduction

OpenMP 5.2 standard has deprecated the usage of the minus operation in
reductions. The minus operation also is an unpleasant feature with
varied interpretations.

The patch also changes the usage of the minus operator in some existing testcases.

Discussed in https://discourse.llvm.org/t/openmp-runtime-problem-with-subtraction-reduction/64404

Reviewed By: peixin

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

2 years ago[CostModel][X86] Add cost kinds test coverage for integer comparisons
Simon Pilgrim [Thu, 18 Aug 2022 14:25:27 +0000 (15:25 +0100)]
[CostModel][X86] Add cost kinds test coverage for integer comparisons

2 years ago[libc++][NFC] Add a short description for __split_buffer
Nikolas Klauser [Wed, 17 Aug 2022 15:01:02 +0000 (17:01 +0200)]
[libc++][NFC] Add a short description for __split_buffer

Reviewed By: Mordante, huixie90, #libc

Spies: libcxx-commits

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

2 years ago[LV] Restructure isPredicatedInst and isScalarWithPredication (w/a fix for uniform...
Philip Reames [Thu, 18 Aug 2022 14:08:39 +0000 (07:08 -0700)]
[LV] Restructure isPredicatedInst and isScalarWithPredication (w/a fix for uniform mem ops)

This change reorganizes the code and comments to make the expected semantics of these routines more clear. However, this is *not* an NFC change. The functional change is having isScalarWithPredication return false if the instruction does not need predicated. Specifically, for the case of a uniform memory operation we were previously considering it *not* to be a predicated instruction, but *were* considering it to be scalable with predication.

As can be seen with the test changes, this causes uniform memory ops which should have been lowered as uniform-per-parts values to instead be lowering via naive scalarization or if scalarization is infeasible (i.e. scalable vectors) aborted entirely. I also don't trust the code to bail out correctly 100% of the time, so it's possible we had a crash or miscompile from trying to scalarize something which isn't scalaralizable. I haven't found a concrete example here, but I am suspicious.

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

2 years ago[clangd] Use the "macro" semantic token for pre-defined identifiers
Christian Kandeler [Thu, 18 Aug 2022 14:12:50 +0000 (16:12 +0200)]
[clangd] Use the "macro" semantic token for pre-defined identifiers

This matches user expectations.

Reviewed By: sammccall

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

2 years ago[Flang] Mark 128 float MODULO intrinsic calls as "TODO"
Peter Steinfeld [Wed, 17 Aug 2022 23:54:34 +0000 (16:54 -0700)]
[Flang] Mark 128 float MODULO intrinsic calls as "TODO"

The code generated for this version of the intrinsic is broken.  I'm
marking it as a "TODO" for now so that people don't get unannounce bad
results.

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

2 years ago[CostModel][X86] getArithmeticInstrCost - use MUL/DIV/REM expansions for all cost...
Simon Pilgrim [Thu, 18 Aug 2022 13:18:54 +0000 (14:18 +0100)]
[CostModel][X86] getArithmeticInstrCost - use MUL/DIV/REM expansions for all cost kinds

The costs tables still assume throughput, but the general expansion patterns should be good for any cost kind

2 years ago[CostModel][X86] Add cost kinds test coverage for integer division/remainder operators
Simon Pilgrim [Thu, 18 Aug 2022 12:48:42 +0000 (13:48 +0100)]
[CostModel][X86] Add cost kinds test coverage for integer division/remainder operators

2 years ago[clang-tidy] Rename a local cmake variables to match the new tool name. NFC.
Martin Storsjö [Thu, 28 Jul 2022 10:54:43 +0000 (13:54 +0300)]
[clang-tidy] Rename a local cmake variables to match the new tool name. NFC.

This shouldn't have any externally visible effect.

This matches the new name from 18b4a8bcf3553174f770f09528c9bd01c8cebfe7.

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

2 years ago[CostModel] Replace getUserCost with getInstructionCost
Simon Pilgrim [Thu, 18 Aug 2022 10:55:23 +0000 (11:55 +0100)]
[CostModel] Replace getUserCost with getInstructionCost
* Replace getUserCost with getInstructionCost, covering all cost kinds.
* Remove getInstructionLatency, it's not implemented by any backends, and we should fold the functionality into getUserCost (now getInstructionCost) to make it easier for targets to handle the cost kinds with their existing cost callbacks.

Original Patch by @samparker (Sam Parker)

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

2 years ago[Clang] Propagate const context info when emitting compound literal
Ties Stuij [Thu, 18 Aug 2022 10:25:07 +0000 (11:25 +0100)]
[Clang] Propagate const context info when emitting compound literal

This patch fixes a crash when trying to emit a constant compound literal.

For C++ Clang evaluates either casts or binary operations at translation time,
but doesn't pass on the InConstantContext information that was inferred when
parsing the statement.  Because of this, strict FP evaluation (-ftrapping-math)
which shouldn't be in effect yet, then causes checkFloatingpointResult to return
false, which in tryEmitGlobalCompoundLiteral will trigger an assert that the
compound literal wasn't constant.

The discussion here around 'manifestly constant evaluated contexts' was very
helpful to me when trying to understand what LLVM's position is on what
evaluation context should be in effect, together with the explanatory text in
that patch itself:
https://reviews.llvm.org/D87528

Reviewed By: rjmccall, DavidSpickett

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

2 years agoPrecommit tests for D132115
wanglian [Thu, 18 Aug 2022 09:06:11 +0000 (17:06 +0800)]
Precommit tests for D132115

Reviewed By: david-arm

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

2 years ago[AMDGPU][MC][GFX11][NFC] Add missing tests for DS opcodes
Dmitry Preobrazhensky [Thu, 18 Aug 2022 09:50:29 +0000 (12:50 +0300)]
[AMDGPU][MC][GFX11][NFC] Add missing tests for DS opcodes

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

2 years ago[mlir][SCF] Loop lb/ub are symbols during Affine Min/Max canonicalization
Matthias Springer [Thu, 18 Aug 2022 09:43:20 +0000 (11:43 +0200)]
[mlir][SCF] Loop lb/ub are symbols during Affine Min/Max canonicalization

This fixes a bug in SCF/AffineCanonicalizationUtils.cpp. Loop lb/ub were previously considered dimensions, which caused a crash when a (non-optimizable) affine.min / affine.max expression was processed (due to multiplication of two dims). Lb/ub are now considered symbols and symbols may be multiplied. (The scope of the analysis is "within the loop body", at which point lb/ub are constants.)

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

2 years ago[Transforms] LICM.cpp - pull out repeated getUserCost call
Simon Pilgrim [Thu, 18 Aug 2022 09:43:21 +0000 (10:43 +0100)]
[Transforms] LICM.cpp - pull out repeated getUserCost call

Pulled out of D79483

2 years ago[Analysis] CostModel.cpp - merge isa<IntrinsicInst> and dyn_cast<IntrinsicInst> checks
Simon Pilgrim [Thu, 18 Aug 2022 09:41:15 +0000 (10:41 +0100)]
[Analysis] CostModel.cpp - merge isa<IntrinsicInst> and dyn_cast<IntrinsicInst> checks

Pulled out of D79483

2 years ago[AMDGPU][MC][GFX10][NFC] Split large test
Dmitry Preobrazhensky [Thu, 18 Aug 2022 09:37:27 +0000 (12:37 +0300)]
[AMDGPU][MC][GFX10][NFC] Split large test

Split gfx10_dasm_all.txt by encoding.

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

2 years ago[mlir][bufferize] Better error handling: Fail if ToMemrefOps are found
Matthias Springer [Thu, 18 Aug 2022 08:11:39 +0000 (10:11 +0200)]
[mlir][bufferize] Better error handling: Fail if ToMemrefOps are found

bufferization.to_memref ops are not supported in One-Shot Analysis. They often trigger a failed assertion that can be confusing. Instead, scan for to_memref ops before running the analysis and immediately abort with a proper error message.

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

2 years ago[NFC][AArch64] precommit sched model for tsv110
zhongyunde [Thu, 18 Aug 2022 09:31:19 +0000 (17:31 +0800)]
[NFC][AArch64] precommit sched model for tsv110

Part of the schedule model is not accurate, so need a initial test record the changes.
This assemble list is refer to the basic part of D128631

Reviewed By: dmgreen

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

2 years ago[MLIR][NFC] Sort table of operations alphabetically
Mats Petersson [Wed, 17 Aug 2022 17:55:48 +0000 (18:55 +0100)]
[MLIR][NFC] Sort table of operations alphabetically

Arrange the operations in alphabetical order, rather than what
appears to be the order they were added. This was suggested in
a review when adding new operations.

Reviewed By: rriddle

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

2 years ago[mlir][test] Require JIT support in JIT tests
Rainer Orth [Thu, 18 Aug 2022 09:26:07 +0000 (11:26 +0200)]
[mlir][test] Require JIT support in JIT tests

A number of mlir tests `FAIL` on Solaris/sparcv9 with `Target has no JIT
support`.  This patch fixes that by mimicing `clang/test/lit.cfg.py` which
implements a `host-supports-jit` keyword for this.  The gtest-based unit
tests don't support `REQUIRES:`, so lack of support needs to be hardcoded
there.

Tested on `amd64-pc-solaris2.11` (`check-mlir` results unchanged) and
`sparcv9-sun-solaris2.11` (only one unrelated failure left).

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

2 years ago[MLIR] Remove hardcoded usage of alloc/dealloc; use memory effects
Uday Bondhugula [Wed, 17 Aug 2022 04:23:54 +0000 (09:53 +0530)]
[MLIR] Remove hardcoded usage of alloc/dealloc; use memory effects

Remove hardcoded usage of memref.alloc/dealloc ops in affine utils; use memory
effects instead. This is NFC for existing test cases, but strictly more
general/powerful in terms of functionality: it allows other allocation and
freeing ops (like gpu.alloc/dealloc) to work in conjunction with affine ops and
utilities.

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

2 years ago[mlir][Vector] Support 0-D vectors in ReductionOp
Güray Özen [Mon, 15 Aug 2022 15:14:12 +0000 (15:14 +0000)]
[mlir][Vector] Support 0-D vectors in ReductionOp

This commit adds support for 0-D vectors in ReductionOp.

Reviewed By: nicolasvasilache, dcaballe

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

2 years ago[X86] Add schedule module for Alderlake-P
Haohai Wen [Thu, 18 Aug 2022 08:37:41 +0000 (16:37 +0800)]
[X86] Add schedule module for Alderlake-P

The X86SchedAlderlakeP.td file is automatically generated by schedtool
(D130897). Most of instruction's scheduling information is based on
measured ADL-P data in uops.info. Some data is from GLC tpt/lat data
provided by intel doc. The rest instruction's scheduling information is
from skylake client schedule model in order to get a relative complete
model.

Reviewed By: RKSimon

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

2 years agoDo not evaluate dependent immediate invocations
Utkarsh Saxena [Wed, 17 Aug 2022 14:44:41 +0000 (16:44 +0200)]
Do not evaluate dependent immediate invocations

We deferred the evaluation of dependent immediate invocations in https://reviews.llvm.org/D119375 until instantiation.
We should also not consider them referenced from a non-consteval context.

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

```
template<typename T>
class Bar {
  consteval static T x() { return 5; }
 public:
  Bar() : a(x()) {}

 private:
  int a;
};

Bar<int> g();
```
Is now accepted by clang. Previously it errored with: `cannot take address of consteval function 'x' outside of an immediate invocation  Bar() : a(x()) {}`

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

2 years ago[tsan] Keep thread/stack for closed FD
Vitaly Buka [Wed, 17 Aug 2022 20:44:53 +0000 (13:44 -0700)]
[tsan] Keep thread/stack for closed FD

Fixes b/242869837

Reviewed By: dvyukov

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

2 years agoRevert "[Driver] Support libc++ in MSVC"
Petr Hosek [Thu, 18 Aug 2022 08:22:43 +0000 (08:22 +0000)]
Revert "[Driver] Support libc++ in MSVC"

This reverts commit a4230319f7af786f4d947f39a870f339b32a6fe7.

This is causing build failures in the 2-stage build.

2 years ago[LoongArch] Supports brcond with 21 bit offsets
gonglingqin [Thu, 18 Aug 2022 07:37:12 +0000 (15:37 +0800)]
[LoongArch] Supports brcond with 21 bit offsets

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

2 years ago[DAGCombiner][NFC] Tidy up unnecessary brackets in visitADD.
wanglian [Thu, 18 Aug 2022 07:09:21 +0000 (15:09 +0800)]
[DAGCombiner][NFC] Tidy up unnecessary brackets in visitADD.

Reviewed By: sdesmalen

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

2 years ago[llvm-objdump] Support dumping segment information with -chained_fixups
Daniel Bertalan [Fri, 12 Aug 2022 13:10:58 +0000 (15:10 +0200)]
[llvm-objdump] Support dumping segment information with -chained_fixups

This commit adds the definitions for `dyld_chained_starts_in_image`,
`dyld_chained_starts_in_segment`, and related enums. Dumping their
contents is possible with the -chained_fixups flag of llvm-otool.

The chained-fixups.yaml test was changed to cover bindings/rebases, as
well as weak imports, weak symbols and flat namespace symbols. Now that
we have actual fixup entries, the __DATA segment contains data that
would need to be hexdumped in YAML. We also test empty pages (to look
for the "DYLD_CHAINED_PTR_START_NONE" annotation), so the YAML would end
up quite large. So instead, this commit includes a binary file.

When Apple's effort to upstream their chained fixups code continues,
we'll replace this code with the then-upstreamed code. But we need
something in the meantime for testing ld64.lld's chained fixups code.

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