platform/upstream/llvm.git
23 months ago[AMDGPU][MC][GFX90A] Correct MIMG dst size validation
Dmitry Preobrazhensky [Thu, 28 Jul 2022 11:27:13 +0000 (14:27 +0300)]
[AMDGPU][MC][GFX90A] Correct MIMG dst size validation

Correct validator to enable MIMG dst size checks.

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

23 months ago[mlir] Add getters for DenseArrayAttr.
Adrian Kuegel [Thu, 28 Jul 2022 10:50:40 +0000 (12:50 +0200)]
[mlir] Add getters for DenseArrayAttr.

This change adds convenience getters to builders.

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

23 months ago[InstCombine] try harder to narrow bitwise logic with cast operands
Sanjay Patel [Wed, 27 Jul 2022 21:40:35 +0000 (17:40 -0400)]
[InstCombine] try harder to narrow bitwise logic with cast operands

This works with any logic + extend:
https://alive2.llvm.org/ce/z/vzsqQD

The motivating case is from issue #56294, but that's still not optimal
(it should simplify completely).

23 months ago[InstCombine] add tests for bitwise logic with cast operands; NFC
Sanjay Patel [Wed, 27 Jul 2022 21:26:26 +0000 (17:26 -0400)]
[InstCombine] add tests for bitwise logic with cast operands; NFC

23 months ago[AMDGPU][MC][GFX11] Disable SGPRs for src1 of v_fma_mix*_dpp opcodes
Dmitry Preobrazhensky [Thu, 28 Jul 2022 11:20:05 +0000 (14:20 +0300)]
[AMDGPU][MC][GFX11] Disable SGPRs for src1 of v_fma_mix*_dpp opcodes

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

23 months ago[gn build] (manually) port 18b4a8bcf35 more
Nico Weber [Thu, 28 Jul 2022 11:14:43 +0000 (07:14 -0400)]
[gn build] (manually) port 18b4a8bcf35 more

23 months ago[Aarch64] Add cost for missing extensions.
chendewen [Thu, 28 Jul 2022 09:15:25 +0000 (17:15 +0800)]
[Aarch64] Add cost for missing extensions.

This patch adds a cost estimate for some missing sign extensions.
ref: https://reviews.llvm.org/D14730

Reviewed By: dmgreen

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

23 months ago[libc][math] Universal exp function for cosh/sinh calculation.
Kirill Okhotnikov [Wed, 6 Jul 2022 16:11:40 +0000 (18:11 +0200)]
[libc][math] Universal exp function for cosh/sinh calculation.

Added a function and test, which can be used later for cosh/sinh
and possibly for expf/expm1f.

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

23 months ago[libc++] Make `_IterOps::__iter_move` more similar to `std::ranges::iter_move`.
Konstantin Varlamov [Thu, 28 Jul 2022 09:06:44 +0000 (02:06 -0700)]
[libc++] Make `_IterOps::__iter_move` more similar to `std::ranges::iter_move`.

Avoid relying on `iterator_traits` and instead deduce the return type of
dereferencing the iterator. Additionally, add a static check to reject
iterators with incorrect `iterator_traits` at compile time.

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

23 months ago[SCEV] Avoid repeated proveNoUnsignedWrapViaInduction calls.
Florian Hahn [Thu, 28 Jul 2022 09:02:19 +0000 (10:02 +0100)]
[SCEV] Avoid repeated proveNoUnsignedWrapViaInduction calls.

At the moment, proveNoUnsignedWrapViaInduction may be called for the
same AddRec a large number of times via getZeroExtendExpr. This can have
a severe compile-time impact for very loop-heavy code. One one
particular workload, LSR takes ~51s without this patch, almost
exlusively in proveNoUnsignedWrapViaInduction. With this patch, the time
in LSR drops to ~0.4s.

If proveNoUnsignedWrapViaInduction failed to prove NUW the first time,
it is unlikely to succeed on subsequent tries and the cost doesn't seem
to be justified.

Besides drastically improving compile-time in some excessive cases, this
also has a slightly positive compile-time impact on CTMark:

NewPM-O3: -0.07%
NewPM-ReleaseThinLTO: -0.08%
NewPM-ReleaseLTO-g: -0.06

https://llvm-compile-time-tracker.com/compare.php?from=b435da027d7774c24cdb8c88d09f6b771e07fb14&to=f2729e33e8284b502f6c35a43345272252f35d12&stat=instructions

Reviewed By: nikic

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

23 months ago[pseudo] Eliminate the false `::` nested-name-specifier ambiguity
Haojian Wu [Tue, 26 Jul 2022 20:27:09 +0000 (22:27 +0200)]
[pseudo] Eliminate the false `::` nested-name-specifier ambiguity

The solution is to favor the longest possible nest-name-specifier, and
drop other alternatives by using the guard, per per C++ [basic.lookup.qual.general].

Motivated cases:

```
Foo::Foo() {};
// the constructor can be parsed as:
//  - Foo ::Foo(); // where the first Foo is return-type, and ::Foo is the function declarator
//  + Foo::Foo(); // where Foo::Foo is the function declarator
```

```
void test() {

// a very slow parsing case when there are many qualifers!
X::Y::Z;
// The statement can be parsed as:
//  - X ::Y::Z; // ::Y::Z is the declarator
//  - X::Y ::Z; // ::Z is the declarator
//  + X::Y::Z;  // a declaration without declarator (X::Y::Z is decl-specifier-seq)
//  + X::Y::Z;  // a qualifed-id expression
}
```

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

23 months ago[clang-tidy] Add CLANG_TIDY_CONFUSABLE_CHARS_GEN cmake cache variable to avoid buildi...
Martin Storsjö [Thu, 14 Jul 2022 19:46:04 +0000 (22:46 +0300)]
[clang-tidy] Add CLANG_TIDY_CONFUSABLE_CHARS_GEN cmake cache variable to avoid building when cross compiling

