platform/upstream/llvm.git
16 months ago[libc] Fix common compile options not getting passed to GPU object
Joseph Huber [Fri, 10 Mar 2023 22:53:43 +0000 (16:53 -0600)]
[libc] Fix common compile options not getting passed to GPU object

Summary:
This variable was named incorrectly. We weren't getting needed flags
passed to object library builds.

16 months agoImplements MLIR Bytecode versioning capability
Matteo Franciolini [Tue, 14 Feb 2023 16:45:08 +0000 (08:45 -0800)]
Implements MLIR Bytecode versioning capability

A dialect can opt-in to handle versioning through the
`BytecodeDialectInterface`. Few hooks are exposed to the dialect to allow
managing a version encoded into the bytecode file. The version is loaded
lazily and allows to retrieve the version information while parsing the input
IR, and gives an opportunity to each dialect for which a version is present
to perform IR upgrades post-parsing through the `upgradeFromVersion` method.
Custom Attribute and Type encodings can also be upgraded according to the
dialect version using readAttribute and readType methods.

There is no restriction on what kind of information a dialect is allowed to
encode to model its versioning. Currently, versioning is supported only for
bytecode formats.

Reviewed By: rriddle, mehdi_amini

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

16 months agoRevert "[X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS"
ManuelJBrito [Fri, 10 Mar 2023 22:23:28 +0000 (22:23 +0000)]
Revert "[X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS"

This reverts commit 1a4d0eb866be909fe16da5ebffe4122aa0693d8c.

16 months ago[cmake] Quote args when generating /libpath option specifying runtime dir for link...
Matthew Voss [Fri, 10 Mar 2023 22:11:37 +0000 (14:11 -0800)]
[cmake] Quote args when generating /libpath option specifying runtime dir for link/lld-link

When the runtime dir path includes whitespace (ex. when it's installed
under "Program Files" on Windows), the lack of quotes causes the linker
to interpret the path as one or more arguments. None of these path
fragments exist, so the link fails.

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

16 months ago[flang] Add missing dependencies for flang/lib/Optimizer/Dialect
Peter Steinfeld [Fri, 10 Mar 2023 21:03:52 +0000 (13:03 -0800)]
[flang] Add missing dependencies for flang/lib/Optimizer/Dialect

Patch D145640 wasn't building for me because .cpp files in
flang/lib/Optimizer/Dialect depend on the files generated in
.../build/include/llfm/IR.  But the .cpp file compilations were being
done before the needed include files were generated.

This patch fixes that by adding dependencies on "intrinsics_gen" to the
CMake files in two directories.

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

16 months agoRevert "[MergeICmps] Adapt to non-eq comparisons, fix bug for cases need be spilted"
Arthur Eubanks [Fri, 10 Mar 2023 21:22:17 +0000 (13:22 -0800)]
Revert "[MergeICmps] Adapt to non-eq comparisons, fix bug for cases need be spilted"

This reverts commit 818e554e251c1e07f133aeed9fe0473502ebfdae.

Causes miscompiles, see comments on D141188.

16 months ago[SLP]Initial support for reshuffling of non-starting buildvector/gather nodes.
Alexey Bataev [Mon, 20 Feb 2023 21:26:11 +0000 (13:26 -0800)]
[SLP]Initial support for reshuffling of non-starting buildvector/gather nodes.

Previously only the very first gather/buildvector node might be probed for reshuffling of other nodes.
But the compiler may do the same for other gather/buildvector nodes too, just need to check the
dependency and postpone the emission of the dependent nodes, if the origin nodes were not emitted yet.

Part of D110978

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

16 months ago[clang][deps] Split lookupModuleOutput out of DependencyConsumer NFC
Ben Langmuir [Fri, 10 Mar 2023 17:48:56 +0000 (09:48 -0800)]
[clang][deps] Split lookupModuleOutput out of DependencyConsumer NFC

The idea is to split the callbacks that are used to consume dependency
information (DependencyConsumer) from callbacks that modify the scan
behaviour itself in any way (DependencyActionController). Currently this
is just lookupModuleOutput, but we have additional callbacks related to
CAS support that we intend to upstream in the future.

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

16 months ago[Driver][FreeBSD] Simplify ARM handling
Brad Smith [Fri, 10 Mar 2023 21:10:44 +0000 (16:10 -0500)]
[Driver][FreeBSD] Simplify ARM handling

Since FreeBSD 8 / 9 support was dropped from the Driver there is room to simplify
things with the ARM handling.

The exception model handling function can be removed.

EABI is now the default.

Reviewed By: dim

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

16 months ago[RISCV] Consistently place single quotes around extension names in error messages.
Craig Topper [Fri, 10 Mar 2023 20:19:10 +0000 (12:19 -0800)]
[RISCV] Consistently place single quotes around extension names in error messages.

Some extensions had them, some did not.

Reviewed By: asb

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

16 months ago[SLP][NFC]Add a test with phi nodes in one tree node with different
Alexey Bataev [Fri, 10 Mar 2023 20:18:23 +0000 (12:18 -0800)]
[SLP][NFC]Add a test with phi nodes in one tree node with different
order of incoming basic blocks, NFC.

16 months ago[Debuginfod] Prune cache after fetch.
Daniel Thornburgh [Wed, 8 Mar 2023 22:03:09 +0000 (14:03 -0800)]
[Debuginfod] Prune cache after fetch.

Previously, the size of the debuginfod cache would grow without bound.
This change prunes the cache after a successful debuginfod lookup, as is
done in libdebuginfod.

The cache pruning behavior is configured by a new
DEBUGINFOD_CACHE_POLICY environment variable. The semantics of this are
the same as --thinlto_cache_policy.

Reviewed By: gulfem

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

