platform/upstream/llvm.git
15 months agoRecommit "[AArch64][TTI] Cost model FADD/FSUB/FNEG""
Sjoerd Meijer [Tue, 11 Apr 2023 11:40:14 +0000 (12:40 +0100)]
Recommit "[AArch64][TTI] Cost model FADD/FSUB/FNEG""

Fixed two test cases that relied on Asserts, and added a fallthrough
annotation to the switch case.

15 months ago[CodeGen] Add Pre-commit tests for D146988
Igor Kirillov [Wed, 5 Apr 2023 20:43:36 +0000 (20:43 +0000)]
[CodeGen] Add Pre-commit tests for D146988

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

15 months ago[DAG] Peek through zext/trunc in haveNoCommonBitsSet.
Amaury Séchet [Fri, 7 Apr 2023 21:32:31 +0000 (21:32 +0000)]
[DAG] Peek through zext/trunc in haveNoCommonBitsSet.

This limitation was discovered thanks to some regression in D127115 .

Reviewed By: RKSimon

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

15 months ago[X86] Improve test coverage for Issue #62014
Simon Pilgrim [Tue, 11 Apr 2023 11:18:56 +0000 (12:18 +0100)]
[X86] Improve test coverage for Issue #62014

Ensure we test different vector element sizes

15 months ago[X86] Split off test coverage for Issue #62014
Simon Pilgrim [Tue, 11 Apr 2023 10:57:23 +0000 (11:57 +0100)]
[X86] Split off test coverage for Issue #62014

vector-bo-select.ll should only be used for binop identity select tests

15 months ago[Pipelines] Drop outdated comments about O0 (NFC)
Nikita Popov [Tue, 11 Apr 2023 11:34:20 +0000 (13:34 +0200)]
[Pipelines] Drop outdated comments about O0 (NFC)

These methods can be called with an O0 level nowadays.

15 months ago[libc][NFC] Use new approach based on types to code memset
Guillaume Chatelet [Tue, 11 Apr 2023 11:31:38 +0000 (11:31 +0000)]
[libc][NFC] Use new approach based on types to code memset

15 months ago[clang][dataflow][NFC] Remove unused parameter from `insertIfGlobal()`.
Martin Braenne [Tue, 11 Apr 2023 10:21:25 +0000 (10:21 +0000)]
[clang][dataflow][NFC] Remove unused parameter from `insertIfGlobal()`.

Reviewed By: gribozavr2

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

15 months ago[Pipelines] Move AddDescriminators to consistent position
Nikita Popov [Tue, 11 Apr 2023 11:19:06 +0000 (13:19 +0200)]
[Pipelines] Move AddDescriminators to consistent position

In the non-ThinLTO pipeline this was directly before PipelineStartEP,
in the ThinLTO pipeline it was directly after. I don't think the
specific position matters here, just make sure it's the same for
both pipelines.

15 months ago[Pipelines] Use isLTOPreLink() helper in more places (NFC)
Nikita Popov [Tue, 11 Apr 2023 11:08:00 +0000 (13:08 +0200)]
[Pipelines] Use isLTOPreLink() helper in more places (NFC)

15 months ago[Pipelines] Remove redundant O0 check (NFC)
Nikita Popov [Tue, 11 Apr 2023 11:05:56 +0000 (13:05 +0200)]
[Pipelines] Remove redundant O0 check (NFC)

buildModuleSimplificationPipeline() is not used for O0.

15 months agoAMDGPU: Fold fneg into bitcast of build_vector
Matt Arsenault [Thu, 26 Jan 2023 19:46:00 +0000 (15:46 -0400)]
AMDGPU: Fold fneg into bitcast of build_vector

The math libraries have a lot of code that performs
manual sign bit operations by bitcasting doubles to int2
and doing bithacking on them. This is a bad canonical form
we should rewrite to use high level sign operations directly
on double. To avoid codegen regressions, we need to do a better
job moving fnegs to operate only on the high 32-bits.

This is only halfway to fixing the real case.

15 months ago[X86] Add test coverage for Issue #62014
Simon Pilgrim [Tue, 11 Apr 2023 10:36:03 +0000 (11:36 +0100)]
[X86] Add test coverage for Issue #62014

Added multiuse checks for v8i16 and v8f32 cases

15 months ago[mlir] rename Math/dependent-dialect.mlir to depends-on-arith.mlir
Alex Zinenko [Tue, 11 Apr 2023 10:35:46 +0000 (12:35 +0200)]
[mlir] rename Math/dependent-dialect.mlir to depends-on-arith.mlir

15 months ago[mlir] make Math dialect depend on Arith dialect
Alex Zinenko [Tue, 11 Apr 2023 08:41:29 +0000 (10:41 +0200)]
[mlir] make Math dialect depend on Arith dialect

Ops from the Math dialect use fastmath attributes defined in Arith.
Therefore Math dialect must declare a dependency on Arith for proper
construction and parsing.

Reviewed By: tpopp

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

15 months ago[X86] vector-bo-select.ll - add SSE test coverage
Simon Pilgrim [Tue, 11 Apr 2023 10:26:00 +0000 (11:26 +0100)]
[X86] vector-bo-select.ll - add SSE test coverage

15 months ago[LICM][NFC] Unify arithmetic statistics collection
Max Kazantsev [Tue, 11 Apr 2023 10:18:57 +0000 (17:18 +0700)]
[LICM][NFC] Unify arithmetic statistics collection

Avoid divergence b/w different kinds of hoisting with reassociation.
Make them all collect general stat NumHoisted and also specific stats
for each particular transform.