This is similar to the LLVM_TABLEGEN, CLANG_TABLEGEN and
CLANG_PSEUDO_GEN cmake cache variables.

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

23 months ago[clang-tidy] Rename the make-confusable-table executable
Martin Storsjö [Thu, 14 Jul 2022 19:39:55 +0000 (22:39 +0300)]
[clang-tidy] Rename the make-confusable-table executable

Rename it to clang-tidy-confusable-chars-gen, to make its role
clearer in a wider context.

In cross builds, the caller might want to provide this tool
externally (to avoid needing to rebuild it in the cross build).
In such a case, having the tool properly namespaced makes its role
clearer.

This matches how the clang-pseudo-gen tool was renamed in
a43fef05d4fae32f02365c7b8fef2aa631d23628 / D126725.

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

23 months ago[mlir] Small stylistic changes to Complex_NumberAttr
Alexander Belyaev [Wed, 27 Jul 2022 13:26:01 +0000 (15:26 +0200)]
[mlir] Small stylistic changes to Complex_NumberAttr

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

23 months ago[libc][math] Improved performance of exp2f function.
Kirill Okhotnikov [Fri, 1 Jul 2022 12:42:22 +0000 (14:42 +0200)]
[libc][math] Improved performance of exp2f function.

New exp2 function algorithm:
1) Improved performance: 8.176 vs 15.270 by core-math perf tool.
2) Improved accuracy. Only two special values left.
3) Lookup table size reduced twice.

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

23 months ago[llvm] Fix some test failures with EXPENSIVE_CHECKS and libstdc++
David Spickett [Wed, 20 Jul 2022 09:37:24 +0000 (09:37 +0000)]
[llvm] Fix some test failures with EXPENSIVE_CHECKS and libstdc++

DebugLocEntry assumes that it either contains 1 item that has no fragment
or many items that all have fragments (see the assert in addValues).

When EXPENSIVE_CHECKS is enabled, _GLIBCXX_DEBUG is defined. On a few machines
I've checked, this causes std::sort to call the comparator even
if there is only 1 item to sort. Perhaps to check that it is implemented
properly ordering wise, I didn't find out exactly why.

operator< for a DbgValueLoc will crash if this happens because the
optional Fragment is empty.

Compiler/linker/optimisation level seems to make this happen
or not. So I've seen this happen on x86 Ubuntu but the buildbot
for release EXPENSIVE_CHECKS did not have this issue.

Add an explicit check whether we have 1 item.

Reviewed By: aprantl

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

23 months ago[lld-macho] Add LOH_ARM64_ADRP_ADD_LDR optimization hint support
Daniel Bertalan [Mon, 25 Jul 2022 18:05:40 +0000 (20:05 +0200)]
[lld-macho] Add LOH_ARM64_ADRP_ADD_LDR optimization hint support

This hint instructs the linker to optimize an adrp+add+ldr sequence used
for loading from a local symbol's address by loading directly if it's
close enough, or with an adrp(p)+ldr sequence if it's not.

This transformation is the same as what's done for ADRP_LDR_GOT_LDR when
the symbol is local. The logic for acting on this hint is therefore
moved to a new function which will be called from the existing
applyAdrpLdrGotLdr() function.

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

23 months ago[mlir][transform] Support results on ForeachOp
Matthias Springer [Wed, 27 Jul 2022 15:58:24 +0000 (17:58 +0200)]
[mlir][transform] Support results on ForeachOp

Handles can be yielded from the ForeachOp.

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

23 months ago[libc++] Fix merge-conflict in .clang-format
Nikolas Klauser [Thu, 28 Jul 2022 08:32:02 +0000 (10:32 +0200)]
[libc++] Fix merge-conflict in .clang-format

23 months ago[gn build] Port e01b4fe956dd
LLVM GN Syncbot [Thu, 28 Jul 2022 08:23:10 +0000 (08:23 +0000)]
[gn build] Port e01b4fe956dd

23 months ago[libc++] Fix unwrapping ranges with different iterators and sentinels
Nikolas Klauser [Wed, 27 Jul 2022 21:52:45 +0000 (23:52 +0200)]
[libc++] Fix unwrapping ranges with different iterators and sentinels

Reviewed By: ldionne, huixie90, #libc

Spies: arichardson, sstefan1, libcxx-commits, mgorny

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

23 months ago[lld-macho] Support creating N_SO stab for DWARF5 compile units
Daniel Bertalan [Tue, 26 Jul 2022 10:06:39 +0000 (12:06 +0200)]
[lld-macho] Support creating N_SO stab for DWARF5 compile units

In DWARF5, the `DW_AT_name` and `DW_AT_comp_dir` attributes are encoded
using the `strx*` forms, which specify an index into `__debug_str_offs`.
This commit adds that section to DwarfObject, so the debug info parser
can resolve these references.

The test case was manually adapted from stabs-icf.s.

Fixes #51668

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

23 months ago[gn build] Port 8a61749f767e
LLVM GN Syncbot [Thu, 28 Jul 2022 07:43:55 +0000 (07:43 +0000)]
[gn build] Port 8a61749f767e

23 months ago[mlir][tensor] Fold `tensor.cast` into `tensor.collapse_shape` op
Gaurav Shukla [Thu, 28 Jul 2022 07:41:05 +0000 (13:11 +0530)]
[mlir][tensor] Fold `tensor.cast` into `tensor.collapse_shape` op

This commit folds a `tensor.cast` op into a `tensor.collapse_shape` op
when following two conditions meet:
1. the `tensor.collapse_shape` op consumes result of the `tensor.cast` op.
2. `tensor.cast` op casts to a more dynamic version of the source tensor.
This is added as a canonicalization pattern in `tensor.collapse_shape` op.