16 months ago[libc++][NFC] Use std::malloc and std::free instead of unqualified versions in tests
Louis Dionne [Fri, 10 Mar 2023 14:15:14 +0000 (09:15 -0500)]
[libc++][NFC] Use std::malloc and std::free instead of unqualified versions in tests

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

16 months agoRevert "Currently the control of the eval-method is mixed with fast-math."
Zahira Ammarguellat [Thu, 9 Mar 2023 14:24:01 +0000 (09:24 -0500)]
Revert "Currently the control of the eval-method is mixed with fast-math."

Setting __FLT_EVAL_METHOD__ to -1 with fast-math will set
__GLIBC_FLT_EVAL_METHOD to 2 and long double ends up being used for
float_t and double_t. This creates some ABI breakage with various C libraries.
See details here: https://github.com/llvm/llvm-project/issues/60781

This reverts commit bbf0d1932a3c1be970ed8a580e51edf571b80fd5.

16 months ago[libc++] Remove conditional usage of rvalue references in C++03
Louis Dionne [Thu, 9 Mar 2023 17:30:08 +0000 (12:30 -0500)]
[libc++] Remove conditional usage of rvalue references in C++03

This one is easy -- Clang supports rvalue references in C++03 mode, so
we should be able to remove that conditional.

As a fly-by fix, turn a few static_casts to std::forward.

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

16 months ago[CMake] Unify llvm_check_linker_flag and llvm_check_compiler_linker_flag
Petr Hosek [Thu, 9 Mar 2023 18:23:04 +0000 (18:23 +0000)]
[CMake] Unify llvm_check_linker_flag and llvm_check_compiler_linker_flag

These will be replaced by CMake's check_linker_flag once we update
the minimum CMake version 3.20.

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

16 months ago[Fuchsia] Add LLDB to CLANG_BOOTSTRAP_TARGETS.
Daniel Thornburgh [Fri, 10 Mar 2023 19:08:36 +0000 (11:08 -0800)]
[Fuchsia] Add LLDB to CLANG_BOOTSTRAP_TARGETS.

stage2-check-lldb should be run in a 2-stage build to test the final
LLDB artifact, so it and related targets must be exported to the stage 1
project.

Reviewed By: phosek

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

16 months ago[flang] Break shared library cyclic dependence
Peter Klausler [Fri, 10 Mar 2023 19:24:23 +0000 (11:24 -0800)]
[flang] Break shared library cyclic dependence

I inadvertently introduced a cycle of dependences between the Evaluate
and Semantics libraries; this patch breaks that cycle and reenables
the flang build bots that rely on shared library builds.

16 months ago[RISCV] Error if F and Zfinx extensions are specified together.
Craig Topper [Fri, 10 Mar 2023 19:26:00 +0000 (11:26 -0800)]
[RISCV] Error if F and Zfinx extensions are specified together.

Fixes #61277

Reviewed By: asb

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

16 months agollvm-exegesis: Only run target specfic tests on native hosts
Tom Stellard [Fri, 10 Mar 2023 05:06:22 +0000 (00:06 -0500)]
llvm-exegesis: Only run target specfic tests on native hosts

These tests were failing on SystemZ hosts, I don't think JIT'ing non-SystemZ
modules on SystemZ is supported.

The tests were initiallay enabled on all arches by
7a76140220bd2c4730a2c39b6fd645402040f011.

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

16 months ago[mlir][sparse] extend storage specifier operations for slices.
Peiming Liu [Tue, 10 Jan 2023 23:46:45 +0000 (23:46 +0000)]
[mlir][sparse] extend storage specifier operations for slices.

Reviewed By: aartbik

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

16 months ago[mlir][spirv][vector] Add pattern to convert reduction to SPIR-V dot prod
Jakub Kuderski [Fri, 10 Mar 2023 18:54:16 +0000 (13:54 -0500)]
[mlir][spirv][vector] Add pattern to convert reduction to SPIR-V dot prod

This converts a specific form of `vector.reduction` to SPIR-V integer
dot product ops.

Add a new test pass to excercise this outside of the main vector to
spirv conversion pass.

Reviewed By: antiagainst

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

16 months ago[flang][runtime] EOF is recoverable only with END= or IOSTAT=
Peter Klausler [Thu, 9 Mar 2023 00:09:01 +0000 (16:09 -0800)]
[flang][runtime] EOF is recoverable only with END= or IOSTAT=

The runtime's I/O error handler was not crashing the program on an
end-of-file condition that arises for a data transfer statement with
at least one of ERR= or IOMSG= and none of END= or IOSTAT= control
items.  This turns out to be incorrect (per subclause 12.11);
an EOF is recoverable only for END= and/or IOSTAT=, and an
non-advancing end-of-record is recoverable only for EOR= and/or IOSTAT=.

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

16 months ago[SLP][NFC]Add a test with multilevel dependency between buildvector
Alexey Bataev [Fri, 10 Mar 2023 18:28:19 +0000 (10:28 -0800)]
[SLP][NFC]Add a test with multilevel dependency between buildvector
nodes, NFC.

16 months ago[flang][runtime] Use Descriptor::Establish() in elemental derived type defined assign...
Peter Klausler [Wed, 8 Mar 2023 22:45:18 +0000 (14:45 -0800)]
[flang][runtime] Use Descriptor::Establish() in elemental derived type defined assignment calls

The code in DoElementalDefinedAssignment() needs to establish its
to & from per-element descriptors with Establish() rather than
copying an array's descriptor and then setting its rank to zero;
the current technique loses the information in the addendum.

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

16 months ago[flang][runtime] Iterate over array elements in user-defined derived type I/O
Peter Klausler [Wed, 8 Mar 2023 19:56:33 +0000 (11:56 -0800)]
[flang][runtime] Iterate over array elements in user-defined derived type I/O