15 months ago[LiveInterval] Fix live range overlap check
Momchil Velikov [Tue, 11 Apr 2023 08:45:15 +0000 (09:45 +0100)]
[LiveInterval] Fix live range overlap check

Reviewed By: MatzeB

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

15 months ago[LICM][NFC] Do not forward declaration of hoistMinMax
Max Kazantsev [Tue, 11 Apr 2023 10:06:20 +0000 (17:06 +0700)]
[LICM][NFC] Do not forward declaration of hoistMinMax

They all are now handled by hoistArithmetics, and only it should be
forwarded.

15 months ago[Test] Precommit negative test on add/sub hoisting
Max Kazantsev [Tue, 11 Apr 2023 10:03:00 +0000 (17:03 +0700)]
[Test] Precommit negative test on add/sub hoisting

Should not optimize here because no-overflow is not proved.

15 months ago[LICM] Fix assert failure in no-allowspeculation mode
Nikita Popov [Tue, 11 Apr 2023 09:54:42 +0000 (11:54 +0200)]
[LICM] Fix assert failure in no-allowspeculation mode

In this case the source GEP might not be hoisted even though it
has invariant operands. For now just bail out, but we might need
additional checks for AllowSpeculation in these special-case
reassociation folds.

15 months ago[X86][MC] Emit instructions into SmallVector
Alexis Engelke [Fri, 10 Mar 2023 14:23:22 +0000 (15:23 +0100)]
[X86][MC] Emit instructions into SmallVector

Depends on D145791

Storing instruction bytes directly in a SmallVector instead of a
raw_ostream yields better encoding performance (in some applications,
the improvment is ~1% of the complete back-end time).

Reviewed By: MaskRay, Amir

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

15 months ago[FastISel] Correctly report prototype on miss
Alexis Engelke [Thu, 9 Mar 2023 18:15:24 +0000 (19:15 +0100)]
[FastISel] Correctly report prototype on miss

The type of a function is nowadays just an opaque pointer, which is not
helpful when analyzing FastISel misses. Instead print the actual
function type of the function.

Reviewed By: efriedma

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

15 months ago[amdgpu][nfc] Update comments on LDS lowering
Jon Chesterfield [Tue, 11 Apr 2023 09:47:53 +0000 (10:47 +0100)]
[amdgpu][nfc] Update comments on LDS lowering

15 months ago[llvm][clang] Correct example in -mcpu-help text
David Spickett [Tue, 11 Apr 2023 09:34:01 +0000 (09:34 +0000)]
[llvm][clang] Correct example in -mcpu-help text

This used to say:
For example, clang --target=aarch64-unknown-linux-gui -mcpu=cortex-a35

Which works but I think it was meant to be `-gnu` not `-gui`. From my
AArch64 Linux build:
```
$ ./bin/clang --version
clang version 17.0.0 <...>
Target: aarch64-unknown-linux-gnu
```

Originally added in af857b93df36a983a27a82455c0dea39f53da5b1.

15 months agoRevert "[AArch64][TTI] Cost model FADD/FSUB/FNEG"
Sjoerd Meijer [Tue, 11 Apr 2023 09:04:38 +0000 (10:04 +0100)]
Revert "[AArch64][TTI] Cost model FADD/FSUB/FNEG"

This reverts commit d0027e0be990df60f6f826123f035286a168f288.

Need to look at 2 test failures.

15 months ago[AMDGPU] Add MMOs for GFX11 Streamout Instructions
Diana Picus [Mon, 13 Mar 2023 15:37:44 +0000 (16:37 +0100)]
[AMDGPU] Add MMOs for GFX11 Streamout Instructions

The GFX11 NGG Streamout Instructions perform atomic operations on
dedicated registers. At the moment, they lack machine memory operands,
which causes the si-memory-legalizer pass to treat them conservatively
and introduce several unnecessary waits and cache invalidations.

This patch introduces a new address space to represent these special
registers and teaches instruction selection to add memory operands with
this new address space to DS_ADD/SUB_GS_REG_RTN.

Since this address space is meant to be compiler-internal, we move it
up a bit from the other address spaces and give it the number 128.
According to the LLVM Language Reference, address space numbers can go
all the way up to 2^24, but I'm not sure how well this is supported in
practice [1], so using a smaller number seems safer.

[1] https://github.com/llvm/llvm-project/blob/0107513fe79da7670e37c29c0862794a2213a89c/llvm/utils/TableGen/IntrinsicEmitter.cpp#L401

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

15 months agoclang-format file I'm about to touch. NFCI
Diana Picus [Tue, 11 Apr 2023 08:23:51 +0000 (10:23 +0200)]
clang-format file I'm about to touch. NFCI

15 months ago[WebAssembly] Correctly check end_if/end_try with else/catch
Heejin Ahn [Sun, 9 Apr 2023 10:28:15 +0000 (03:28 -0700)]
[WebAssembly] Correctly check end_if/end_try with else/catch

When we encounter an `else`, `catch`, or `catch_all`, we currently just
push the structure `NestingType` and don't preserve the original `if`
and `try`'s signature. So after we pass `else`/`catch`/`catch_all`, we
can't check if the values on stack have the correct types when we
encounter `end_if` or `end_try`. This CL fixes the issue, and modifies
the existing test to be correct (some of them had `try` without
`catch`).

Reviewed By: dschuff

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

15 months ago[WebAssembly] Handle block-like structures consistently in type checker
Heejin Ahn [Sat, 8 Apr 2023 14:11:43 +0000 (07:11 -0700)]
[WebAssembly] Handle block-like structures consistently in type checker