Signed-Off-By: Gaurav Shukla <gaurav@nod-labs.com>
Reviewed By: mravishankar

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

23 months ago[libc++][ranges] implement `std::ranges::inplace_merge`
Hui Xie [Wed, 27 Jul 2022 12:20:16 +0000 (13:20 +0100)]
[libc++][ranges] implement `std::ranges::inplace_merge`

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

23 months ago[Driver][PowerPC] Support -mtune=
Fangrui Song [Thu, 28 Jul 2022 07:34:04 +0000 (00:34 -0700)]
[Driver][PowerPC] Support -mtune=

Reviewed By: #powerpc, nemanjai

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

23 months ago[Test] Fix block name in test
Max Kazantsev [Thu, 28 Jul 2022 06:42:14 +0000 (13:42 +0700)]
[Test] Fix block name in test

23 months ago[LAA] Remove block order sensitivity in LAA algorithm. PR56672
Max Kazantsev [Thu, 28 Jul 2022 06:27:19 +0000 (13:27 +0700)]
[LAA] Remove block order sensitivity in LAA algorithm. PR56672

As test in PR56672 shows, LAA produces different results which lead to either
positive or negative vectorization decisions depending on the order of blocks
in loop. The exact reason of this is not clear to me, however this makes investigation
of related bugs extremely complex.

Current order of blocks in the loop is arbitrary. It may change, for example, if loop
info analysis is dropped and recomputed. Seems that it interferes with LAA's logic.
This patch chooses fixed traversal order of blocks in loops, making it RPOT.

Note: this is *not* a fix for bug with incorrect analysis result. It just makes
the answer more robust to make the investigation easier.

Differential Revision: https://reviews.llvm.org/D130482
Reviewed By: aeubanks, fhahn

23 months agoworkflows: Use macos-11 runners
Tom Stellard [Wed, 27 Jul 2022 22:23:24 +0000 (15:23 -0700)]
workflows: Use macos-11 runners

macos-10.15 is deprecated and will be removed.

23 months ago[MLIR] Fix bazel build after 7356404ace4bdb09e8a81eb2d10e0f5e7a9ab3c0.
Christian Sigg [Thu, 28 Jul 2022 06:14:18 +0000 (08:14 +0200)]
[MLIR] Fix bazel build after 7356404ace4bdb09e8a81eb2d10e0f5e7a9ab3c0.

23 months ago[ASTWriter] Replace `const std::string &OutputFile` with `StringRef OutputFile` in...
Argyrios Kyrtzidis [Thu, 28 Jul 2022 06:00:56 +0000 (23:00 -0700)]
[ASTWriter] Replace `const std::string &OutputFile` with `StringRef OutputFile` in some of `ASTWriter` functions, NFC

This is to make it consistent with LLVM's string parameter passing convention.

23 months ago[X86][MC] Avoid emitting incorrect warning for complex FMUL
Phoebe Wang [Thu, 28 Jul 2022 05:40:32 +0000 (13:40 +0800)]
[X86][MC] Avoid emitting incorrect warning for complex FMUL

We will insert a new operand which is identical to the Dest for complex
FMUL with a mask. https://godbolt.org/z/eTEdnYv3q

Complex FMA and FMUL with maskz don't have this problem.

Reviewed By: LuoYuanke, skan

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

23 months ago[AMDGPU] Aggressively schedule to reduce RP in occupancy limited regions
Austin Kerbow [Wed, 20 Jul 2022 05:55:42 +0000 (22:55 -0700)]
[AMDGPU] Aggressively schedule to reduce RP in occupancy limited regions

By not clustering loads and adjusting heuristics to more aggressively reduce
register pressure we may be able to increase occupancy for the function if it
was dropped in a first pass scheduling.

Similarly, try to reduce spilling if register usage exceeds lower bound
occupancy.

Reviewed By: rampitec

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

23 months ago[AArch64][GlobalISel] Fix custom legalization of rotates using sext for shift vs...
Amara Emerson [Thu, 28 Jul 2022 05:10:42 +0000 (22:10 -0700)]
[AArch64][GlobalISel] Fix custom legalization of rotates using sext for shift vs zext.

Rotates are defined according to DAG documentation as having unsigned shifts,
so we need to zero-extend instead of sign-extend here.

Fixes issue 56664

23 months agoGlobalISel: update legalize-rotr-rotl.mir checks before change.
Amara Emerson [Thu, 28 Jul 2022 05:09:31 +0000 (22:09 -0700)]
GlobalISel: update legalize-rotr-rotl.mir checks before change.

23 months ago[clang-format] Fix the return code of git-clang-format
Sridhar Gopinath [Thu, 28 Jul 2022 04:00:37 +0000 (21:00 -0700)]
[clang-format] Fix the return code of git-clang-format

In diff and diffstat modes, the return code is != 0 even when there are no
changes between commits. This issue can be fixed by passing --exit-code to
git-diff command that returns 0 when there are no changes and using that as
the return code for git-clang-format.

Fixes #56736.

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

23 months agoUse pseudoparser-based folding ranges in ClangdServer.
Utkarsh Saxena [Mon, 18 Jul 2022 14:23:28 +0000 (16:23 +0200)]
Use pseudoparser-based folding ranges in ClangdServer.

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

23 months ago[NFC] [C++20] [Modules] Add tests for merging redefinitions in modules
Chuanqi Xu [Thu, 28 Jul 2022 03:13:00 +0000 (11:13 +0800)]
[NFC] [C++20] [Modules] Add tests for merging redefinitions in modules

Add tests for detecting redefinitions in C++20 modules. Some of these
may be covered by other tests. But more tests should be always good.

23 months agoworkflows: Use correct access token when pushing to llvm-project-release-prs repo
Tom Stellard [Thu, 28 Jul 2022 03:13:21 +0000 (20:13 -0700)]
workflows: Use correct access token when pushing to llvm-project-release-prs repo