It was only handling scalars; change to iterate over all array elements.

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

16 months ago[ConstraintElimination] UB reproducer for D145677
Vitaly Buka [Fri, 10 Mar 2023 18:06:50 +0000 (10:06 -0800)]
[ConstraintElimination] UB reproducer for D145677

Reviewed By: fhahn

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

16 months agoMachO: support custom section names on global variables
Tim Northover [Fri, 10 Mar 2023 17:53:49 +0000 (17:53 +0000)]
MachO: support custom section names on global variables

These attributes have been accepted in ELF for a while, and are generated by
Clang in some places, so it makes sense to support them on MachO too.

https://reviews.llvm.org/D143173

16 months agoDon't produce a dynamic value if there was an error creating it.
Jim Ingham [Fri, 10 Mar 2023 18:08:26 +0000 (10:08 -0800)]
Don't produce a dynamic value if there was an error creating it.

We used to make a dynamic value that "pretended to be its parent"
but that's hard for some of the more complex ValueObject types, and
it's better in this case just to return no dynamic value.

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

16 months ago[flang][runtime] Corrections to formatted child I/O
Peter Klausler [Wed, 8 Mar 2023 19:07:39 +0000 (11:07 -0800)]
[flang][runtime] Corrections to formatted child I/O

A handful of I/O statements (OPEN, CLOSE, positioning) are not allowed
on units during child I/O; catch violations and report errors.
Also finesse error handling during FORMAT runtime parsing of DT
derived type edit descriptors, and ensure that formatted child
I/O is nonadvancing.

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

16 months ago[flang] Correct handling of USE-associated generic override in nested scope
Peter Klausler [Tue, 7 Mar 2023 21:29:32 +0000 (13:29 -0800)]
[flang] Correct handling of USE-associated generic override in nested scope

As the new test here shows by failing with the current compiler with
a bogus error message about indistinguishable specific procedures in
a generic interface, name resolution needs to take care to not
copy a USE-associated generic into the current scope for extension
when the USE association is actually into an enclosing scope.

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

16 months ago[flang] Fix checking of TBP bindings
Peter Klausler [Tue, 7 Mar 2023 01:32:12 +0000 (17:32 -0800)]
[flang] Fix checking of TBP bindings

Non-DEFERRED procedure binding checking can't blindly accept
all procedures defined in modules -- they can't be ABSTRACT
interfaces.  And GetUltimate() must be used rather than
FindSubprogram(); the latter will resolve to a procedure's
interface in the case of "procedure(interface) :: external",
not "external".

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

16 months ago[Flang] add space between number and character in print
Shao-Ce SUN [Fri, 10 Mar 2023 17:58:10 +0000 (01:58 +0800)]
[Flang] add space between number and character in print

```
print *, "123",456,"789"
```
before
```
123 456789
```
after
```
123 456 789
```

Reviewed By: klausler

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

16 months agoRevert "[LICM] Support logical AND/OR when hoisting min/max"
Vitaly Buka [Fri, 10 Mar 2023 17:52:57 +0000 (09:52 -0800)]
Revert "[LICM] Support logical AND/OR when hoisting min/max"

Breaks https://lab.llvm.org/buildbot/#/builders/37/builds/20720

This reverts commit 9e83d13c9f77e300ebb7b94a1400de3c2d47b3d5.

16 months ago[test][asan] Fix requirement formatting
Vitaly Buka [Fri, 10 Mar 2023 17:52:08 +0000 (09:52 -0800)]
[test][asan] Fix requirement formatting

16 months ago[flang] Detect obvious argument shape incompatibility when checking procedure compati...
Peter Klausler [Tue, 7 Mar 2023 00:07:24 +0000 (16:07 -0800)]
[flang] Detect obvious argument shape incompatibility when checking procedure compatibility

The compiler presently detects different dummy object array ranks;
extend the compatibility check to also note discrepancies in corresponding
constant dummy argument extents.

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

16 months ago[flang] Diagnose ridiculously large kind parameters
Peter Klausler [Mon, 6 Mar 2023 23:10:47 +0000 (15:10 -0800)]
[flang] Diagnose ridiculously large kind parameters

Kind parameters on literals (1_4, 1.0_8, 4_"Unicode") are not
being caught as errors if they're extremely large integer values
that become valid when truncated to C++'s int type.

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

16 months ago[flang] Check dummy arguments of BIND(C) procedures
Peter Klausler [Mon, 6 Mar 2023 22:29:53 +0000 (14:29 -0800)]
[flang] Check dummy arguments of BIND(C) procedures

Declaration checking in semantics was only examining symbols with
explicit BIND(C) attributes; extend it to also check dummy arguments
to such procedures.

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

16 months ago[flang][runtime] Catch infinite unlimited format repetition better
Peter Klausler [Sun, 5 Mar 2023 22:01:28 +0000 (14:01 -0800)]
[flang][runtime] Catch infinite unlimited format repetition better

The runtime check for infinite unlimited format repetition is missing
the case of implicit unlimited format repetition at the top level
without finding the next data edit descriptor that corresponds with
a data list item.

Replace the check with a Boolean flag that detects unlimited
repetition hitting a right parenthesis and restarting, and fail
when it happens the second time.

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

16 months ago[ConstraintElim] Update test to use variable start value.
Florian Hahn [Fri, 10 Mar 2023 17:29:50 +0000 (18:29 +0100)]
[ConstraintElim] Update test to use variable start value.

Otherwise %x <= 10 will be true on the first iteration, making the latch
dead. This makes the test more robust to CE becoming more powerful in
the future.

16 months ago[flang] Forward references to COMMON from specification expr under IMPLICIT NONE
Peter Klausler [Fri, 3 Mar 2023 19:43:55 +0000 (11:43 -0800)]
[flang] Forward references to COMMON from specification expr under IMPLICIT NONE