We disable type check in unreachable code, but when the unreachable code
is enclosed within a block-like structure, the block as a whole has a
valid type and we should continue type checking after the block. But it
looks we currently only do that for blocks and not other block-like
structures (`loop`s, `try`s, and `if`s). Also unreachable code within
`if`'s true body shouldn't disable type checking in `else` body, and
that in `try` body shouldn't disable type checking in `catch/catch_all`
body.

This also causes the values/types on the stack to be correctly checked
when encounterint `catch`, `catch_all`, and `delegate`.

Reviewed By: dschuff

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

15 months ago[WebAssembly] Fix type index block type handling in type checker
Heejin Ahn [Sat, 8 Apr 2023 03:29:25 +0000 (20:29 -0700)]
[WebAssembly] Fix type index block type handling in type checker

The current code is
```
      ExpectBlockType = false;
      TC.setLastSig(*Signature.get());
      if (ExpectBlockType)
        NestingStack.back().Sig = *Signature.get();
```

Because of the first line, the third line's `if (ExpectBlockType)` is
always false and we don't get to update `NestingStack.back().Sig`. This
results in not correctly erroring out when the types of remaining values
on the stack do not match the block type if the block type is written in
the form of a function type. We should set `ExpectBlockType` to false
after the `if`.

Reviewed By: sbc100

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

15 months ago[AArch64][TTI] Cost model FADD/FSUB/FNEG
Sjoerd Meijer [Tue, 11 Apr 2023 08:37:37 +0000 (09:37 +0100)]
[AArch64][TTI] Cost model FADD/FSUB/FNEG

This lowers the cost for FADD, FSUB, and FNEG. The motivation is to avoid
over-eager SLP vectorisation, that makes it look like SLP vectorisation is
profitable but results in significant slow downs. Lowering the cost for scalar
FADD/FSUB costs helps the profitability decision to favour the scalar
version where vectorisation isn't beneficial.

Lowering the cost for these floating point operations makes sense because a lot
of other instructions including many shuffles have only a cost of 1; these
FADD/FSUB/FNEG instructions should not be twice the cost.

Performance results show a 7% improvement for Imagick from SPEC FP 2017, a
small improvement in Blender, and unchanged results for the other apps in SPEC.
RAJAPerf is neutral and mostly shows no changes.

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

15 months ago[LoongArch] Fix typos in file description. NFC
wanglei [Tue, 11 Apr 2023 08:24:13 +0000 (16:24 +0800)]
[LoongArch] Fix typos in file description. NFC

15 months ago[LICM] Reassociate GEPs to allow hoisting
Nikita Popov [Fri, 24 Mar 2023 14:10:53 +0000 (15:10 +0100)]
[LICM] Reassociate GEPs to allow hoisting

Reassociate gep (gep ptr, idx1), idx2 to gep (gep ptr, idx2), idx1
if this would make the inner GEP loop invariant and thus hoistable.