The checkout action will hard-code the default github actions token in
the git config so that all pushes use it.  We need to set
persist-credentials=false so we can use a token that has permission
to push to the llvm-project-release-prs repo.

23 months ago[AMDGPU][SIFoldOperands] Clear kills when folding COPY
Carl Ritson [Thu, 28 Jul 2022 02:43:46 +0000 (11:43 +0900)]
[AMDGPU][SIFoldOperands] Clear kills when folding COPY

Clear all kill flags on source register when folding a COPY.
This is necessary because the kills may now be out of order with the uses.

Reviewed By: foad

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

23 months ago[Docs] Fix column ordering on clang attribute docs
Chris Bieneman [Thu, 28 Jul 2022 02:36:43 +0000 (21:36 -0500)]
[Docs] Fix column ordering on clang attribute docs

This patch just adjusts the ordering of the headings on the attribute
docs to match the order of the column content.

23 months ago[mlir] Delete most of the ops from the quant dialect.
Stella Laurenzo [Wed, 27 Jul 2022 23:59:56 +0000 (16:59 -0700)]
[mlir] Delete most of the ops from the quant dialect.

* https://discourse.llvm.org/t/rfc-removing-the-quant-dialect/3643/8
* Removes most ops. Leaves casts given final comment (can remove more in a followup).
* There are a few uses in Tosa keeping some of the utilities alive. In a followup, I will probably elect to just move simplified versions of them into Tosa itself vs having this quasi-library dependency.

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

23 months agoDebugInfo: Test vtable homing overriding ctor homing only on itanium since msvc ABI...
David Blaikie [Thu, 28 Jul 2022 00:44:12 +0000 (00:44 +0000)]
DebugInfo: Test vtable homing overriding ctor homing only on itanium since msvc ABI doesn't home vtables

23 months ago[RISCV] Reorder (and/or/xor (shl X, C1), C2) if we can form ANDI/ORI/XORI.
Craig Topper [Thu, 28 Jul 2022 00:35:26 +0000 (17:35 -0700)]
[RISCV] Reorder (and/or/xor (shl X, C1), C2) if we can form ANDI/ORI/XORI.

InstCombine and DAGCombine prefer to keep shl before binops.

This patch teaches isel to convert to (shl (and/or/xor X, C1 >> C2), C2)
if (C1 >> C2) is a simm12. The idea was taken from X86's isel code.

There's a special case implemented for a sext_inreg between the
shift and the binop.

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

23 months ago[RISCV] Pre-commit tests for D130610. NFC
Craig Topper [Thu, 28 Jul 2022 00:35:17 +0000 (17:35 -0700)]
[RISCV] Pre-commit tests for D130610. NFC

23 months ago[RISCV] Reorder code in lowerFROUND to make the diff in D130659 cleaner. NFC
Craig Topper [Wed, 27 Jul 2022 23:43:06 +0000 (16:43 -0700)]
[RISCV] Reorder code in lowerFROUND to make the diff in D130659 cleaner. NFC

23 months agoDebugInfo: Prefer vtable homing over ctor homing.
David Blaikie [Thu, 28 Jul 2022 00:07:35 +0000 (00:07 +0000)]
DebugInfo: Prefer vtable homing over ctor homing.

Vtables will be emitted in fewer places than ctors (every ctor
references the vtable, so at worst it's the same places - but at best
the type has a non-inline key function and the vtable is emitted in one
place)

Pulling this fix out of 517bbc64dbe493644eff8d55fd9566435e930520 which
was reverted in 4821508d4db75a535d02b8938f81fac6de66cc26

23 months ago[NFC] Automatically generate CodeGen/VE/Scalar/atomic.ll
Amaury Séchet [Wed, 27 Jul 2022 23:52:00 +0000 (23:52 +0000)]
[NFC] Automatically generate CodeGen/VE/Scalar/atomic.ll

23 months ago[mlir][spirv] Unify resources of different vector sizes
Lei Zhang [Wed, 27 Jul 2022 23:22:38 +0000 (19:22 -0400)]
[mlir][spirv] Unify resources of different vector sizes

This commit extends UnifyAliasedResourcePass to handle the case
where aliased resources have different vector sizes. (It still
requires all scalar types to be of the same bitwidth.) This is
effectively reusing the code for handling different-bitwidth
scalar types.

Reviewed By: ThomasRaoux

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

23 months ago[mlir][spirv] Fix spv.CompositeConstruct assembly and validation
Lei Zhang [Wed, 27 Jul 2022 23:16:56 +0000 (19:16 -0400)]
[mlir][spirv] Fix spv.CompositeConstruct assembly and validation

This commit fixes spv.CompositeConstruct to assembly to list
operand types to enable vector construction out of smaller vectors.
Validation is also fixed to properly check the cases for vector
construction.

Reviewed By: ThomasRaoux

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

23 months agoRegAllocGreedy: Fix nondeterminism in tryLastChanceRecoloring
Matt Arsenault [Wed, 27 Jul 2022 13:26:41 +0000 (09:26 -0400)]
RegAllocGreedy: Fix nondeterminism in tryLastChanceRecoloring

tryLastChanceRecoloring iterates over the set of LiveInterval pointers
and used that to seed the recoloring stack, which was
nondeterministic. Fixes a future test failing about 20% of the time.

This just takes the order the interfering vreg was encountered. Not
sure if we should try to order this more intelligently.

23 months agoRevert "[Clang] Diagnose ill-formed constant expression when setting a non fixed...
Shafik Yaghmour [Wed, 27 Jul 2022 22:31:41 +0000 (15:31 -0700)]
Revert "[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values"

This reverts commit a3710589f285de0bb22ff92b1fc24df9411e986f.