As a near-universal extension, Fortran compilers permit forward references
to dummy arguments and variables in COMMON blocks from specification expressions
before an explicit type-declaration-stmt appears for those variables
under IMPLICIT NONE, so long as those variables are later explicitly typed
with the types that regular implicit typing rules would have given them
(usually default INTEGER).

F18 implemented this extension for dummy arguments, but not variables in
COMMON blocks.  Extend the extension to also accept variables in COMMON.

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

16 months ago[RISCV] Support Zfa fli instructions with vector splats.
Craig Topper [Fri, 10 Mar 2023 17:16:21 +0000 (09:16 -0800)]
[RISCV] Support Zfa fli instructions with vector splats.

-Return false from RISCVDAGToDAGISel::selectFPImm for fli
 constants so we don't try to use integer expansion.
-Support fli.h with Zvfh+Zfhmin.

Reviewed By: reames

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

16 months ago[mlir] Add mlir::LLVM::FastmathFlags to LLVM instrinsic vector reductions
Brandon Myers [Fri, 10 Mar 2023 17:12:50 +0000 (09:12 -0800)]
[mlir] Add mlir::LLVM::FastmathFlags to LLVM instrinsic vector reductions

Rationale:
The LLVM dialect supports passing fastmath flags from floating point ops to LLVMIR instructions. However, not all LLVM ops have the required attribute. This change adds support for fastmath flags to `llvm.intr.vector.reduce.{fmin,fmax}`. One scenario where this is useful is in lowering llvm.intr.vector.reduce.{fmax,fmin} to LLVMIR with `nnan` (NoNans) flag so it may be [[ https://github.com/llvm/llvm-project/blob/115c7beda74f3cfaf83b91d14bc97a39bff4cf19/llvm/lib/CodeGen/ExpandReductions.cpp#L159 | lowered to a shuffle reduction ]].

Changes:

  - Make `LLVM_VecReductionF` implement the `FastmathFlagsInterface`; change is modeled on `LLVM_UnaryIntrOpF`
  - Add an assembly format for `LLVM_VecReductionF` ops. The purpose is to keep existing functionality: avoid printing the fastmath flags attribute when it has its default value (`none`). Change is modeled on `LLVM_UnaryIntrOpBase`

Reviewed By: gysit

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

16 months ago[flang] Check that a SELECT TYPE selector is not a procedure
Peter Klausler [Fri, 3 Mar 2023 18:37:13 +0000 (10:37 -0800)]
[flang] Check that a SELECT TYPE selector is not a procedure

A SELECT TYPE statement's selector must be a variable or expression,
not a procedure; specifically, a function with a polymorphic result
is unacceptable.

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

16 months ago[NFC] [CMake] Cleanup clang tool dependencies
Chris Bieneman [Fri, 10 Mar 2023 16:40:19 +0000 (10:40 -0600)]
[NFC] [CMake] Cleanup clang tool dependencies

None of these tools need to depend on clang to build, instead the test
target should depend on them.

This prevents rebuilding/linking these tools when building the `clang`
target directly.

16 months ago[flang] Ignore FINAL subroutines with mismatching type parameters
Peter Klausler [Thu, 2 Mar 2023 16:15:51 +0000 (08:15 -0800)]
[flang] Ignore FINAL subroutines with mismatching type parameters

When a parameterized derived type has FINAL subroutines, only
those FINAL subroutines whose dummy argument's type matches the
type parameter values of a particular instantiation are relevant
to that instantiation.

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

16 months agoReland D144768 "[scudo] Mitigate page releasing thrashing"
Chia-hung Duan [Thu, 9 Mar 2023 16:20:08 +0000 (16:20 +0000)]
Reland D144768 "[scudo] Mitigate page releasing thrashing"

This reverts commit e64fabf51e882cc8e6157b7d139005162adb947c.

Reviewed By: cferris

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

16 months ago[VPlan] Add VPWidenSelectRecipe::getCond() (NFC).
Florian Hahn [Fri, 10 Mar 2023 16:49:23 +0000 (17:49 +0100)]
[VPlan] Add VPWidenSelectRecipe::getCond() (NFC).

Add helper to access condition, as suggested in D144489.

16 months ago[flang] Fix crash in folding TRANSFER() with MOLD=substring
Peter Klausler [Thu, 2 Mar 2023 00:08:43 +0000 (16:08 -0800)]
[flang] Fix crash in folding TRANSFER() with MOLD=substring

When a substring appears as the MOLD= argument to TRANSFER(),
it's possible for the compiler to assert if it can't figure
out a constant length for the substring.  Fix.

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

16 months ago[RISCV] Enable Zfa fli.h instruction in MC layer with Zfhmin and Zvfh.
Craig Topper [Fri, 10 Mar 2023 16:23:23 +0000 (08:23 -0800)]
[RISCV] Enable Zfa fli.h instruction in MC layer with Zfhmin and Zvfh.

According to the spec this instruction is can be enabled with Zfh
and Zvfh (which requires Zfhmin). The other instructions f16
instructions from Zfa require Zfh.

Reviewed By: reames

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

16 months ago[SLP][NFC]Update/simplify test to avoid dead code elimination.
Alexey Bataev [Wed, 8 Mar 2023 21:46:18 +0000 (13:46 -0800)]
[SLP][NFC]Update/simplify test to avoid dead code elimination.

16 months ago[RISCV] Print Zfa fli instruction FP values in a more adaptive way.
Craig Topper [Fri, 10 Mar 2023 15:57:44 +0000 (07:57 -0800)]
[RISCV] Print Zfa fli instruction FP values in a more adaptive way.

Previously, we printed all constants in scientific notation with
6 digits of precision. This is not enough to accurately display
the smallest value, but increasing the precision would be too much
for other values.

This patch prints values with fractional bits using only as many digits as
needed. 1*2^-15 and 1*2^-16 will be printed in scientific notation while
the others are printed without scientific notation. The integer values
are printed with a single 0 after the decimal point.

Reviewed By: reames

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

16 months ago[TargetParser] Disallow Global Constructors
Archibald Elliott [Sat, 4 Feb 2023 13:27:32 +0000 (13:27 +0000)]
[TargetParser] Disallow Global Constructors

Global Constructors are disallowed in the Support library. The
TargetParser library is likely to go along with the Support library in
most uses, because it contains llvm::Triple, so lets pre-emptively add
the same rule, rather than getting caught out later.

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

16 months ago[DebugInfo][DWARF][NFC] follow LLVM style guideline about namespaces.
Alexey Lapshin [Fri, 10 Mar 2023 15:39:07 +0000 (16:39 +0100)]
[DebugInfo][DWARF][NFC] follow LLVM style guideline about namespaces.

16 months ago[LICM] Delay fetching of preheader (NFC)
Nikita Popov [Fri, 10 Mar 2023 15:15:49 +0000 (16:15 +0100)]
[LICM] Delay fetching of preheader (NFC)

Only fetch preheader once we want to actually hoist. It turns out
that calculating the preheader is expensive enough to affect
overall compile-time if you do it for every single instruction.

Addresses the compile-time regression from D143726.

16 months ago[AArch64] NFC: Merge addTypeForStreamingSVE and addTypeForFixedLengthSVE
Sander de Smalen [Fri, 10 Mar 2023 13:27:19 +0000 (13:27 +0000)]
[AArch64] NFC: Merge addTypeForStreamingSVE and addTypeForFixedLengthSVE

The two functions are basically identical, with a few minor exceptions.
They've been merged into a single function that distinguishes based on
a 'bool StreamingSVE' argument.

16 months ago[GlobalOpt] Add test where the initializer evaluation fails.
Florian Hahn [Fri, 10 Mar 2023 15:01:46 +0000 (16:01 +0100)]
[GlobalOpt] Add test where the initializer evaluation fails.

Test coverage for D145490.

16 months ago[gn build] Port 54178fc6161a
LLVM GN Syncbot [Fri, 10 Mar 2023 14:38:36 +0000 (14:38 +0000)]
[gn build] Port 54178fc6161a

16 months ago[AMDGPU] Make use of defvar in defining SMEM Real instructions
Jay Foad [Fri, 10 Mar 2023 14:31:24 +0000 (14:31 +0000)]
[AMDGPU] Make use of defvar in defining SMEM Real instructions

16 months ago[VPlan] Replace InvariantCond field from VPWidenSelectRecipe.
Florian Hahn [Fri, 10 Mar 2023 14:28:43 +0000 (15:28 +0100)]
[VPlan] Replace InvariantCond field from VPWidenSelectRecipe.

There is no need to store information about invariance in the recipe.
Replace the fields with checks of the operands using
isDefinedOutsideVectorRegions.

Reviewed By: Ayal

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

16 months ago[AArch64] Remove fixed FIXMEs from D120706. NFC
David Green [Fri, 10 Mar 2023 14:28:15 +0000 (14:28 +0000)]
[AArch64] Remove fixed FIXMEs from D120706. NFC

These comments were not adjusted when the fix went in.

16 months agoReserve unused bits in struct CXIndexOptions; NFC
Igor Kushnir [Fri, 10 Mar 2023 14:26:10 +0000 (09:26 -0500)]
Reserve unused bits in struct CXIndexOptions; NFC

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

16 months agoImprove documentation of CXIndexOptions; NFC
Igor Kushnir [Fri, 10 Mar 2023 14:21:33 +0000 (09:21 -0500)]
Improve documentation of CXIndexOptions; NFC

Document one more alternative way to initialize struct CXIndexOptions,
which is used in LibclangSetPreambleStoragePathTest since
df8f8f76207df40dca11c9c0c2328d6b3dfba9ca because the previous
initialization approach causes compiler warnings.

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

16 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 10 Mar 2023 14:14:44 +0000 (15:14 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

16 months ago[libc++] Clean up old macOS back-deployment workarounds
Louis Dionne [Tue, 28 Feb 2023 23:21:20 +0000 (18:21 -0500)]
[libc++] Clean up old macOS back-deployment workarounds

This patch bumps the minimum macOS version for building the dylib
or back-deploying a statically-linked libc++ from macOS 10.11 to
macOS 10.13. AFAICT, Chrome was the last one to require macOS 10.11,
but since then they have bumped their minimal supported version to
macOS 10.13.

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

16 months ago[clang-tidy] Finish cppcoreguidelines-avoid-capturing-lambda-coroutines check
Piotr Zegar [Fri, 10 Mar 2023 14:03:08 +0000 (14:03 +0000)]
[clang-tidy] Finish cppcoreguidelines-avoid-capturing-lambda-coroutines check

This commit implements check for CP.51 C++ Core Guidelines

Depends on D137514

Reviewed By: ChuanqiXu

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

16 months ago[clang-tidy] add check for capturing lambda coroutines
Noah Watkins [Fri, 10 Mar 2023 14:02:50 +0000 (14:02 +0000)]
[clang-tidy] add check for capturing lambda coroutines

Signed-off-by: Noah Watkins <noah@redpanda.com>
Reviewed By: ChuanqiXu

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

16 months ago[libc++] Remove _LIBCPP_CONSTEVAL
Louis Dionne [Thu, 9 Mar 2023 17:26:39 +0000 (12:26 -0500)]
[libc++] Remove _LIBCPP_CONSTEVAL

It was only used in one place, and it seems entirely valid to use
constexpr unconditionally in that location.

Note that a different change was attempted, i.e. using consteval
unconditionally. However, this led to http://llvm.org/PR60709.

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

16 months ago[clang-tidy] Change readability-magic-numbers to allow numbers in type aliases.
Florian Humblot [Fri, 10 Mar 2023 13:55:30 +0000 (13:55 +0000)]
[clang-tidy] Change readability-magic-numbers to allow numbers in type aliases.

This commit introduces an option to the readability-magic-values checker.
The option defaults to false so that the behavior of the checker doesn't change unless specifically enabled.
These commits are supposed to fix https://github.com/llvm/llvm-project/issues/61259

Reviewed By: PiotrZSL

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

16 months ago[clang-tidy] Fix readability-redundant-string-cstr for smart pointer #576705
Mike Crowe [Fri, 10 Mar 2023 13:47:25 +0000 (13:47 +0000)]
[clang-tidy] Fix readability-redundant-string-cstr for smart pointer #576705

Fix the readability-redundant-string-cstr check to correctly replace
calls to c_str() via an overloaded operator-> (such as from an
iterator.)

Previously, the fix for `i->c_str()` would be `*i->`. Using consume_back
to remove any trailing `->` results in the correct `*i`.

Add some lit check test cases too.

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

Reviewed By: PiotrZSL

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

16 months ago[AMDGPU][MachineVerifier] Fix vdata reg count for MIMG d16
Mirko Brkusanin [Fri, 10 Mar 2023 12:29:33 +0000 (13:29 +0100)]
[AMDGPU][MachineVerifier] Fix vdata reg count for MIMG d16

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

16 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 10 Mar 2023 10:36:14 +0000 (11:36 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

16 months agoRevert "[SLP]Initial support for reshuffling of non-starting buildvector/gather nodes."
Hans Wennborg [Fri, 10 Mar 2023 13:34:45 +0000 (14:34 +0100)]
Revert "[SLP]Initial support for reshuffling of non-starting buildvector/gather nodes."

This caused verifier errors:

  Instruction does not dominate all uses!
    %8 = insertelement <2 x i64> %7, i64 %pgocount1330, i64 1
    %15 = shufflevector <2 x i64> %8, <2 x i64> poison, <2 x i32> <i32 1, i32 1>
  in function ?NearestInclusiveAncestorAssignedToSlot@SlotScopedTraversal@blink@@SAPAVElement@2@ABV32@@Z

(or register allocator crash when the verifier was disabled).

See comment on the code review.

> Previously only the very first gather/buildvector node might be probed for reshuffling of other nodes.
> But the compiler may do the same for other gather/buildvector nodes too, just need to check the
> dependency and postpone the emission of the dependent nodes, if the origin nodes were not emitted yet.
>
> Part of D110978
>
> Differential Revision: https://reviews.llvm.org/D144958

This reverts commit a611b3f3059e4c3b9e7b914091c3edaef099fd5d.
It also reverts 7a4061ae372b3262703ffeea3b64db89187db611 which depended on the above.

16 months agoRevert "[Modules] Remove unnecessary check when generating name lookup table in ASTWr...
Krasimir Georgiev [Fri, 10 Mar 2023 13:08:36 +0000 (14:08 +0100)]
Revert "[Modules] Remove unnecessary check when generating name lookup table in ASTWriter"

This reverts commit db987b9589be1eb604fcb74c85b410469e31485f.

We're seeing failures in modules-enabled builds from within stdlib after
this commit. Errors look like:

In module '...stl_cc_library':
...optional:560:38: error: 'std::__optional_copy_assign_base<unsigned
long>::__optional_copy_assign_base' from module '...optional' is not
present in definition of 'std::__optional_copy_assign_base<unsigned
long>' in module '...optional'
    using __optional_move_base<_Tp>::__optional_move_base;

In module '...stl_cc_library':
...optional:771:11: error: no matching constructor for initialization of '__optional_move_assign_base<unsigned long>'
        : __base(in_place, _VSTD::forward<_Up>(__v)) {}
          ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/clang/include/clang/Basic/CodeGenOptions.h:448:57: note: in instantiation of function template specialization 'std::optional<unsigned long>::optional<int, 0>' requested here
  std::optional<uint64_t> DiagnosticsHotnessThreshold = 0;

I don't have a self-contained reproducer at this point. I'm hoping that
we may be able to share more information about these issues later, if
necessary.

16 months ago[AArch64] Fix N2 SchedModel for arithmetic and logic ops with cheap LSL
Ricardo Jesus [Fri, 24 Feb 2023 10:51:39 +0000 (10:51 +0000)]
[AArch64] Fix N2 SchedModel for arithmetic and logic ops with cheap LSL

According to the N2 Software Optimization Guide, arithmetic ops with LSL
≤ 4, no flagset logical ops, and flagset logical ops with LSL = 0 have a
latency of 1 and use pipeline group I. However, most of these ops were
being modelled as having a latency of 2 and using pipeline M. The
affected instructions include the "unshifted" versions of ADD/SUB, among
others.

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

16 months ago[libc++] Granularize <atomic> includes
Nikolas Klauser [Tue, 31 Jan 2023 18:23:30 +0000 (19:23 +0100)]
[libc++] Granularize <atomic> includes

Reviewed By: ldionne, Mordante, #libc

Spies: arichardson, libcxx-commits

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

16 months ago[lldb][test] TestInlineNamespaceAlias.py: skip on older compiler versions
Michael Buch [Fri, 10 Mar 2023 12:16:30 +0000 (12:16 +0000)]
[lldb][test] TestInlineNamespaceAlias.py: skip on older compiler versions

This was failing with versions of clang that didn't support the
dsymutil (D143458) and llvm (D143397) changes that are needed for this test.

Remove unused parameters that we tried passing for the `dwarf` variant, which
is an NFC change. LLDB doesn't yet support `-gdwarf-5` debugging yet so
passing it to the `Makefile` would actually cause the test to fail.

16 months ago[LICM] Support logical AND/OR when hoisting min/max
Max Kazantsev [Fri, 10 Mar 2023 10:43:10 +0000 (17:43 +0700)]
[LICM] Support logical AND/OR when hoisting min/max

We can handle logical AND/OR in the same way as arithmetic AND/OR, it only
takes us freezing `RHS2` for which we may introduce a new use which didn't
exist before dynamically.

Differential Revision: https://reviews.llvm.org/D145771
Reviewed By: nikic

16 months ago[clangd] UnusedIncludes: Strict config now uses the include-cleaner-library implement...
Haojian Wu [Fri, 10 Mar 2023 07:57:27 +0000 (08:57 +0100)]
[clangd] UnusedIncludes: Strict config now uses the include-cleaner-library implementation.

And remove the classical clangd-own unused-include implementation.

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

16 months ago[mlir][NFC] reifyResultShapes: Add extra error checking
Matthias Springer [Fri, 10 Mar 2023 10:25:15 +0000 (11:25 +0100)]
[mlir][NFC] reifyResultShapes: Add extra error checking

This change adds a new helper function `mlir::reifyResultShapes` that calls the corresponding interface method and also checks the result produced by the implementation when running in debug mode. Bugs due to incorrect interface implementations can be difficult to debug.

This helper function also reduces the amount of code needed at call sites: the cast to `ReifyRankedShapedTypeOpInterface` is done in the helper function.

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

16 months ago[mlir][tensor/linalg] Fix bug in reifyResultShapes
Matthias Springer [Fri, 10 Mar 2023 10:24:43 +0000 (11:24 +0100)]
[mlir][tensor/linalg] Fix bug in reifyResultShapes

`reifyResultShapes` should return an IntegerAttr if and only if the corresponding dimension is static.

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

16 months ago[LICM] Simplify (X < A && X < B) into (X < MIN(A, B)) if MIN(A, B) is loop-invariant
Max Kazantsev [Mon, 20 Feb 2023 10:24:49 +0000 (17:24 +0700)]
[LICM] Simplify (X < A && X < B) into (X < MIN(A, B)) if MIN(A, B) is loop-invariant

We don't do this transform in InstCombine in general case for arbitrary values, because cost of
AND and 2 ICMP's isn't higher than of MIN and ICMP. However, LICM also has a notion
about the loop structure. This transform becomes profitable if `A` and `B` are loop-invariant and
`X` is not: by doing this, we can compute min outside the loop.

Differential Revision: https://reviews.llvm.org/D143726
Reviewed By: nikic

16 months agoReland "[mlir] Enable opaque pointers in LLVM conversion passes by default"
Markus Böck [Fri, 10 Mar 2023 10:24:41 +0000 (11:24 +0100)]
Reland "[mlir] Enable opaque pointers in LLVM conversion passes by default"

This reverts commit cdd914a959528cd7abf36c096b4a0644c1721214.

16 months ago[Test] Rename some negative tests into positive with required freeze
Max Kazantsev [Fri, 10 Mar 2023 10:15:00 +0000 (17:15 +0700)]
[Test] Rename some negative tests into positive with required freeze

In fact, we can optimize this cases, it will just take us insertion of freeze.

16 months ago[mlir][GPUToLLVM] Fix regression introduced with opaque-pointers when generate GPU...
Markus Böck [Fri, 10 Mar 2023 09:49:16 +0000 (10:49 +0100)]
[mlir][GPUToLLVM] Fix regression introduced with opaque-pointers when generate GPU launch func parameters

This has caused build failures when enabling opaque pointers for the GPU integration tests as could be seen here:
https://lab.llvm.org/buildbot/#/builders/220/builds/16946 and here https://lab.llvm.org/buildbot/#/builders/61/builds/40822

The gist of the issue was the use of a wrong pointer base type within a GEP. There sadly was no test coverage for either the generating of that GEP, nor is LLVM Dialects GEP verifier currently capable of catching such issues, so it went unnoticed until the integration tests actually attempted to convert it to LLVM IR.

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

16 months ago[InstSimplify] Adjust context instruction when threading phi (PR61312)
Nikita Popov [Fri, 10 Mar 2023 09:34:27 +0000 (10:34 +0100)]
[InstSimplify] Adjust context instruction when threading phi (PR61312)

When threading operations over phis, we need to adjust the context
instruction to the terminator of the incoming block. This was
handled when threading icmps, but not when threading binops.

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

16 months ago[InstSimplify] Add test for PR61312 (NFC)
Nikita Popov [Fri, 10 Mar 2023 09:29:28 +0000 (10:29 +0100)]
[InstSimplify] Add test for PR61312 (NFC)

16 months ago[Clang][Sema] Start fixing handling of out-of-line definitions of constrained templates
Alexander Shaposhnikov [Fri, 10 Mar 2023 09:10:37 +0000 (09:10 +0000)]
[Clang][Sema] Start fixing handling of out-of-line definitions of constrained templates

This diff starts fixing our handling of out-of-line definitions of constrained templates.
Initially it was motivated by https://github.com/llvm/llvm-project/issues/49620 and
https://github.com/llvm/llvm-project/issues/60231.
In particular, this diff adjusts Sema::computeDeclContext to work properly in the case of
constrained template parameters.

Test plan:
1/ ninja check-all
2/ Bootstrapped Clang passes all the tests
3/ Internal testing

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

16 months ago[InstCombine] Add precommit tests for strong order compare patterns; NFC
chenglin.bi [Fri, 10 Mar 2023 08:58:05 +0000 (16:58 +0800)]
[InstCombine] Add precommit tests for strong order compare patterns; NFC

16 months ago[llvm][Uniformity] consistently handle always-uniform instructions
Sameer Sahasrabuddhe [Fri, 10 Mar 2023 07:14:20 +0000 (12:44 +0530)]
[llvm][Uniformity] consistently handle always-uniform instructions

An instruction that is "always uniform" is so even if it occurs in an
irreducible cycle. The output produced by such an instruction may depend on the
implementation defined cycle hierarchy, but that does not affect the uniformity
of the output. In other words, an "always uniform" instruction is uniform even
if it is not m-converged.

Reviewed By: ruiling, ronlieb

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

16 months ago[flang] Handle unlimited polymorphic with intrinsic dynamic type in extends_type_of
Valentin Clement [Fri, 10 Mar 2023 08:49:12 +0000 (09:49 +0100)]
[flang] Handle unlimited polymorphic with intrinsic dynamic type in extends_type_of

Unlimited polymorphic entities can have an intrinsic dynamic type. Update the
code of extends_type_of to compare the CFI_type in these case.

Reviewed By: PeteSteinfeld

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

16 months ago[Test] Add missing noundef in positive test
Max Kazantsev [Fri, 10 Mar 2023 08:33:27 +0000 (15:33 +0700)]
[Test] Add missing noundef in positive test

16 months ago[RISCV] Use binary search for RISCVLoadFPImm::getLoadFPImm.
Craig Topper [Fri, 10 Mar 2023 08:02:04 +0000 (00:02 -0800)]
[RISCV] Use binary search for RISCVLoadFPImm::getLoadFPImm.

The table is sorted so we can use a binary search instead of a
linear scan.

16 months agoRevert "[mlir] Enable opaque pointers in LLVM conversion passes by default"
Markus Böck [Fri, 10 Mar 2023 07:51:17 +0000 (08:51 +0100)]
Revert "[mlir] Enable opaque pointers in LLVM conversion passes by default"

This reverts commit 552522bef66c56dc4336d5948662f295dd733c0d.

There are test failures in integration tests for GPU builds

16 months ago[mlir] Enable opaque pointers in LLVM conversion passes by default
Markus Böck [Fri, 10 Mar 2023 07:33:21 +0000 (08:33 +0100)]
[mlir] Enable opaque pointers in LLVM conversion passes by default

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

When this patch lands any downstream users with custom LLVM conversion passes not yet using opaque pointers will start either experiencing assertions being triggered, null pointer dereferences or at the very least verifier errors. These can be either fixed by switching to opaque pointers or simply disabling opaque pointers in both pass options of any upstream conversion passes and any uses of `LLVMTypeConverter` via the `LowerToLLVMOptions`.

Users using just MLIRs conversion passes to the LLVM Dialect should not experience any change in functionality except when inspecting the output from the passes.

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

16 months ago[JITLink][docs] Update docs for generic link algorithm and memory manager apis.
Lang Hames [Fri, 10 Mar 2023 07:21:35 +0000 (23:21 -0800)]
[JITLink][docs] Update docs for generic link algorithm and memory manager apis.

These sections were out of date.

16 months agoRevert "[NFC] Don't recompute Linkage for Decl in Release Modes"
Chuanqi Xu [Fri, 10 Mar 2023 07:25:26 +0000 (15:25 +0800)]
Revert "[NFC] Don't recompute Linkage for Decl in Release Modes"

This reverts commit 87ba95aa212a4fd363a4dd52677e9eea5224a4e7.

16 months ago[NFC] Don't recompute Linkage for Decl in Release Modes
Chuanqi Xu [Fri, 10 Mar 2023 07:16:39 +0000 (15:16 +0800)]
[NFC] Don't recompute Linkage for Decl in Release Modes

In the assertion enabled mode we will test if the computed linkage of
Declaration is consistent with the cached linkage. But we shouldn't
compuate it if we have cached linkage in the release modes.

16 months ago[RISCV] Move some RISCVLoadFPImm out of line. NFC
Craig Topper [Fri, 10 Mar 2023 07:09:27 +0000 (23:09 -0800)]
[RISCV] Move some RISCVLoadFPImm out of line. NFC

This moves the LoadFPImmArr array to the cpp file. Being in the header
meant it was duplicated in every translation unit that includes the
header.

Move the 2 functions that use the array out of line.

16 months ago[FSAFDO] Improve FS discriminator encoding
Rong Xu [Fri, 10 Mar 2023 06:43:08 +0000 (22:43 -0800)]
[FSAFDO] Improve FS discriminator encoding

This change improves FS discriminators in the following ways:
(1) use call-stack debug information in the the to generate
discriminators: the same (src/line) DILs can now have same
discriminator value if they come from different call-stacks.
This effectively increases the usable discriminator values
for each round of FS discriminator pass.
(2) don't generate the FS discriminator for meta instructions
(i.e. instructions not emitted). This reduces the number
discriminators conflicts (for the case we run out of discriminator
bits for that pass).
(3) use less expensive hashing of xxHash64.

These improvements should bring better performance for FSAFDO
and they should be used by default. But this change creates
incompatible FS discriminators. For the iterative profile users,
they might see a performance drop in the first release with
this change (due to the fact that the profiles have the old
discriminators and the compiler uses the new discriminator).
We have measured that this is not more than 1.5% on several
benchmarks. Note the degradation should be gone in the second
release and one should expect a performance gain over the binary
without this change.

One possible solution to the iterative profile issue would be
separating discriminators for profile-use and the ones emitted to
the binary. This would require a mechanism to allow two sets of
discriminators to be maintained and then phasing out the first
approach. This is too much churn in the compiler and the
performance implications do not seem to be worth the effort.

Instead, we put the changes under an option so iterative profile
users can do a gradual rollout of this change. We will make the
option default value to true in a later patch and eventually
purge this option from the code base.

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