This is intended to replace an InstCombine fold that does this (in
https://github.com/llvm/llvm-project/blob/04f61fb73dc6a994ab267d431f2fdaedc67430ff/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L2006).
The problem with the InstCombine fold is that LoopInfo is an optional
dependency, so it is not performed reliably.

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

15 months ago[ARM] Convert test to opaque pointers
Nikita Popov [Tue, 4 Apr 2023 09:27:43 +0000 (11:27 +0200)]
[ARM] Convert test to opaque pointers

When converting this test to opaque pointers, we get a register
move between the call and the inline asm. However, the test
comment specifically says that there should be nothing between them.

As far as I can tell, this is fine, both in that the inline asm
doesn't use the relevant registers, but also more generally
because the inline asm doesn't declare any clobbers, so really
LLVM can do whatever, side effects or not. The test was added
by 618ce3e85ed1c68e89dc696b7c9ab94a6a910797 with only a reference
to Apple's internal issue tracker.

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

15 months ago[clang] Add test for CWG1822
Vlad Serebrennikov [Tue, 11 Apr 2023 08:07:00 +0000 (11:07 +0300)]
[clang] Add test for CWG1822

[[https://wg21.link/p1787 | P1787]]: CWG1822 is resolved by specifying that the body of a lambda remains in the surrounding (function parameter) scope.
Wording: A parameter-declaration-clause P introduces a function parameter scope that includes P. <...> If P is associated with a lambda-declarator, its scope extends to the end of the compound-statement in the lambda-expression. ([basic.scope.param])

Reviewed By: #clang-language-wg, shafik

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

15 months ago[InstCombine] Allow splats with poison/undef in llvm::decomposeBitTestICmp
John McIver [Tue, 11 Apr 2023 08:03:01 +0000 (09:03 +0100)]
[InstCombine] Allow splats with poison/undef in llvm::decomposeBitTestICmp

This change is made to enable conversion of a masked icmp splat vector
containing poison/undef to an equality expression.

llvm::decomposeBitTestICmp Alive2 correctness examples using splat/masking vectors:

    SLT <    https://alive2.llvm.org/ce/z/pPTTHh
    SLE <=   https://alive2.llvm.org/ce/z/qQhAmU
    SGT >    https://alive2.llvm.org/ce/z/koFHzF
    SGE >=   https://alive2.llvm.org/ce/z/3SNz2S
    ULT <u   https://alive2.llvm.org/ce/z/W8ktzQ
    ULE <=u  https://alive2.llvm.org/ce/z/G5SdUY
    UGT >u   https://alive2.llvm.org/ce/z/WFwYxq
    UGE >=u  https://alive2.llvm.org/ce/z/DzJszP

Tests have been verified using Alive2:

    icmp-logical.ll: @nomask_splat_and_B_allones       https://alive2.llvm.org/ce/z/zmJwQU
    icmp-logical.ll: @nomask_splat_and_B_mixed         https://alive2.llvm.org/ce/z/ktzgzd
    signed-truncation-check.ll: @positive_vec_undef0   https://alive2.llvm.org/ce/z/-sTRLD

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

15 months ago[InstCombine][NFC] Add tests with icmp splat vectors and B masks
John McIver [Tue, 11 Apr 2023 07:59:34 +0000 (08:59 +0100)]
[InstCombine][NFC] Add tests with icmp splat vectors and B masks

Add tests to verifying future support for splat vectors containing poison/undef in llvm::decomposeBitTestICmp.

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

15 months ago[Test] Fix tests according to initial intent, add more tests & comments
Max Kazantsev [Tue, 11 Apr 2023 07:28:39 +0000 (14:28 +0700)]
[Test] Fix tests according to initial intent, add more tests & comments

15 months agoReland "[MLIR] Add an assert in Operation::getOpResultImpl for out of range result"
Shivam Gupta [Tue, 11 Apr 2023 06:30:11 +0000 (12:00 +0530)]
Reland "[MLIR] Add an assert in Operation::getOpResultImpl for out of range result"

This reverts commit e08af170736271f022b2cab44d58326356ce1db8.

15 months ago[RISCV] Remove is*Branch instruction flags from C_JR
Job Noorman [Tue, 11 Apr 2023 07:28:18 +0000 (09:28 +0200)]
[RISCV] Remove is*Branch instruction flags from C_JR

As discussed in 1d1b3c49531b, instruction flags set in the *.td files
are under-approximations. For C_JR, isBranch and isConditionalBranch are
set even though it is used for for returns which are not considered
branches.

This patch proposes to remove those flags from C_JR. More detailed
analysis can be implemented in RISCVMCInstrAnalysis.

Reviewed By: craig.topper

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

15 months ago[AMDGPU] Hide "removing function" diagnostics by default
pvanhout [Thu, 6 Apr 2023 12:07:41 +0000 (14:07 +0200)]
[AMDGPU] Hide "removing function" diagnostics by default

Use an `OptimizationRemark` for them even though it's not really an
optimization. It just integrates better with the other diagnostics
(enabling is easy with `-pass-remark`).

Reviewed By: arsenm

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

15 months ago[NFC] Fix typo in statistic description
Max Kazantsev [Tue, 11 Apr 2023 06:27:48 +0000 (13:27 +0700)]
[NFC] Fix typo in statistic description

15 months ago[LICM][NFC] Restructure code to have one entry point for reassociation-based hoistings
Max Kazantsev [Tue, 11 Apr 2023 06:14:17 +0000 (13:14 +0700)]
[LICM][NFC] Restructure code to have one entry point for reassociation-based hoistings

We already hoist min/max functions and want to do more of this kind. Some
refactoring to make growth points for it.

15 months ago[LICM] Add test showing subtraction hoisting opportunity
Max Kazantsev [Tue, 11 Apr 2023 06:09:41 +0000 (13:09 +0700)]
[LICM] Add test showing subtraction hoisting opportunity

15 months ago[TableGen] Call std::vector::reserve to preallocate memory before a loop of push_back...
Craig Topper [Tue, 11 Apr 2023 07:07:57 +0000 (00:07 -0700)]
[TableGen] Call std::vector::reserve to preallocate memory before a loop of push_back. NFC

15 months ago[clang-tidy] Fix hungarian notation failed to indicate the number of asterisks in...
Douglas Chen [Tue, 11 Apr 2023 06:10:57 +0000 (06:10 +0000)]
[clang-tidy] Fix hungarian notation failed to indicate the number of asterisks in check-clang-extra-clang-tidy-checkers-readability

Fix hungarian notation failed to indicate the number of asterisks for the pointers of multiple word types.

- WRONG: `unsigned char* value`  : `value` --> `ucValue`
- RIGHT: `unsigned cahr* value`  : `value`  --> `pucValue`
- RIGHT: `unsigned char** value` : `value`  --> `ppucValue`

Reviewed By: amurzeau, PiotrZSL

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

15 months ago[NFC] add check for potentially dereferencing null return value
Bing1 Yu [Tue, 11 Apr 2023 06:42:03 +0000 (14:42 +0800)]
[NFC] add check for potentially dereferencing null return value

Reviewed By: pengfei

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

15 months ago[mlir] Make the inliner arg/res handlers more concise.
Tobias Gysi [Tue, 11 Apr 2023 06:16:12 +0000 (06:16 +0000)]
[mlir] Make the inliner arg/res handlers more concise.

The revision ensures the newly introduced argument
and result handlers cannot be used for type conversion.
Instead use the existing materializeCallConversion hook to
perform type conversions.

Reviewed By: Dinistro

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

15 months ago[clang-tidy] Use StringRef::contains (NFC)
Kazu Hirata [Tue, 11 Apr 2023 06:33:47 +0000 (23:33 -0700)]
[clang-tidy] Use StringRef::contains (NFC)

15 months ago[CodeGen][ShrinkWrap] Split restore point
sgokhale [Tue, 11 Apr 2023 06:14:28 +0000 (11:44 +0530)]
[CodeGen][ShrinkWrap] Split restore point

This patch splits a restore point to allow it to only post-dominate blocks reachable by use
or def of CSRs(Callee Saved Registers)/FI(Frame Index).

Benchmarking this on SPEC2017, this gives around 4% improvement on povray and no significant change
for others.

Co-authored-by: junbuml
Differential Revision: https://reviews.llvm.org/D42600

15 months agoFix use-after-free in help message: this cl::opt was binding a StringRef to a tempora...
Mehdi Amini [Tue, 11 Apr 2023 04:50:19 +0000 (22:50 -0600)]
Fix use-after-free in help message: this cl::opt was binding a StringRef to a temporary string

Caught by ASAN on a bot: https://lab.llvm.org/buildbot/#/builders/168/builds/12872/steps/14/logs/stdio

15 months ago[X86][mem-fold] Use x86-registered-target in the tablgen test, NFCI
Shengchen Kan [Tue, 11 Apr 2023 06:06:04 +0000 (14:06 +0800)]
[X86][mem-fold] Use x86-registered-target in the tablgen test, NFCI

15 months ago[TableGen] Avoid vector copy in TreePatter::InlinePatternFragments. NFC
Craig Topper [Tue, 11 Apr 2023 06:01:15 +0000 (23:01 -0700)]
[TableGen] Avoid vector copy in TreePatter::InlinePatternFragments. NFC

Instead of copying a vector and clearing the original, we can swap
with an empty vector.

15 months ago[SCEV][NFC] GetMinTrailingZeros switch case and naming cleanup
Joshua Cao [Tue, 11 Apr 2023 05:39:40 +0000 (22:39 -0700)]
[SCEV][NFC] GetMinTrailingZeros switch case and naming cleanup

* combine zext and sext into the one switch case
* combine vscale and udiv into one switch case
* renames according to LLVM style

15 months ago[Test] Add some more IndVars canonicalization tests
Max Kazantsev [Tue, 11 Apr 2023 05:31:57 +0000 (12:31 +0700)]
[Test] Add some more IndVars canonicalization tests

15 months ago[X86][AMX] Add check for potentially dereferencing null return value
Bing1 Yu [Mon, 10 Apr 2023 09:09:35 +0000 (17:09 +0800)]
[X86][AMX] Add check for potentially dereferencing null return value

Reviewed By: xiangzhangllvm

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

15 months ago[X86][mem-fold] Only run x86-fold-tables.test when target x86 is built
Shengchen Kan [Tue, 11 Apr 2023 04:32:37 +0000 (12:32 +0800)]
[X86][mem-fold] Only run x86-fold-tables.test when target x86 is built

Avoid the LIT fail when only arm/aarch64 is built.

15 months ago[libc] Correctly add new files
Alex Brachet [Tue, 11 Apr 2023 04:41:14 +0000 (04:41 +0000)]
[libc] Correctly add new files

15 months agoReland "[libc] Add {,r}index"
Alex Brachet [Tue, 11 Apr 2023 04:30:50 +0000 (04:30 +0000)]
Reland "[libc] Add {,r}index"

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

15 months ago[ORC] Link `atomic` on platforms without hardware support for atomics.
Owen Shepherd [Tue, 11 Apr 2023 04:11:48 +0000 (04:11 +0000)]
[ORC] Link `atomic` on platforms without hardware support for atomics.

Fixes error about missing reference to __atomic_fetch_add_8 when linking
LLVMOrcJit on ARMv6.

Reviewed By: lhames

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

15 months ago[X86][mem-fold] Speed up test by not re-generating the .inc file
Shengchen Kan [Tue, 11 Apr 2023 02:00:18 +0000 (10:00 +0800)]
[X86][mem-fold] Speed up test by not re-generating the .inc file

Reviewed By: pengfei

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

15 months ago[SCEV] Strengthen huge constant trip multiples.
Joshua Cao [Sun, 9 Apr 2023 01:12:46 +0000 (18:12 -0700)]
[SCEV] Strengthen huge constant trip multiples.

SCEV determines that loops with trip count >=2^32 have a trip multiple
of 1 to guard against huge multiples. This patch stregthens this to
instead find the greatest power of 2 divisor that is less than the
threshold.

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

15 months ago[LoopUnroll] Add script test checks for LoopUnroll/X86/mmx.ll
Joshua Cao [Sun, 9 Apr 2023 01:05:26 +0000 (18:05 -0700)]
[LoopUnroll] Add script test checks for LoopUnroll/X86/mmx.ll

15 months ago[SCEV][NFC] Convert check to assert getSmallConstantTripMultiple()
Joshua Cao [Sun, 9 Apr 2023 00:31:43 +0000 (17:31 -0700)]
[SCEV][NFC] Convert check to assert getSmallConstantTripMultiple()

15 months ago[SCEV] When computing trip count, only zext if necessary
Joshua Cao [Wed, 29 Mar 2023 03:49:39 +0000 (20:49 -0700)]
[SCEV] When computing trip count, only zext if necessary

This patch improves on https://reviews.llvm.org/D110587. To summarize
the patch, given backedge-taken count BC, trip count TC is `BC + 1`.
However, we don't know if BC we might overflow. So the patch modifies TC
computation to `1 + zext(BC)`.

This patch only adds the zext if necessary by looking at the constant
range. If we can determine that BC cannot be the max value for its
bitwidth, then we know adding 1 will not overflow, and the zext is not
needed. We apply loop guards before computing TC to get more data.

The primary motivation is to support my work on more precise trip
multiples in https://reviews.llvm.org/D141823. For example:

```
void test(unsigned n)
  __builtin_assume(n % 6 == 0);
  for (unsigned i = 0; i < n; ++i)
    foo();
```

Prior to this patch, we had `TC = 1 + zext(-1 + 6 * ((6 umax %n) /u
6))<nuw>`. SCEV range computation is able to determine that the BC
cannot be the max value, so the zext is not needed. The result is `TC
-> (6 * ((6 umax %n) /u 6))<nuw>`. From here, we would be able to
determine that %n is a multiple of 6.

There was one change in LoopCacheAnalysis/LoopInterchange required.
Before this patch, if a loop has BC = false, it would compute `TC -> 1 +
zext(false) -> 1`, which was fine. After this patch, it computes `TC -> 1
+ false = true`. CacheAnalysis would then sign extend the `true`, which
was not the intended the behavior. I modified CacheAnalysis such that
it would only zero extend trip counts.

This patch is not NFC, but also does not change any SCEV outputs. I
would like to get this patch out first to make work with trip multiples
easier.

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

15 months ago[Sanitizer][Test] Disable atos test on unknown address for ubsan
Blue Gaston [Mon, 10 Apr 2023 22:53:47 +0000 (15:53 -0700)]
[Sanitizer][Test] Disable atos test on unknown address for ubsan

This test is failing for some cases in CI for ubsan. I suspect because
of the undefined behavior nature of the test, ubsan does not always
try to symbolicate or save the frame for the faulting address.

Specifically is failing on x86 CI. But making this unsupported on
ubsan for now.

rdar://107846128

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

15 months ago[MCJIT] Run ExecutionEngine/MCJIT/remote tests only if threads enabled.
Youngsuk Kim [Tue, 11 Apr 2023 01:41:48 +0000 (01:41 +0000)]
[MCJIT] Run ExecutionEngine/MCJIT/remote tests only if threads enabled.

When LLVM_ENABLE_THREADS=Off, disables tests under
llvm/test/ExecutionEngine/MCJIT/remote/ that require threads.

Reviewed By: lhames

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

15 months ago[mlir][linalg] Replace `getUpperBoundForIndex` implementation
Matthias Springer [Tue, 11 Apr 2023 01:19:19 +0000 (10:19 +0900)]
[mlir][linalg] Replace `getUpperBoundForIndex` implementation

Use `reifyValueBound` instead, which is more general not hard-coded to a specific list supported ops.

Also add a `closedUB` parameter to the ValueBoundsOpInterface API.

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

15 months agoRevert "[libc] Add {,r}index"
Alex Brachet [Tue, 11 Apr 2023 01:21:39 +0000 (01:21 +0000)]
Revert "[libc] Add {,r}index"

This reverts commit a0a141fcbe1dfd35032fa5c052e6906180a37fb1.

15 months ago[Target] Use isNullConstant and isOneConstant (NFC)
Kazu Hirata [Tue, 11 Apr 2023 01:23:07 +0000 (18:23 -0700)]
[Target] Use isNullConstant and isOneConstant (NFC)

15 months agoUse APInt::getOneBitSet (NFC)
Kazu Hirata [Tue, 11 Apr 2023 01:19:17 +0000 (18:19 -0700)]
Use APInt::getOneBitSet (NFC)

15 months ago[lldb-vscode] Fix two issues with runInTerminal test.
Jorge Gorbe Moya [Fri, 7 Apr 2023 20:34:16 +0000 (13:34 -0700)]
[lldb-vscode] Fix two issues with runInTerminal test.

With ptrace_scope = 1 the kernel only allows tracing descendants of a
process. When using runInTerminal, the target process is not launched
by the debugger, so we need to modify LaunchRunInTerminal to explicitly
allow tracing. This should fix a problem reported in
https://reviews.llvm.org/D84974#3903716

In order to allow only the main lldb-vscode process to attach to the
target, this change introduces a new `--debugger-pid` flag that needs
to be passed with `--launch-target` and `--comm-file`.

Also, remove a special case from the launch method in the
lldbvscode_testcase test harness. The existing test was using
stopOnEntry, so the first stop didn't happen at the expected breakpoint
unless the harness did configurationDone first.

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

15 months ago[libc] Add {,r}index
Alex Brachet [Tue, 11 Apr 2023 01:16:21 +0000 (01:16 +0000)]
[libc] Add {,r}index

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

15 months ago[libc] Move str{,r}chr implementation to headers
Alex Brachet [Tue, 11 Apr 2023 01:11:32 +0000 (01:11 +0000)]
[libc] Move str{,r}chr implementation to headers

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

15 months ago[mlir][Interfaces] Better error handling for `addBound`
Matthias Springer [Tue, 11 Apr 2023 00:31:16 +0000 (09:31 +0900)]
[mlir][Interfaces] Better error handling for `addBound`

Do not assert if a bound could not be added. This may or may not cause an error. We have the appropriate error handling in `computeBound` (which returns a `LogicalResult`).

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

15 months agoAdd tracing for pattern application in a ApplyPatternAction
Mehdi Amini [Tue, 11 Apr 2023 00:39:34 +0000 (18:39 -0600)]
Add tracing for pattern application in a ApplyPatternAction

Reviewed By: rriddle

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

15 months ago[Updated commit] Fix Transpose Check in MMA.SYNC Path.
Manish Gupta [Thu, 6 Apr 2023 23:58:17 +0000 (23:58 +0000)]
[Updated commit] Fix Transpose Check in MMA.SYNC Path.

Pushed a stale commit for the same review in my previous commit.
I am updating the main-line with the latest commit including
review commits. Apologies for the redundant commit.

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

15 months agoFix Transpose Check in MMA.SYNC Path
Manish Gupta [Thu, 6 Apr 2023 23:58:17 +0000 (23:58 +0000)]
Fix Transpose Check in MMA.SYNC Path

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

15 months ago[flang][NFC] Move TypeConverter.h header file to include dir
Valentin Clement [Tue, 11 Apr 2023 00:01:10 +0000 (17:01 -0700)]
[flang][NFC] Move TypeConverter.h header file to include dir

After the extraction of the TypeConverter, move the header files
to the include dir so the shared library build is fine.

Reviewed By: PeteSteinfeld

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

15 months ago[clang-tidy][NFC] Remove redundant allOf matcher calls
Nathan James [Mon, 10 Apr 2023 23:38:37 +0000 (00:38 +0100)]
[clang-tidy][NFC] Remove redundant allOf matcher calls

Remove calls to the `allOf` matcher in all matchers that are derived from the `VariadicDynCastAllOfMatcher`.

15 months ago[libc] Add swab implementation
Caslyn Tonelli [Mon, 10 Apr 2023 20:24:58 +0000 (20:24 +0000)]
[libc] Add swab implementation

Swab implementation is added to libc/src/unistd.

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

15 months ago[ifs] Print an error when llvm-ifs is supplied with an unknown arch
Haowei Wu [Wed, 22 Mar 2023 23:41:47 +0000 (16:41 -0700)]
[ifs] Print an error when llvm-ifs is supplied with an unknown arch

This patch makes llvm-ifs print an error when the arch string from
'--arch' flag or the IFS file 'Arch' field is unknown.

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

15 months ago[TableGen] Pass TreePatternNodePtr to InlinePatternFragments by const reference. NFC
Craig Topper [Mon, 10 Apr 2023 20:36:52 +0000 (13:36 -0700)]
[TableGen] Pass TreePatternNodePtr to InlinePatternFragments by const reference. NFC

Not all paths through this function require the reference count
to be incremened. Pass by reference so we don't increase the count
unnecessarily.

15 months ago[flang][openacc] Add missing piece to translate to LLVM IR dialect
Valentin Clement [Mon, 10 Apr 2023 21:29:58 +0000 (14:29 -0700)]
[flang][openacc] Add missing piece to translate to LLVM IR dialect

Add missing pieces to translate handle OpenACC dialect in the translation.

Depends on D147825

Reviewed By: PeteSteinfeld, razvanlupusoru

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

15 months ago[libcxxabi, libunwind] [test] Place output from tests under a 'test' subdir
Martin Storsjö [Wed, 5 Apr 2023 10:56:54 +0000 (13:56 +0300)]
[libcxxabi, libunwind] [test] Place output from tests under a 'test' subdir

Previously, all the output from the tests were placed directly in
the build directory. The tests produce a couple directories named
`__config_{exec,cache,src}__` which are easy to distinguish, and
the output from the individual tests were placed directly in a
directory named `Output`.

This is the same change as
736c6e246f5398331d83edd204a846cc967ad5c6, but for the libcxxabi
and libunwind test suites.

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

15 months ago[mlir][math] Expand math.floorf to truncate, compares and increments
Balaji V. Iyer [Mon, 10 Apr 2023 21:01:26 +0000 (21:01 +0000)]
[mlir][math] Expand math.floorf to truncate, compares and increments

Floorf are pushed directly to libm. This is problematic for
situations where libm is not available. This patch will break down
a floorf function to truncate followed by an increment for negative
values, if necessary.

Reviewed By: rsuderman

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

15 months ago[compiler-rt] [test] Generalize the triple regex for windows XFAILs
Martin Storsjö [Fri, 31 Mar 2023 05:47:59 +0000 (08:47 +0300)]
[compiler-rt] [test] Generalize the triple regex for windows XFAILs

Don't hardcode the vendor field in the triples to "pc"; for mingw
environments the triple is often "<arch>-w64-windows-gnu".

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

15 months ago[compiler-rt] [test] [ubsan] Build .cpp files with %clangxx
Martin Storsjö [Thu, 6 Apr 2023 10:11:46 +0000 (13:11 +0300)]
[compiler-rt] [test] [ubsan] Build .cpp files with %clangxx

This fixes linker errors in mingw configurations, where the ubsan
runtime needs the C++ standard library when instrumenting C++ code.

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

15 months ago[compiler-rt] [test] Use %clangxx for tests that use -x c++
Martin Storsjö [Wed, 5 Apr 2023 21:41:51 +0000 (21:41 +0000)]
[compiler-rt] [test] Use %clangxx for tests that use -x c++

When instrumenting C++ code, ubsan ends up referencing
the ubsan_type_hash_* object files, which require linking against
the C++ ABI library. When building with "clang -x c++", the code
is handled as C++, but the compiler still only links as if it was
C.

Change all cases of "%clang -x c++" into "%clangxx -x c++".

This fixes a lot of ubsan tests in mingw mode.

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

15 months ago[compiler-rt] [builtins] Don't use assembly floatundi*f on x86_64 mingw
Martin Storsjö [Thu, 6 Apr 2023 07:51:35 +0000 (07:51 +0000)]
[compiler-rt] [builtins] Don't use assembly floatundi*f on x86_64 mingw

The x86 assembly is entirely skipped for MSVC build configurations,
since the assembly uses GAS syntax (which MSVC proper can't
assemble, but clang-cl can). But for mingw configurations, the
assembly is used.

On x86_64 Windows, the general calling convention is entirely different
than on other platforms (passing arguments in different registers),
so we can't use this assembly for mingw targets (unless adapted to
handle that calling convention). Thus skip these few assembly routines
for Windows targets. (For i386, we can keep using the assembly
functions.)

This fixes the builtins tests that test these routines. They aren't
used in practice though, as LLVM expands code inline for doing such
conversions anyway.

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

15 months ago[libcxxabi] [test] Mark thread_local_destruction_order.pass.cpp unsupported for mingw...
Martin Storsjö [Mon, 3 Apr 2023 12:52:46 +0000 (15:52 +0300)]
[libcxxabi] [test] Mark thread_local_destruction_order.pass.cpp unsupported for mingw targets

With current versions of mingw-w64, TLS destructors that are registered
while executing TLS destructors are lost and leaked.

The root cause does get fixed further upstream in mingw-w64 in
https://github.com/mingw-w64/mingw-w64/commit/71eddccd746c56d9cde28bb5620d027d49259de9
though, but mark the test as unsupported for now. The marking can be
removed later when the version used in the CI runner has been updated
to include the fix.

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

15 months ago[libunwind] [test] Mark the signal_frame test as unsupported on Windows
Martin Storsjö [Fri, 31 Mar 2023 21:52:05 +0000 (00:52 +0300)]
[libunwind] [test] Mark the signal_frame test as unsupported on Windows

Mark it as unsupported on x86_64, arm and aarch64. On i686, DWARF
is used as the default unwinding format, and there, the CFI
directives are supported.

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

15 months ago[libunwind] [SEH] Handle ExceptionContinueExecution in forced unwinding
Martin Storsjö [Wed, 5 Apr 2023 10:42:22 +0000 (10:42 +0000)]
[libunwind] [SEH] Handle ExceptionContinueExecution in forced unwinding

This fixes the libcxxabi test force_unwind3.pass.cpp when run on native
Windows.

When unwinding past the main thread function into the system functions
that brought up the thread, we can hit functions whose personality
functions return ExceptionContinueExecution (instead of the regular
ExceptionContinueSearch). Interpret this as a signal to stop the
unwind.

Curiously, in this case, it does return ExceptionContinueSearch if
running within a debugger.

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

15 months ago[libunwind] [SEH] Sync LSDA and handler between unw_proc_info_t and DISPATCHER_CONTEXT
Martin Storsjö [Tue, 4 Apr 2023 20:26:20 +0000 (20:26 +0000)]
[libunwind] [SEH] Sync LSDA and handler between unw_proc_info_t and DISPATCHER_CONTEXT

For normal C++ unwinding, we get _dispContext initialized by the
prepopulated DISPATCHER_CONTEXT in _GCC_specific_handler, which
we set with __unw_seh_set_disp_ctx.

When doing force unwinding, we step and populate the unw_proc_info_t
struct _info with getInfoFromSEH, but when we execute the handler
via the __libunwind_seh_personality wrapper function, we execute
the handler set in DISPATCHER_CONTEXT.

Whenever updating these fields in either _info or _dispContext,
sync them to the other one too.

This fixes one aspect of the libcxxabi force_unwind*.pass.cpp tests on
x86_64.

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

15 months ago[libunwind] Increase the external value of _LIBUNWIND_CURSOR_SIZE for SEH/x86_64
Martin Storsjö [Wed, 5 Apr 2023 11:12:24 +0000 (14:12 +0300)]
[libunwind] Increase the external value of _LIBUNWIND_CURSOR_SIZE for SEH/x86_64

For x86_64 Windows targets (that use SEH), _LIBUNWIND_CURSOR_SIZE
is 204; this fixes corruption in test cases that include libunwind.h
without manually defining _LIBUNWIND_IS_NATIVE_ONLY.

If the libunwind.h header is included without defining
_LIBUNWIND_IS_NATIVE_ONLY (like in the libunwind test cases), the
sizes are set to accommodate the maximum possible cursors and
contexts.

(Alternatively, __libunwind_config.h should be changed to default
to native unwinding unless cross unwinding has been requested.
Cross unwinding isn't implemented as far as I know anyway.)

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

15 months ago[lldb][NFC] Update syntax description for language cplusplus demangle
Alex Langford [Sat, 8 Apr 2023 05:50:45 +0000 (22:50 -0700)]
[lldb][NFC] Update syntax description for language cplusplus demangle

Also added some tests because this is completely untested.

rdar://107780577

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

15 months ago[flang][openacc] Add data operands conversion from FIR
Valentin Clement [Mon, 10 Apr 2023 20:32:37 +0000 (13:32 -0700)]
[flang][openacc] Add data operands conversion from FIR

This patch revive an old PR attempt [1] to perform the
data operands conversion needed for translation to LLVMIR.

This is currently not supporting box/class type since they will
normally not reach this pass when the proposed change in this RFC [2]
are implemented.

[1] https://github.com/flang-compiler/f18-llvm-project/pull/915
[2] https://discourse.llvm.org/t/rfc-openacc-dialect-data-operation-improvements/69825/2

Depends on D147824

Reviewed By: PeteSteinfeld, razvanlupusoru

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

15 months ago[LV] Re-use already computed runtime VF in fixFixedOrderRecurrence.
Florian Hahn [Mon, 10 Apr 2023 20:25:11 +0000 (21:25 +0100)]
[LV] Re-use already computed runtime VF in fixFixedOrderRecurrence.

This was suggested as independent cleanup in D147472.

This removes a redundant runtime VF computation when using scalable
vectors.

15 months ago[LV] Turn check into assert in fixFixedOrderRecurrence (NFCI).
Florian Hahn [Mon, 10 Apr 2023 20:11:40 +0000 (21:11 +0100)]
[LV] Turn check into assert in fixFixedOrderRecurrence (NFCI).

Suggested as independent cleanup in D147567. Either VF or UF need to be
> 1. Note that if the condition would be false, the code below would use
a nullptr and crash.