23 months ago[lldb] Read from the Rosetta shared cache with Xcode 14
Jonas Devlieghere [Wed, 27 Jul 2022 21:30:39 +0000 (14:30 -0700)]
[lldb] Read from the Rosetta shared cache with Xcode 14

Xcode 14 no longer puts the Rosetta expanded shared cache in a directory
named "16.0". Instead, it includes the real version number (e.g. 13.0),
the build string and the architecture, similar to the device support
directory names for iOS, tvOS and watchOS.

Currently, when there are multiple directories, we might end up picking
the wrong one in GetSDKDirectoryForCurrentOSVersion. The problem is that
without the build string we have no way to differentiate between
multiple directories with the same version number. This patch fixes the
problem by using GetOSBuildString which, as the name implies, returns
the build string if known.

This also adds a test for Rosetta debugging on Apple Silicon. Depending
on whether the Rosetta expanded shared cache is present, the test
ensures that there is or isn't a diagnostic about reading out of memory.

rdar://97576121

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

23 months ago[RISCV] Add merge operand to RISCVISD::FCOPYSIGN_VL.
Craig Topper [Wed, 27 Jul 2022 21:14:40 +0000 (14:14 -0700)]
[RISCV] Add merge operand to RISCVISD::FCOPYSIGN_VL.

Similar to what was done for VRGATHER*_VL recently.

This will be used in D130659.

23 months agoCall WatchpointList::RemoveAll in Target::Destroy.
Jim Ingham [Wed, 27 Jul 2022 22:09:05 +0000 (15:09 -0700)]
Call WatchpointList::RemoveAll in Target::Destroy.

I noticed that the test TestSetWatchpoint.py was failing every so often
on macOS.  The failure was in the last assert, that after destroying the
SBTarget containing it, the SBWatchpoint was still saying it was valid.

IsValid in this case just meant the watchpoint weak pointer could be turned
into a shared pointer.  The watchpoint shared pointers have two strong references
in general, one to the "Target::m_last_created_watchpoint", and one in the
Target::m_watchpoint_list.  Target::Destroy reset the last created watchpoint
but neglected to call RemoveAll on the watchpoint list (it does the analogous
work for the internal & external breakpoint lists...)  This patch does the
equivalent cleanup for the watchpoint list.

23 months ago[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to...
Shafik Yaghmour [Wed, 27 Jul 2022 21:59:35 +0000 (14:59 -0700)]
[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

DR2338 clarified that it was undefined behavior to set the value outside the
range of the enumerations values for an enum without a fixed underlying type.

We should diagnose this with a constant expression context.

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

23 months ago[gn build] Port 6047deb7c2aa
LLVM GN Syncbot [Wed, 27 Jul 2022 21:44:47 +0000 (21:44 +0000)]
[gn build] Port 6047deb7c2aa

23 months ago[mlir][sparse] Add arith-expand pass to the sparse-compiler pipeline.
bixia1 [Wed, 27 Jul 2022 19:32:47 +0000 (12:32 -0700)]
[mlir][sparse] Add arith-expand pass to the sparse-compiler pipeline.

Modify an existing test to test the situation.

Reviewed By: Peiming

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

23 months agoRevert "[llvm][NFC] Refactor code to use ProfDataUtils"
Paul Kirth [Wed, 27 Jul 2022 21:38:11 +0000 (21:38 +0000)]
Revert "[llvm][NFC] Refactor code to use ProfDataUtils"

This reverts commit 300c9a78819b4608b96bb26f9320bea6b8a0c4d0.

We will reland once these issues are ironed out.

23 months ago[llvm][NFC] Refactor code to use ProfDataUtils
Paul Kirth [Wed, 29 Jun 2022 21:31:17 +0000 (21:31 +0000)]
[llvm][NFC] Refactor code to use ProfDataUtils

In this patch we replace common code patterns with the use of utility
functions for dealing with profiling metadata. There should be no change
in functionality, as the existing checks should be preserved in all
cases.

Reviewed By: bogner, davidxl

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

23 months ago[llvm] Provide utility function for MD_prof
Paul Kirth [Tue, 19 Jul 2022 22:56:45 +0000 (22:56 +0000)]
[llvm] Provide utility function for MD_prof

Currently, there is significant code duplication for dealing with
MD_prof metadata throughout the compiler. These utility functions can
improve code reuse and simplify boilerplate code when dealing with
profiling metadata, such as branch weights. The inent is to provide a
uniform set of APIs that allow common tasks, such as identifying
specific types of MD_prof metadata and extracting branch weights.

Future patches can build on this initial implementation and clean up the
different implementations across the compiler.

Reviewed By: bogner

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

23 months ago[GlobalISel] Handle IntToPtr constants in dbg.value
Adrian Prantl [Wed, 27 Jul 2022 20:39:16 +0000 (13:39 -0700)]
[GlobalISel] Handle IntToPtr constants in dbg.value

Currently, the IR to MIR translator can only handle two kinds of constant
inputs to dbg.values intrinsics: constant integers and constant floats. In
particular, it cannot handle pointers created from IntToPtr ConstantExpression
objects.

This patch addresses the limitation above by replacing the IntToPtr with
its input integer prior to converting the dbg.value input.

Patch by Felipe Piovezan!

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

23 months ago[lldb][NFC] Pass ParsedDWARFTypeAttributes as const reference into ParseArrayType()
Arthur Eubanks [Mon, 25 Jul 2022 17:58:18 +0000 (10:58 -0700)]
[lldb][NFC] Pass ParsedDWARFTypeAttributes as const reference into ParseArrayType()

Fixes a FIXME

Reviewed By: zequanwu

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

23 months agoworkflows: Fix version check for X.0.0 releases
Tom Stellard [Wed, 27 Jul 2022 19:31:40 +0000 (12:31 -0700)]
workflows: Fix version check for X.0.0 releases

23 months ago[LLDB][NFC] Fix possible resource leak
Slava Gurevich [Wed, 27 Jul 2022 17:30:27 +0000 (10:30 -0700)]
[LLDB][NFC] Fix possible resource leak

SymbolVendorPECOFF object is leaked on early return at line 110

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

23 months agoworkflows: Fix pull request creation for backports
Tom Stellard [Wed, 27 Jul 2022 20:09:20 +0000 (20:09 +0000)]
workflows: Fix pull request creation for backports

This was broken by 17d4796cc84618e9b15f9484e5576127c431bc60.

23 months ago[LinkerWrapper] Do not consume `--verbose` from the linker
Joseph Huber [Wed, 27 Jul 2022 20:05:37 +0000 (16:05 -0400)]
[LinkerWrapper] Do not consume `--verbose` from the linker

Summary:
Linkers use `--verbose` to let users investigate search libraries among
other things. The linker wrapper was incorrectly not forwarding this to
the linker job. This patch simply renames this so users can still see
verbose messages from the linker if it was passed.

23 months ago[Flang][Driver] Add support for AsmPrinter -mmlir options
Prabhdeep Singh Soni [Wed, 27 Jul 2022 20:09:24 +0000 (16:09 -0400)]
[Flang][Driver] Add support for AsmPrinter -mmlir options

This patch adds support for AsmPrinter  `-mmlir` options to the Flang driver.

Reviewed By: awarzynski

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

23 months ago[libc++][chrono] Uses operator<=> in the calendar.
Mark de Wever [Wed, 13 Jul 2022 05:59:46 +0000 (07:59 +0200)]
[libc++][chrono] Uses operator<=> in the calendar.

Since the calendar is added in C++20 the existing operators are removed.

Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: #libc, ldionne

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

23 months ago[cross-project-tests] Add split-file as dependency
Arthur Eubanks [Wed, 27 Jul 2022 19:23:20 +0000 (12:23 -0700)]
[cross-project-tests] Add split-file as dependency

simplified_template_names_noncanonical_type_units.cpp uses split-file.

Reviewed By: dblaikie

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

23 months ago[RISCV] Enable (scalable) vectorization by default
Philip Reames [Wed, 27 Jul 2022 18:48:38 +0000 (11:48 -0700)]
[RISCV] Enable (scalable) vectorization by default

This change enables vectorization (using scalable vectorization only, fixed vectors are not yet enabled) for RISCV when vector instructions are available for the target configuration.

At this point, the resulting configuration should be both stable (e.g. no crashes), and profitable (i.e. few cases where scalar loops beat vector ones), but is not going to be particularly well tuned (i.e. we emit the best possible vector loop). The goal of this change is to align testing across organizations and ensure the default configuration matches what downstreams are using as closely as possible.

This exposes a large amount of code which hasn't otherwise been on by default, and thus may not have been fully exercised.  Given that, having issues fall out is not unexpected.  If you find issues, please make sure to include as much information as you can when reverting this change.

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

23 months ago[clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas
Denis Fatkulin [Wed, 27 Jul 2022 19:19:08 +0000 (22:19 +0300)]
[clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas

Lambdas with trailing return type 'auto' are annotated incorrectly. It causes a misformatting. The simpliest code to reproduce is:

```
auto list = {[]() -> auto { return 0; }};
```

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

Reviewed By: HazardyKnusperkeks, owenpan, curdeius

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

23 months ago[gn build] Port 0f3f357e26cf
LLVM GN Syncbot [Wed, 27 Jul 2022 19:04:03 +0000 (19:04 +0000)]
[gn build] Port 0f3f357e26cf

23 months ago[clang-offload-bundler] Library-ize ClangOffloadBundler
Jacob Lambert [Fri, 15 Jul 2022 00:00:26 +0000 (17:00 -0700)]
[clang-offload-bundler] Library-ize ClangOffloadBundler

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API. This will allow online and JIT compilers to
bundle and unbundle files without spawning a new process.

This patch lifts the classes and functions used to implement
the clang-offload-bundler into a separate OffloadBundler.cpp,
and defines three top-level API functions in OfflaodBundler.h.
        BundleFiles()
        UnbundleFiles()
        UnbundleArchives()

This patch also introduces a Config class that locally stores the
previously global cl::opt options and arrays to allow users to call
the APIs in a multi-threaded context, and introduces an
OffloadBundler class to encapsulate the top-level API functions.

We also  lift the BundlerExecutable variable, which is specific
to the clang-offload-bundler tool, from the API, and replace
its use with an ObjcopyPath variable. This variable must be set
in order to internally call llvm-objcopy.

Finally, we move the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.

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

23 months ago[AMDGPU] Consider S_SETPRIO a scheduling boundary
Stanislav Mekhanoshin [Wed, 27 Jul 2022 18:13:17 +0000 (11:13 -0700)]
[AMDGPU] Consider S_SETPRIO a scheduling boundary

The instruction is used to modify wave priority with the intent
to affect VALU execution and currently we can reschedule VALU
around it since that VALU does not have side effects.

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

23 months ago[mlir][OpenMP] Add omp.atomic.update canonicalization
Shraiysh Vaishay [Wed, 27 Jul 2022 18:41:21 +0000 (00:11 +0530)]
[mlir][OpenMP] Add omp.atomic.update canonicalization

This patch adds canonicalization conditions for omp.atomic.update thus
eliminating it when it becomes just a write or a no-op due to other
changes during canonicalization.

Reviewed By: ftynse

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

23 months ago[DebugInfo] Teach LLVM and LLDB about ptrauth in DWARF
Jonas Devlieghere [Wed, 27 Jul 2022 17:44:15 +0000 (10:44 -0700)]
[DebugInfo] Teach LLVM and LLDB about ptrauth in DWARF

Teach libDebugInfo (llvm-dwarfdump) and lldb about DWARF tags and
attributes for pointer authentication. These values have been emitted by
Apple clang for several releases. Although upstream LLVM doesn't emit
these values yet, we hope to upstream that part sometime soon.

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

23 months ago[LV][RISCV] Add a test case for a quality problem mixing vector index and data types
Philip Reames [Wed, 27 Jul 2022 18:29:59 +0000 (11:29 -0700)]
[LV][RISCV] Add a test case for a quality problem mixing vector index and data types

The problem here is target independent, but particularly painful on RISCV.  If we chose to vectorize such that vscale x 2 x i32 is our widest type and fits in a register, a naive expansion of i64 comparisons results in comparisons and index types at <scalabe x 2 x i64>.  This requires both an LMUL of 2, and a VSETVLI toggle in the loop.  Note that we could have used <vscale x 2 x i32> for the compairons legally given the range of the trip count.

23 months agoUse hasNItemsOrLess() in MRI::hasAtMostUserInstrs().
Amara Emerson [Wed, 27 Jul 2022 18:11:46 +0000 (11:11 -0700)]
Use hasNItemsOrLess() in MRI::hasAtMostUserInstrs().

23 months ago[VPlan] Mark VPPredInstPHIRecipe as not having side-effects.
Florian Hahn [Wed, 27 Jul 2022 18:29:26 +0000 (19:29 +0100)]
[VPlan] Mark VPPredInstPHIRecipe as not having side-effects.

Now that all uses of VPPredInstPHIRecipes are properly modeled, they can
be treated as not having side-effects, enabling removal.

23 months ago[libc++] Implement P1004R2 (constexpr std::vector)
Nikolas Klauser [Wed, 27 Jul 2022 12:41:40 +0000 (14:41 +0200)]
[libc++] Implement P1004R2 (constexpr std::vector)

Reviewed By: #libc, ldionne

Spies: mgorny, var-const, ormris, philnik, miscco, hiraditya, steven_wu, jkorous, ldionne, christof, libcxx-commits

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

23 months ago[AMDGPU] Precommit s_setprio scheduling test. NFC.
Stanislav Mekhanoshin [Wed, 27 Jul 2022 18:17:54 +0000 (11:17 -0700)]
[AMDGPU] Precommit s_setprio scheduling test. NFC.

23 months ago[clang][dataflow][NFC] Remove last use of deprecated ctor
Eric Li [Wed, 27 Jul 2022 18:17:14 +0000 (14:17 -0400)]
[clang][dataflow][NFC] Remove last use of deprecated ctor

Use a delegating constructor to remove the last use of the deprecated
ctor of `TypeErasedDataflowAnalysis`, and then delete it.

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

23 months ago[ELF][test] Fix compressed-debug-level.test with zlib-ng
Fangrui Song [Wed, 27 Jul 2022 18:18:19 +0000 (11:18 -0700)]
[ELF][test] Fix compressed-debug-level.test with zlib-ng

The test is brittle but it seems unnecessary to remove size check now.

Close #56222

23 months ago[AArch64] Explicitly use v1i64 type for llvm.aarch64.neon.pmull64
Mingming Liu [Tue, 26 Jul 2022 05:48:56 +0000 (22:48 -0700)]
[AArch64] Explicitly use v1i64 type for llvm.aarch64.neon.pmull64

Without this, the intrinsic will be expanded to an integer; thereby an
explicit copy (from GPR to SIMD register) will be codegen'd. This matches the
general convention of using "v1" types to represent scalar integer operations in
vector registers.

The similar approach is observed in D56616, and the pattern likely applies on
other intrinsic that accepts integer scalars (e.g.,
int_aarch64_neon_sqdmulls_scalar)

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

23 months ago[libc++] Fixes the CI.
Mark de Wever [Wed, 27 Jul 2022 17:59:56 +0000 (19:59 +0200)]
[libc++] Fixes the CI.

The GDB test was disabled for clang-15, updated the filter since main
now is clang-16.

23 months ago[LV] Refresh an autogened test to pickup naming changes
Philip Reames [Wed, 27 Jul 2022 17:48:52 +0000 (10:48 -0700)]
[LV] Refresh an autogened test to pickup naming changes

23 months ago[AArch64][GlobalISel] Add heuristics for localizing G_CONSTANT.
Amara Emerson [Tue, 26 Jul 2022 08:27:44 +0000 (01:27 -0700)]
[AArch64][GlobalISel] Add heuristics for localizing G_CONSTANT.

This adds similar heuristics to G_GLOBAL_VALUE, querying the cost of
materializing a specific constant in code size. Doing so prevents us from
sinking constants which require multiple instructions to generate into
use blocks.

Code size savings on CTMark -Os:
Program                                       size.__text
                                              before         after           diff
ClamAV/clamscan                               381940.00      382052.00       0.0%
lencod/lencod                                 428408.00      428428.00       0.0%
SPASS/SPASS                                   411868.00      411876.00       0.0%
kimwitu++/kc                                  449944.00      449944.00       0.0%
Bullet/bullet                                 463588.00      463556.00      -0.0%
sqlite3/sqlite3                               284696.00      284668.00      -0.0%
consumer-typeset/consumer-typeset             414492.00      414424.00      -0.0%
7zip/7zip-benchmark                           595244.00      594972.00      -0.0%
mafft/pairlocalalign                          247512.00      247368.00      -0.1%
tramp3d-v4/tramp3d-v4                         372884.00      372044.00      -0.2%
                           Geomean difference                               -0.0%

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

23 months ago[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 3
Slava Gurevich [Tue, 26 Jul 2022 21:18:41 +0000 (14:18 -0700)]
[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 3

Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com/projects/llvm:

1355854, 1347549, 1316348, 1372028, 1431625,
1315634, 1315637, 1355855, 1364803, 1420505,
1420563, 1420685, 1366014, 1203966, 1204029,
1204031, 1204032, 1328411, 1325969, 1325968,
1374921, 1094809

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

23 months agoAllow data prefetch into non-default address space
Stanislav Mekhanoshin [Thu, 14 Jul 2022 19:19:18 +0000 (12:19 -0700)]
Allow data prefetch into non-default address space

I am playing with the LoopDataPrefetch pass and found out that it
bails to work with a pointer in a non-zero address space. This
patch adds the target callback to check if an address space is to
be considered for prefetching. Default implementation still only
allows address space 0, so this is NFCI.

This does not currently affect any known targets, but seems to be
generally useful for the future.

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

23 months ago[Lit] Sort previously failed tests early
David Green [Wed, 27 Jul 2022 16:55:11 +0000 (17:55 +0100)]
[Lit] Sort previously failed tests early

D98179 added a mechanism to sort tests by test time to run slow tests
early, increasing potential parallelism. It also added a feature where
negative tests would be marked as negative, allowing subsequent test
runs to run them earlier. Unfortunately it never actually stored the
negative time, even if all the other code seemed to be inplace to sort
them early. Luckily the fix seems simple.

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

23 months agoFix misc uses of "long" variables to use "int64_t".
Eli Friedman [Wed, 27 Jul 2022 16:37:13 +0000 (09:37 -0700)]
Fix misc uses of "long" variables to use "int64_t".

I don't have any evidence these particular uses are actually causing any
issues, but we should avoid accidentally truncating immediate values
depending on the host.

23 months ago[RISCV] Add isel pattern for (mul (and X, 0xffffffff), 3<<C) with Zba.
Craig Topper [Wed, 27 Jul 2022 16:41:58 +0000 (09:41 -0700)]
[RISCV] Add isel pattern for (mul (and X, 0xffffffff), 3<<C) with Zba.

We can use slli.uw by C followed by sh1add. Similar can be done
for multiples of 5 and 9. We need to make sure that C is less than
32 to stay in bounds of the 5-bit immediate for slli.uw.

We have existing patterns for (mul X, 3<<C) that use sh1add
followed by slli. That order doesn't allow the and to be folded.

Reviewed By: reames

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

23 months ago[RISCV] Disable constant hoisting for multiply by negated power of 2.
Craig Topper [Wed, 27 Jul 2022 16:33:45 +0000 (09:33 -0700)]
[RISCV] Disable constant hoisting for multiply by negated power of 2.

A mul by a negated power of 2 is a slli followed by neg. This doesn't
require any constant materialization and may be lower latency than mul.
The neg may also be foldable into other arithmetic.

Reviewed By: reames

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

23 months ago[PowerPC] Change long to int64_t (which is always 64 bit or 8 bytes )
Umesh Kalappa [Wed, 27 Jul 2022 16:32:41 +0000 (09:32 -0700)]
[PowerPC] Change long to int64_t (which is always 64 bit or 8 bytes )

We can't guarantee the long always 64 bits like WINDOWS or LLP64 data
model (rare but we should consider).

So use int64_t from inttypes.h and safe in this case.

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

23 months ago[libc] Change sinf range reduction to mod pi/16 to be shared with cosf.
Tue Ly [Wed, 27 Jul 2022 01:14:22 +0000 (21:14 -0400)]
[libc] Change sinf range reduction to mod pi/16 to be shared with cosf.

Change `sinf` range reduction to mod pi/16 to be shared with `cosf`.

Previously, `sinf` used range reduction `mod pi`, but this cannot be used to implement `cosf` since the minimax algorithm for `cosf` does not converge due to critical points at `pi/2`.  In order to be able to share the same range reduction functions for both `sinf` and `cosf`, we change the range reduction to `mod pi/16` for the following reasons:
- The table size is sufficiently small: 32 entries for `sin(k * pi/16)` with `k = 0..31`.  It could be reduced to 16 entries if we treat the final sign separately, with an extra multiplication at the end.
- The polynomials' degrees are reduced to 7/8 from 15, with extra computations to combine `sin` and `cos` with trig sum equality.
- The number of exceptional cases reduced to 2 (with FMA) and 3 (without FMA).
- The latency is reduced while maintaining similar throughput as before.

Reviewed By: zimmermann6

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

23 months ago[libc++][doc] Extended integral type support
Mark de Wever [Thu, 7 Jul 2022 18:02:07 +0000 (20:02 +0200)]
[libc++][doc] Extended integral type support

This addresses a request during the review of D128929.

Reviewed By: ldionne, #libc

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

23 months ago[libc++] Update clang-format style.
Mark de Wever [Sun, 10 Jul 2022 12:14:36 +0000 (14:14 +0200)]
[libc++] Update clang-format style.

After evaluating the new style I noticed inner namespaces are now
indented. I am not fond of that style and I've seen some other review
comment in this regard so I propose we remove this option and use the
LLVM default not to indent it.

Reviewed By: ldionne, philnik, var-const, #libc

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

23 months ago[RISCV][LV] Add basic tests for default configuration
Philip Reames [Wed, 27 Jul 2022 16:10:12 +0000 (09:10 -0700)]
[RISCV][LV] Add basic tests for default configuration

All of our other tests are functionality tests constrained to some
specific configuration.  This one is intended to float with the
default configuration so that changes in that default are visible
in reviews.  Note that our current default does not enable
vectorization at all; thus the current output is unvectorized.

23 months ago[mlir][sparse] fix error when sparse kernel is nested in a scf structrual operator.
Peiming Liu [Wed, 27 Jul 2022 00:16:20 +0000 (00:16 +0000)]
[mlir][sparse] fix error when sparse kernel is nested in a scf structrual operator.

Sparse compiler failed on the provided test (when the sparse kernel is nested in a scf structrual operator).

Reviewed By: bixia

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