platform/upstream/llvm.git
18 months ago[flang] Account for .exe suffix in test/Driver/omp-driver-offload.f90.
Slava Zakharin [Tue, 25 Apr 2023 16:45:45 +0000 (09:45 -0700)]
[flang] Account for .exe suffix in test/Driver/omp-driver-offload.f90.

I believe this test started failing pre-commit testing after D148038.
For example:
https://buildkite.com/llvm-project/premerge-checks/builds/148654#0187b72b-7360-4c52-be94-93eefcb269f4
https://buildkite.com/llvm-project/premerge-checks/builds/148642#0187b691-15a7-44c4-ae23-c7e97ec67755

On Windows the .exe suffix is used for clang-offload-packager tool:
"c:\\program files\\llvm\\bin\\clang-offload-packager.exe" ...

At the same time, I believe I have seen this test sporadically fail before,
meaning that the .exe suffix is not added consistently. I am not sure
why this might be happening. I decided just to allow the suffix.

18 months ago[RISCV][NFC] Pull select->binop identities used in lowerSelect to a helper function
Alex Bradbury [Tue, 25 Apr 2023 16:53:12 +0000 (17:53 +0100)]
[RISCV][NFC] Pull select->binop identities used in lowerSelect to a helper function

This will allow reusing the same logic for a select combine.

18 months ago[docs] Update HowToReleaseLLVM documentation.
Tobias Hieta [Tue, 25 Apr 2023 07:54:33 +0000 (09:54 +0200)]
[docs] Update HowToReleaseLLVM documentation.

There was a bunch of references to bugzilla and other old
instructions in there. I have updated it to match the current
reality.

Reviewed By: tstellar

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

18 months ago[AArch64][SME] NFC: Fix comment in enum class
Cullen Rhodes [Tue, 25 Apr 2023 16:45:38 +0000 (16:45 +0000)]
[AArch64][SME] NFC: Fix comment in enum class

18 months ago[flang][runtime] Added Clang CMake modules include path.
Slava Zakharin [Mon, 24 Apr 2023 18:09:57 +0000 (11:09 -0700)]
[flang][runtime] Added Clang CMake modules include path.

Fortran runtime standalone build is broken after D140998
because of the missing CMake modules path. This is a fix.

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

18 months ago[DebugInfo] Treat empty metadata operands the same as undef operands
OCHyams [Tue, 25 Apr 2023 15:21:42 +0000 (16:21 +0100)]
[DebugInfo] Treat empty metadata operands the same as undef operands

A `ValueAsMetadata` may be replaced with nullptr for several reasons including
deleting values and value remapping a use-before-def. In the case of a
`MetadataAsValue` user, `handleChangedOperand` intercepts and replaces the
metadata with an empty tuple (`!{}`).

At the moment, an empty metadata operand in a debug intrinsics signals that it
can be deleted.

Given that we end up with empty metadata operands in circumstances where the
Value has been "lost" the current behaviour can lead to incorrect variable
locations. Instead, we should treat empty metadata as meaning "there is no
location for the variable" (the same as we currently treat undef operands).

This patch changes `isKillLocation` to take this into account.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

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

18 months agoFix codegen for initialization of global atomics
Aaron Ballman [Tue, 25 Apr 2023 15:29:22 +0000 (11:29 -0400)]
Fix codegen for initialization of global atomics

This amends 2e275e24355cb224981f9beb2b026a3169fc7232. That commit added
a null to pointer cast kind when determining whether the expression can
be a valid constant initializer, but failed to update the constant
expression evaluator to perform the evaluation. This commit updates the
constant expression evaluator to handle that cast kind.

18 months ago[DebugInfo] Replace UndefValue with PoisonValue in DIArgList::handleChangedOperand
OCHyams [Tue, 25 Apr 2023 14:39:31 +0000 (15:39 +0100)]
[DebugInfo] Replace UndefValue with PoisonValue in DIArgList::handleChangedOperand

This helps towards the effort to remove UndefValue from LLVM.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: nlopes

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

18 months ago[mlir] ActionTracing: require ASSERTS for debugcounter test
Emilio Cota [Tue, 25 Apr 2023 14:26:02 +0000 (10:26 -0400)]
[mlir] ActionTracing: require ASSERTS for debugcounter test

While at it, fix some typos.

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

18 months ago[AMDGPU] Do not handle _SGPR SMEM instructions in SILoadStoreOptimizer
Jay Foad [Tue, 25 Apr 2023 09:26:46 +0000 (10:26 +0100)]
[AMDGPU] Do not handle _SGPR SMEM instructions in SILoadStoreOptimizer

After D147334 we never select _SGPR forms of SMEM instructions on
subtargets that also support the _SGPR_IMM form, so there is no need to
handle them here.

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

18 months agoDisable private mapping test for AMD GPU due to intermittent fails.
Doru Bercea [Tue, 25 Apr 2023 14:05:07 +0000 (10:05 -0400)]
Disable private mapping test for AMD GPU due to intermittent fails.

18 months ago[mlir][llvm][test] Move exception-related tests to their own file
Victor Perez [Mon, 24 Apr 2023 08:51:11 +0000 (09:51 +0100)]
[mlir][llvm][test] Move exception-related tests to their own file

Move mlir-translate exception-related tests from basic.ll to exception.ll.

Signed-off-by: Victor Perez <victor.perez@codeplay.com>
Differential Revision: https://reviews.llvm.org/D149043

18 months ago[InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0
Zhongyunde [Tue, 25 Apr 2023 13:47:41 +0000 (21:47 +0800)]
[InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0

Use simplifySelectWithICmpEq to handle the implied equalities from the icmp-or,
then both of ICMP_NE and ICMP_EQ will be addressed
  (X | Y) == 0 ?  X : 0 --> 0 (commuted 2 ways)
  (X | Y) != 0 ?  0 : X --> 0 (commuted 2 ways)
Fixes https://github.com/llvm/llvm-project/issues/62263

Reviewed By: nikic, RKSimon
Differential Revision: https://reviews.llvm.org/D148986

18 months agoReapply [InstSimplify] Support all instructions in simplifyWithOpReplaced()
Nikita Popov [Mon, 24 Apr 2023 13:22:20 +0000 (15:22 +0200)]
Reapply [InstSimplify] Support all instructions in simplifyWithOpReplaced()

Relative to the previous attempt, this includes a bailout for phi
nodes, whose arguments might refer to a previous cycle iteration.

We did not hit this before by a fortunate deficiency of the
ConstantFoldInstOperands() API, which doesn't handle phi nodes,
unlike ConstantFoldInstruction().

-----

Instead of hardcoding a few instruction kinds, use the generic
interface now that we have it.

The primary effect of this is that intrinsics are now supported.

It's worth noting that this is still limited in that it does not
support vectors, so we can't remove e.g. existing fshl special
cases.

18 months ago[tests] precommit tests for D148986
Zhongyunde [Tue, 25 Apr 2023 13:39:06 +0000 (21:39 +0800)]
[tests] precommit tests for D148986

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

18 months ago[InstSimplify] Add test for select op replacement in phi (NFC)
Nikita Popov [Tue, 25 Apr 2023 13:40:43 +0000 (15:40 +0200)]
[InstSimplify] Add test for select op replacement in phi (NFC)

18 months agoTableGen: Introduce `!range` operator for half-opened interval
NAKAMURA Takumi [Wed, 1 Mar 2023 22:16:44 +0000 (07:16 +0900)]
TableGen: Introduce `!range` operator for half-opened interval

`!range(a, b)` generates a list `[a,b)`. `a` is optional and `0` by default.

  - `!range(-1, 4)` generates `[-1, 0, 1, 2, 3]`
  - `!range(4)` generates `[0, 1, 2, 3]`
  - `!range(2, 2)` generates `[]<list<int>>`

`!range(list)` is equivalent to `!range(0, !size(list))`.

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

18 months agoReformat
NAKAMURA Takumi [Tue, 25 Apr 2023 13:35:33 +0000 (22:35 +0900)]
Reformat

18 months agoRevert "[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline"
OCHyams [Tue, 25 Apr 2023 13:36:38 +0000 (14:36 +0100)]
Revert "[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline"

This reverts commit 1e6fe677f8aa98518e05218affa16e468819f5ed (D140900).

Buildbot: https://lab.llvm.org/buildbot/#/builders/196/builds/29937

18 months ago[LoopVectorize] Convert test to opaque pointers (NFC)
Nikita Popov [Tue, 25 Apr 2023 13:20:36 +0000 (15:20 +0200)]
[LoopVectorize] Convert test to opaque pointers (NFC)

18 months ago[DebugInfo][CSInfo] Avoid crash when defining super-regs
Jeremy Morse [Tue, 25 Apr 2023 13:04:41 +0000 (14:04 +0100)]
[DebugInfo][CSInfo] Avoid crash when defining super-regs

In rare situations involving AVX intrinsics, it seems LLVM can be coaxed
into generating copies to arguments that look like this:

    $xmm0 = VMOVAPSrr $xmm1, implicit-def $ymm0
    CALL64 @something ymm0

This particular form of copy implicitly zeros the upper lanes of ymm0,
hence there's an implicit-def for the register in the copy. The X86
implementation of describeLoadedValue doesn't attempt to describe this sort
of copy which causes the generic implementation in
TargetInstrInfo::describeLoadedValue to fire an assertion saying it
expected the target hook to handle it.

Play it safe in the generic implementation and return the "no location /
value" return value, rather than asserting.

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

18 months ago[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline
OCHyams [Tue, 25 Apr 2023 10:24:30 +0000 (11:24 +0100)]
[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline

This improves the readability of debugging intrinsics. Instead of:

    call void @llvm.dbg.value(metadata !2, ...)
    !2 = !{}

We will see:

    call void @llvm.dbg.value(metadata !{}, ...)
    !2 = !{}

Note that we still get a numbered metadata entry for the node even if it's not
used elsewhere. This is to avoid adding more context to the print functions.

This is already legal IR - LLVM can parse and understand it - so there is no
need to update the parser.

The next patches in this stack will make such empty metadata operands more
common and semantically important.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

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

18 months ago[MC] Eagerly skip zero-sized .fill fragments
Benjamin Kramer [Tue, 25 Apr 2023 12:57:09 +0000 (14:57 +0200)]
[MC] Eagerly skip zero-sized .fill fragments

This doesn't change the output in any way, but we have a bunch of
emitFill for padding. When emitting an array of floats we'd end up with

DataFragment float1
FillFragment 0
DataFragment float2
FillFragment 0
... and so on

We never actually emit anything for those fills, neither in asm nor obj
emission mode, they just consume RAM for no reason.

18 months ago[AMDGPU] Move GCN-specific stuff out of AMDGPUISelLowering. NFC.
Jay Foad [Tue, 25 Apr 2023 11:07:00 +0000 (12:07 +0100)]
[AMDGPU] Move GCN-specific stuff out of AMDGPUISelLowering. NFC.

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

18 months ago[flang][hlfir] inline hlfir.transpose as hlfir.elemental
Tom Eccles [Tue, 25 Apr 2023 12:24:46 +0000 (12:24 +0000)]
[flang][hlfir] inline hlfir.transpose as hlfir.elemental

Inlining as a hlfir.elemental will allow the transpose to be inlined
into subsequent operations in some cases. For example,

y = TRANSPOSE(x)
z = y * 2

Will operate in a single loop without creating a temporary for the
TRANSPOSE (unlike the runtime call, which always allocates).

This is in a new SimplifyHLFIRIntriniscs pass. The intention is that some
day that pass might replace the FIR SimplifyIntrinsics pass.

Depends On: D149060

Reviewed By: jeanPerier, vzakhari

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

18 months ago[flang][hlfir] get constant extents when possible
Tom Eccles [Tue, 25 Apr 2023 12:24:08 +0000 (12:24 +0000)]
[flang][hlfir] get constant extents when possible

If we know the extent at compile time, it is better to generate an
arith.constant than hlfir.get_extent. This gives more information earlier
in compilation (before hflir.get_extent is lowered).

Reviewed By: jeanPerier

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

18 months ago[bazel] update build for MLIR test for c8d1388e6c8bd57299d5801f170719218f735c4c
Mikhail Goncharov [Tue, 25 Apr 2023 12:37:23 +0000 (14:37 +0200)]
[bazel] update build for MLIR test for c8d1388e6c8bd57299d5801f170719218f735c4c

18 months ago[SCEV] Regenerate test checks (NFC)
Nikita Popov [Tue, 25 Apr 2023 12:25:57 +0000 (14:25 +0200)]
[SCEV] Regenerate test checks (NFC)

I was very confused by this change while working on a patch --
turns out that it's pre-existing, and we currently just match the
"1" part of "13".

18 months ago[MergeICmps] Adapt to non-eq comparisons, bugfix
Zhongyunde [Tue, 25 Apr 2023 11:36:12 +0000 (19:36 +0800)]
[MergeICmps] Adapt to non-eq comparisons, bugfix

Fix the last runtime issue as some sequent comparisons need be spilted.
For the origin equal comparisons chain, the new spilted Icmp chain will
still be end with equal, while for the new not-equal comparisons chain,
the new spilted Icmp chain will still be end with equal, so should address
this carefully, see detail wih case partial_sequent_ne

Thanks for @aeubanks, @glandium and @ayzhao report the runtime issue
and carefully examine.
Fix https://github.com/llvm/llvm-project/issues/59740.

Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141188

18 months ago[RISCV][NFC] Fix typo in comment in RISCVISelLowering
Alex Bradbury [Tue, 25 Apr 2023 11:38:04 +0000 (12:38 +0100)]
[RISCV][NFC] Fix typo in comment in RISCVISelLowering

SELECT_CC is expanded to SETT and SELECT.

18 months ago[compiler-rt][test] Add `--large-address-aware` link flag for MinGW
Alvin Wong [Sat, 22 Apr 2023 14:38:53 +0000 (22:38 +0800)]
[compiler-rt][test] Add `--large-address-aware` link flag for MinGW

The interception tests rely on the test binary being large address
aware. This has already been set for MSVC builds. Now we do the same for
MinGW.

This fixes the interception unit tests for i686-w64-windows-gnu target.

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

18 months ago[compiler-rt][asan] Add report on intercept fail to more places
Alvin Wong [Sat, 22 Apr 2023 11:33:53 +0000 (19:33 +0800)]
[compiler-rt][asan] Add report on intercept fail to more places

Use `ASAN_INTERCEPT_FUNC` instead of `INTERCEPT_FUNCTION` so it checks
the return value and reports a message if verbosity >= 1.

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

18 months ago[clangd] Add support TextDocumentEdit.
Haojian Wu [Wed, 19 Apr 2023 21:54:22 +0000 (23:54 +0200)]
[clangd] Add support TextDocumentEdit.

This is an initial patch to add TextDocumentEdit (versioned edits) support in
clangd, the scope is minimal:

- add and extend the corresponding protocol structures
- propagate the documentChanges for diagnostic codeactions (our motivated case)

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

18 months ago[LoopReroll] Convert tests to opaque pointers (NFC)
Nikita Popov [Tue, 25 Apr 2023 10:55:36 +0000 (12:55 +0200)]
[LoopReroll] Convert tests to opaque pointers (NFC)

18 months ago[LoopReroll] Regenerate test checks (NFC)
Nikita Popov [Tue, 25 Apr 2023 10:55:21 +0000 (12:55 +0200)]
[LoopReroll] Regenerate test checks (NFC)

18 months ago[SCEV] Support sub in and negative constants willNotOverflow
Max Kazantsev [Tue, 25 Apr 2023 09:40:37 +0000 (16:40 +0700)]
[SCEV] Support sub in and negative constants willNotOverflow

This lifts two TODOs from this function, allowing us to prove
no-overflow whether it happens through max int (up) or through
min int (down) for both and and sub.

Differential Revision: https://reviews.llvm.org/D148618
Reviewed By: dmakogon

18 months ago[LICM] Add additional "free instruction" tests (NFC)
Nikita Popov [Tue, 25 Apr 2023 08:51:25 +0000 (10:51 +0200)]
[LICM] Add additional "free instruction" tests (NFC)

18 months ago[SLP] Deduplicate loads subkey generator. NFCI
Luke Lau [Fri, 21 Apr 2023 13:50:35 +0000 (14:50 +0100)]
[SLP] Deduplicate loads subkey generator. NFCI

Reviewed By: ABataev

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

18 months ago[RISCV] Fix interleave crash on unary interleaves
Luke Lau [Tue, 18 Apr 2023 17:29:20 +0000 (18:29 +0100)]
[RISCV] Fix interleave crash on unary interleaves

We were crashing when lowering interleave shuffles like
(shuffle <0,3,1,4>, x:v4i8, y:v4i8)
Where it was technically an unary shuffle (both EvenSrc and OddSrc point
to the first operand), but the resulting extract_subvectors were out of
bounds.
This checks to make sure that the vectors being extracted are within
range.

Reviewed By: craig.topper

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

18 months ago[LICM] Remove redundant test (NFC)
Nikita Popov [Tue, 25 Apr 2023 08:07:30 +0000 (10:07 +0200)]
[LICM] Remove redundant test (NFC)

Drop the separate opaque pointers test now that the original one
uses opaque pointers as well.

18 months ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Tue, 25 Apr 2023 08:06:39 +0000 (10:06 +0200)]
[LICM] Regenerate test checks (NFC)

18 months ago[LICM] Only forget loop/block dispositions
Nikita Popov [Tue, 25 Apr 2023 07:57:39 +0000 (09:57 +0200)]
[LICM] Only forget loop/block dispositions

As we are moving the instruction without changing its value, it
is sufficient to only invalidate the loop/block dispositions.
This is the same we do in LoopSink.

18 months ago[mlir][ArmSME] Add tests for Streaming SVE
Cullen Rhodes [Tue, 25 Apr 2023 07:38:09 +0000 (07:38 +0000)]
[mlir][ArmSME] Add tests for Streaming SVE

This patch adds a couple of tests for targeting Arm Streaming SVE (SSVE)
mode, part of the Arm Scalable Matrix Extension (SME).

SSVE is enabled in the backend at the function boundary by specifying
the `aarch64_pstate_sm_enabled` attribute, as documented here [1]. SSVE
can be targeted from MLIR by specifying this in the passthrough
attributes [2] and compiling with

  -mattr=+sme,+sve -force-streaming-compatible-sve

The passthrough will propagate to the backend where `smstart/smstop`
will be emitted around the call to the SSVE function.

The set of legal instructions changes in SSVE,
`-force-streaming-compatible-sve` avoids the use of NEON entirely and
instead lowers to (streaming-compatible) SVE. The behaviour this flag
predicates will be hooked up to the function attribute in the future
such that simply specifying this (should) lead to correct
code-generation.

Two tests are added:

  * A basic LLVMIR test verifying the attribute is passed through.
  * An integration test calling a SSVE function.

The integration test can be run with QEMU.

[1] https://llvm.org/docs/AArch64SME.html
[2] https://mlir.llvm.org/docs/Dialects/LLVM/#attribute-pass-through

Reviewed By: awarzynski, aartbik

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

18 months ago[ValueMapper] allow mapping ConstantTargetNone to its layout type
Bing1 Yu [Tue, 25 Apr 2023 07:47:33 +0000 (15:47 +0800)]
[ValueMapper] allow mapping ConstantTargetNone to its layout type

zeroinitializer is allowed for spirv TargetExtType.
This PR allows ValueMapper to map TargetExtType ConstantTargetNone to '0' constant of its layout type.

Reviewed By: jcranmer-intel

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

18 months ago[MLIR][doc] Fix the [TOC] tag in two doc
Mehdi Amini [Tue, 25 Apr 2023 07:08:20 +0000 (00:08 -0700)]
[MLIR][doc] Fix the [TOC] tag in two doc

Somehow it was escaped in these documents.

18 months ago[flang][runtime] Fix padding in CHARACTER(4) assignments.
Jean Perier [Tue, 25 Apr 2023 07:05:37 +0000 (09:05 +0200)]
[flang][runtime] Fix padding in CHARACTER(4) assignments.

One piece of pointer arithmetic was adding the number of bytes instead
of the number of characters. This caused failures in CHARACTER(KIND>1)
that required padding.
This was caught using HLFIR that currently uses the runtime for array
assignment where the current lowering does everything inline.

Reviewed By: vzakhari, klausler

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

18 months ago[flang][hlfir] Support fir.declare in AbstractResult pass
Jean Perier [Tue, 25 Apr 2023 07:03:55 +0000 (09:03 +0200)]
[flang][hlfir] Support fir.declare in AbstractResult pass

The AbstractResult pass replaces allocation of function result on the callee
side per an extra argument so that the allocation of the result can be
done on the caller stack.
It looks for the result allocation from the fir.return op, so it needs
to handle (in a transparent way) a fir.declare in the chain between the
allocation and the fir.return.

Reviewed By: vzakhari, clementval

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

18 months ago[flang][hlfir] Lower NULL(MOLD) to a variable
Jean Perier [Tue, 25 Apr 2023 07:02:18 +0000 (09:02 +0200)]
[flang][hlfir] Lower NULL(MOLD) to a variable

HLFIR lowering promotes intrinsic results lowered in memory to
hlfir.expr to underline their read-only aspect once they are created.
NULL(MOLD) should not be promoted to an hlfir.expr, it is the NULL
variable (we need to see it as an address).

Reviewed By: clementval

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

18 months ago[clang][Interp] Fix zero-init of float and pointer arrays
Timm Bäder [Mon, 24 Apr 2023 12:30:54 +0000 (14:30 +0200)]
[clang][Interp] Fix zero-init of float and pointer arrays

Our Zero opcode only exists for integer types. Use
visitZeroInitializer() here as well so it works for floats and pointers.

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

18 months ago[libc] Fix typos in documentation
Kazu Hirata [Tue, 25 Apr 2023 06:31:48 +0000 (23:31 -0700)]
[libc] Fix typos in documentation

18 months ago[Driver] Remove no-op -frewrite-map-file=
Fangrui Song [Tue, 25 Apr 2023 06:18:59 +0000 (23:18 -0700)]
[Driver] Remove no-op -frewrite-map-file=

This option has been a no-op since D99707.

18 months ago[clang] Modernize SkipBodyInfo (NFC)
Kazu Hirata [Tue, 25 Apr 2023 06:15:55 +0000 (23:15 -0700)]
[clang] Modernize SkipBodyInfo (NFC)

18 months ago[RISCV][NFC] skip non-RISCV target test riscv32-zihintntl.c
Piyou Chen [Tue, 25 Apr 2023 06:09:56 +0000 (23:09 -0700)]
[RISCV][NFC] skip non-RISCV target test riscv32-zihintntl.c

Reviewed By: kito-cheng

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

18 months ago[clang][Interp] PointerToBoolean casts
Timm Bäder [Sat, 22 Apr 2023 04:40:54 +0000 (06:40 +0200)]
[clang][Interp] PointerToBoolean casts

Just emit e != nullptr for these.

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

18 months ago[clang] Add test for CWG1821
Vlad Serebrennikov [Tue, 25 Apr 2023 06:03:14 +0000 (09:03 +0300)]
[clang] Add test for CWG1821

[[https://wg21.link/p1787 | P1787]]: My clarification in [[ http://lists.isocpp.org/core/2019/06/6614.php | “Where can namespace-scope functions and variables be redeclared?” ]] is applied, resolving CWG1821.
Wording: (If the declaration is not a friend declaration:) If the id-expression in a declarator-id is a qualified-id Q, let S be its lookup context; the declaration shall inhabit a namespace scope. ([dcl.meaning]/1)

Reviewed By: shafik, #clang-language-wg

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

18 months ago[Driver] Simplify handling of -mabi=vec-default -mabi=vec-extabi
Fangrui Song [Tue, 25 Apr 2023 05:59:54 +0000 (22:59 -0700)]
[Driver] Simplify handling of -mabi=vec-default -mabi=vec-extabi

And fix a minor issue that -mabi=vec-extabi -mabi=vec-default should not pass
"-bplugin_opt:-vec-extabi" to ld.

18 months agoRevert "Remove code only needed to detect a pre-4.0 API break."
Owen Anderson [Tue, 25 Apr 2023 05:52:18 +0000 (22:52 -0700)]
Revert "Remove code only needed to detect a pre-4.0 API break."

This reverts commit 17a3fbf2a3683f862de52e0058110eb8b356be56
due to build failures in llvm/unittests/ADT/IListTest.cpp

18 months agoRemove code only needed to detect a pre-4.0 API break.
Owen Anderson [Tue, 25 Apr 2023 05:23:38 +0000 (22:23 -0700)]
Remove code only needed to detect a pre-4.0 API break.

Reviewed By: dexonsmith

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

18 months ago[clang][AST][NFC] Turn some single-line comments into doc comments
Timm Bäder [Sun, 23 Apr 2023 08:08:44 +0000 (10:08 +0200)]
[clang][AST][NFC] Turn some single-line comments into doc comments

18 months ago[bazel][mlir] Fold :Observers and :BreakpointManagers into :Debug
Emilio Cota [Tue, 25 Apr 2023 04:53:03 +0000 (00:53 -0400)]
[bazel][mlir] Fold :Observers and :BreakpointManagers into :Debug

To avoid circular deps.

While at it, add missing dep on CAPIIR.

18 months ago[flang] Feature list plugin
Ethan Luis McDonough [Tue, 25 Apr 2023 04:35:19 +0000 (23:35 -0500)]
[flang] Feature list plugin

Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

Updated to fix build issues.

Reviewed By: jdoerfert

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

18 months ago[RISCV] Fix -Wdeprecated-declarations in RISCVInstrInfo.cpp (NFC)
Jie Fu [Tue, 25 Apr 2023 03:54:16 +0000 (11:54 +0800)]
[RISCV] Fix -Wdeprecated-declarations in RISCVInstrInfo.cpp (NFC)

/Users/jiefu/llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:2636:10: error: 'makeArrayRef<std::pair<llvm::MachineMemOperand::Flags, const char *>, 2UL>' is deprecated: Use deduction guide instead [-Werror,-Wdeprecated-declarations]
  return makeArrayRef(TargetFlags);
         ^~~~~~~~~~~~
         ArrayRef
/Users/jiefu/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:572:3: note: 'makeArrayRef<std::pair<llvm::MachineMemOperand::Flags, const char *>, 2UL>' has been explicitly marked deprecated here
  LLVM_DEPRECATED("Use deduction guide instead", "ArrayRef")
  ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/Compiler.h:143:50: note: expanded from macro 'LLVM_DEPRECATED'
                                                 ^
1 error generated.

18 months ago[mlir] detensorize: don't accidentally convert function entry blocks
Alex Zinenko [Sat, 22 Apr 2023 08:57:10 +0000 (08:57 +0000)]
[mlir] detensorize: don't accidentally convert function entry blocks

In the Linalg detensorize pass, dialect conversion could accidentally
trigger signature conversion of the function entry block after inlining
the body of a Linalg generic into it. Such a conversion is not desirable
because it would break the internal validity of the function op, that is
futhermore not supposed to be detensorized at the boundary. Mitigate
this by creating a dummy (empty) entry block so Linalg operations are
never inlined into it and the conversion is never triggered.

Closes #62249.

Reviewed By: silvas

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

18 months ago[gn build] Port 8a3950510f81
LLVM GN Syncbot [Tue, 25 Apr 2023 03:20:33 +0000 (03:20 +0000)]
[gn build] Port 8a3950510f81

18 months ago[RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain
Piyou Chen [Tue, 25 Apr 2023 02:58:38 +0000 (19:58 -0700)]
[RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain

This commit implements the two NTLH intrinsic functions.

```
type __riscv_ntl_load (type *ptr, int domain);
void __riscv_ntl_store (type *ptr, type val, int domain);

```

```
enum {
  __RISCV_NTLH_INNERMOST_PRIVATE = 2,
  __RISCV_NTLH_ALL_PRIVATE,
  __RISCV_NTLH_INNERMOST_SHARED,
  __RISCV_NTLH_ALL
};
```

We encode the non-temporal domain into MachineMemOperand flags.

1. Create the RISC-V built-in function with custom semantic checking.
2. Assume the domain argument is a compile time constant,
and make it as LLVM IR metadata (nontemp_node).
3. Encode domain value as two bits MachineMemOperand TargetMMOflag.
4. According to MachineMemOperand TargetMMOflag, select corrsponding ntlh instruction.

Currently, it supports scalar type and fixed-length vector type.

Reviewed By: craig.topper

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

18 months ago-Wframe-larger-than=: improve error with an invalid argument
Fangrui Song [Tue, 25 Apr 2023 03:11:21 +0000 (20:11 -0700)]
-Wframe-larger-than=: improve error with an invalid argument

Remove a FIXME. For simplicity, the error message for the missing argument case
has changed from err_drv_missing_argument to err_drv_invalid_argument_to_option,
which should be fine.

18 months agoValueTracking: Add ordered negative handling for fmul to computeKnownFPClass
Matt Arsenault [Mon, 17 Apr 2023 19:01:11 +0000 (15:01 -0400)]
ValueTracking: Add ordered negative handling for fmul to computeKnownFPClass

Port from the existing handling in cannotBeOrderedLessThanZero

18 months agoValueTracking: Handle fptrunc_round in computeKnownFPClass
Matt Arsenault [Sun, 9 Apr 2023 11:16:56 +0000 (07:16 -0400)]
ValueTracking: Handle fptrunc_round in computeKnownFPClass

18 months ago[bazel][mlir] Build Debug/BreakpointManagers only from a single target
Emilio Cota [Tue, 25 Apr 2023 02:11:22 +0000 (22:11 -0400)]
[bazel][mlir] Build Debug/BreakpointManagers only from a single target

When writing 5f2b0892d "[bazel][mlir] BreakpointManager fixes for 7f069f5",
I did not notice that 17c6de3f1 "[bazel] Fix bazel build for 7f069f5ef.."
had added Debug/BreakpointManagers globs to the Debug target. But these
are already being built in the "BreakpointManagers" target; remove them
from "Debug".

18 months ago[RISCV] Ensure extract_vector_elt has a single use in combineBinOpToReduce.
Craig Topper [Tue, 25 Apr 2023 01:11:05 +0000 (18:11 -0700)]
[RISCV] Ensure extract_vector_elt has a single use in combineBinOpToReduce.

Without this, the original reduction will not be removed and we'll
end up with a second reduction. Reductions are expensive operations so
we should avoid that.

18 months ago[RISCV] Add test case showing duplicated reduction due to missing one use check. NFC
Craig Topper [Tue, 25 Apr 2023 01:09:14 +0000 (18:09 -0700)]
[RISCV] Add test case showing duplicated reduction due to missing one use check. NFC

We don't check that the extract_vector_elt has one use in combineBinOpToReduce.

18 months ago[mlir][tosa] Fix `tosa.reshape` folder for quantized constants
Robert Suderman [Tue, 25 Apr 2023 00:55:47 +0000 (00:55 +0000)]
[mlir][tosa] Fix `tosa.reshape` folder for quantized constants

It is possible for `tosa.const` to have a quantized return type.
In these cases we need to retain the expected result type to avoid
potential type mismatches further in the model.

Reviewed By: cota

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

18 months ago[RISCV] Strengthen INSERT_SUBVECTOR check in combineBinOpToReduce.
Craig Topper [Tue, 25 Apr 2023 00:30:35 +0000 (17:30 -0700)]
[RISCV] Strengthen INSERT_SUBVECTOR check in combineBinOpToReduce.

It's not enough for the vector we're inserting into to be undef.
We also need to be inserting into the lowest subvector.

Spotted by inspection while trying to figure out why this doesn't
work for vp.reduce.fadd.

18 months ago[gn build] Port d45fae601067
LLVM GN Syncbot [Mon, 24 Apr 2023 23:56:11 +0000 (23:56 +0000)]
[gn build] Port d45fae601067

18 months agoMigrate `IIT_Info` into `Intrinsics.td`
NAKAMURA Takumi [Wed, 8 Mar 2023 22:25:11 +0000 (07:25 +0900)]
Migrate `IIT_Info` into `Intrinsics.td`

  - Define `IIT_Info` in `Intrinsics.td`
  - Implement `EmitIITInfo` in `IntrinsicEmitter.cpp`
  - Use generated `IIT_Info` in `Function.cpp`

Depends on D145873 and D146179

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

18 months agoFully generate `MachineValueType.h`
NAKAMURA Takumi [Sun, 26 Mar 2023 07:39:01 +0000 (16:39 +0900)]
Fully generate `MachineValueType.h`

Part of D146914

18 months agoValueTypes.td: Reorganize ValueType
NAKAMURA Takumi [Wed, 8 Mar 2023 16:20:57 +0000 (01:20 +0900)]
ValueTypes.td: Reorganize ValueType

Introduce VTAny as `isOverloaded = true`. ValueType.isOverloaded` is used for;

  - Define `iPTRAny`, `vAny`, `fAny`, and `Any`
  - Reflect `ValueType.isOverloaded` to `LLVMType.isAny` in `Intrinsics.td`
  - (Planninig) Reflect the condition to `MVT::isOverloaded()`

Introduce some fields in `ValueType`

  - LLVMName
  - isInteger
  - isFP
  - isVector
  - isScalable
  - nElem
  - ElementType

Introduce `VTVec<int nelem, ValueType elt, int value>` to represent
the element type. VTVec.Size may be calculated by `!mul(nelem, elt.Size)`.

Introduce `list<ValueType> ValueTypes` as convention for lookup.

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

18 months agoValueTypes.td: Introduce VTAny as `isOverloaded = true`
NAKAMURA Takumi [Wed, 8 Mar 2023 15:37:00 +0000 (00:37 +0900)]
ValueTypes.td: Introduce VTAny as `isOverloaded = true`

`ValueType.isOverloaded` is used for;

  - Define `iPTRAny`, `vAny`, `fAny`, and `Any`
  - Reflect `ValueType.isOverloaded` to `LLVMType.isAny` in `Intrinsics.td`
  - (Planninig) Reflect the condition to `MVT::isOverloaded()`

Part of D146179

18 months agoSupportTests/MachineValueType.h: Catch up llvmorg-17-init-8340-gb68b94f6f40b
NAKAMURA Takumi [Mon, 24 Apr 2023 22:07:19 +0000 (07:07 +0900)]
SupportTests/MachineValueType.h: Catch up llvmorg-17-init-8340-gb68b94f6f40b

18 months agoMove CodeGen/LowLevelType => CodeGen/LowLevelTypeUtils
NAKAMURA Takumi [Sun, 23 Apr 2023 12:46:09 +0000 (21:46 +0900)]
Move CodeGen/LowLevelType => CodeGen/LowLevelTypeUtils

Before restoring `CodeGen/LowLevelType`, rename this to `LowLevelTypeUtils`.

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

18 months agoReland "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code...
MalavikaSamak [Mon, 24 Apr 2023 23:49:13 +0000 (16:49 -0700)]
Reland "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros"

This reverts commit 84ec1f7725d4f4575474b59467e598d7c5528a4e.

18 months agoRevert "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code...
MalavikaSamak [Mon, 24 Apr 2023 23:48:14 +0000 (16:48 -0700)]
Revert "[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros"

This reverts commit 9bd0db80784e30d40a4a65f1b47109c833f05b54.

18 months ago[libc][Obvious] Add NO_RUN_POSTBUILD to sqrtf exhaustive test.
Siva Chandra Reddy [Mon, 24 Apr 2023 23:40:23 +0000 (23:40 +0000)]
[libc][Obvious] Add NO_RUN_POSTBUILD to sqrtf exhaustive test.

The bots are timing out because they are trying to run this test.

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

18 months ago[clang] Fix -Wimplicit-fallthrough in UnsafeBufferUsage.cpp [NFC]
Jie Fu [Mon, 24 Apr 2023 23:34:39 +0000 (07:34 +0800)]
[clang] Fix -Wimplicit-fallthrough in UnsafeBufferUsage.cpp [NFC]

/Users/jiefu/llvm-project/clang/lib/Analysis/UnsafeBufferUsage.cpp:1272:5: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case Strategy::Kind::Wontfix:
    ^
/Users/jiefu/llvm-project/clang/lib/Analysis/UnsafeBufferUsage.cpp:1272:5: note: insert 'LLVM_FALLTHROUGH;' to silence this warning
    case Strategy::Kind::Wontfix:
    ^
    LLVM_FALLTHROUGH;
/Users/jiefu/llvm-project/clang/lib/Analysis/UnsafeBufferUsage.cpp:1272:5: note: insert 'break;' to avoid fall-through
    case Strategy::Kind::Wontfix:
    ^
    break;
1 error generated.

18 months ago[libc][Obvious] Enable hermetic tests only under full build.
Siva Chandra Reddy [Mon, 24 Apr 2023 23:07:22 +0000 (23:07 +0000)]
[libc][Obvious] Enable hermetic tests only under full build.

Reviewed By: jhuber6

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

18 months agoMove DBG_VALUE's that depend on loads to after a
Shubham Sandeep Rastogi [Tue, 18 Apr 2023 21:09:12 +0000 (14:09 -0700)]
Move DBG_VALUE's that depend on loads to after a
load if the load is moved due to the pre register allocation ld/st
optimization pass

The issue here is that there can be a scenario where debug information
is lost because of the pre register allocation load store optimization
pass, where a load who's result describes the debug infomation for a
local variable gets moved below the load and that causes the debug
information for that load to get lost.

Example:

Before the Pre Register Allocation Load Store Pass
inst_a
%2 = ld ...
inst_b
DBG_VALUE %2, "x", ...
%3 = ld ...

After the Pass:
inst_a
inst_b
DBG_VALUE %2, "x", ...
%2 = ld ...
%3 = ld ...

The load has now been moved to after the DBG_VAL that uses its result
and the debug info for "x" has been lost. What we want is:

inst_a
inst_b
%2 = ld ...
DBG_VALUE %2, "x", ...
%3 = ld ...

Which is what this patch addresses

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

18 months ago[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within...
MalavikaSamak [Fri, 21 Apr 2023 17:55:01 +0000 (10:55 -0700)]
[-Wunsafe-buffer-usage] Bug fix: Handles the assertion violations for code within macros

When macros get expanded, the source location for the expanded code received by the Fixable
gadgets is invalid. We do not want to emit fixits for macro expanded code and it currently
crashes the analysis. This patch fixes the assertion violations that were introduced for
handling code with such invalid locations.

Reviewed by: NoQ, ziqingluo-90, jkorous

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

18 months ago[libc] Add rule named `add_libc_hermetic_test` which adds a hermetic test.
Siva Chandra Reddy [Tue, 18 Apr 2023 22:50:26 +0000 (22:50 +0000)]
[libc] Add rule named `add_libc_hermetic_test` which adds a hermetic test.

A convenience wrapper name `add_libc_test` is also added which adds both
a unit test and a hermetic test. The ctype tests have been switched over
to use add_libc_test.

Reviewed By: jhuber6

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

18 months ago[libc] Run all unit tests, irrespective of whether they belong to a test suite.
Siva Chandra Reddy [Thu, 20 Apr 2023 07:18:43 +0000 (07:18 +0000)]
[libc] Run all unit tests, irrespective of whether they belong to a test suite.

Previously, only those unit tests which belonged to a suite were run as
part of libc-unit-tests. It meant that unit tests not part of any suite
were not being tested. This change makes all unit tests run as part of
libc-unit-tests. The convenience function to add a libc unit test suite
has been removed and add_custom_target is used in its place. One of the
bit-rotting test has along been fixed. Math exhaustive and differential
tests are skipped under full build.

Reviewed By: michaelrj

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

18 months ago[NVPTX] Unforce minimum alignment of 4 for byval arguments of device-side functions.
Pavel Kopyl [Sat, 22 Apr 2023 00:52:04 +0000 (02:52 +0200)]
[NVPTX] Unforce minimum alignment of 4 for byval arguments of device-side functions.

Minimum alignment of 4 for byval arguments was forced to workaround
a bug in old versions of ptxas. Details: https://reviews.llvm.org/D22428.
Recent ptxas versions (> 9.0) do not seem to have this bug, so alignment
requirement was relaxed. To force again minimum alignment of 4, use
'-force-min-byval-param-align' option.

18 months agoFix MLIR build when shared library mode is enabled
Mehdi Amini [Mon, 24 Apr 2023 22:13:15 +0000 (15:13 -0700)]
Fix MLIR build when shared library mode is enabled

18 months ago[bazel][mlir] BreakpointManager fixes for 7f069f5ef4fe
Emilio Cota [Mon, 24 Apr 2023 22:00:35 +0000 (18:00 -0400)]
[bazel][mlir] BreakpointManager fixes for 7f069f5ef4fe

18 months ago[libc][Obvious] Add include.stdlib as missing dep for CPP.string.
Siva Chandra Reddy [Mon, 24 Apr 2023 16:39:52 +0000 (16:39 +0000)]
[libc][Obvious] Add include.stdlib as missing dep for CPP.string.

string.h includes stdlib.h to get free and realloc. This change
adds the missing dep on stdlib.h.

Reviewed By: jhuber6

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

18 months ago[NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY
Manna, Soumi [Mon, 24 Apr 2023 21:16:32 +0000 (14:16 -0700)]
[NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY

Reported by Coverity:
AUTO_CAUSES_COPY
Unnecessary object copies can affect performance.

1. Inside "ExtractAPIVisitor.h" file, in clang::extractapi::impl::ExtractAPIVisitorBase<<unnamed>::BatchExtractAPIVisitor>::VisitFunctionDecl(clang::FunctionDecl const *): Using the auto keyword without an & causes the copy of an object of type DynTypedNode.

2. Inside "NeonEmitter.cpp" file, in <unnamed>::Intrinsic::Intrinsic(llvm::Record *, llvm::StringRef, llvm::StringRef, <unnamed>::TypeSpec, <unnamed>::TypeSpec, <unnamed>::ClassKind, llvm::ListInit *, <unnamed>::NeonEmitter &, llvm::StringRef, llvm::StringRef, bool, bool): Using the auto keyword without an & causes the copy of an object of type Type.

3. Inside "MicrosoftCXXABI.cpp" file, in <unnamed>::MSRTTIBuilder::getClassHierarchyDescriptor(): Using the auto keyword without an & causes the copy of an object of type MSRTTIClass.

4. Inside "CGGPUBuiltin.cpp" file, in clang::CodeGen::CodeGenFunction::EmitAMDGPUDevicePrintfCallExpr(clang::CallExpr const *): Using the auto keyword without an & causes the copy of an object of type CallArg.

5. Inside "SemaDeclAttr.cpp" file, in threadSafetyCheckIsSmartPointer(clang::Sema &, clang::RecordType const *): Using the auto keyword without an & causes the copy of an object of type CXXBaseSpecifier.

6. Inside "ComputeDependence.cpp" file, in clang::computeDependence(clang::DesignatedInitExpr *): Using the auto keyword without an & causes the copy of an object of type Designator.

7. Inside "Format.cpp" file, In clang::format::affectsRange(llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int): Using the auto keyword without an & causes the copy of an object of type Range.

Reviewed By: tahonermann

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

18 months ago[MLIR] Fix build, obivous typos in cca510640
Mehdi Amini [Mon, 24 Apr 2023 21:41:23 +0000 (14:41 -0700)]
[MLIR] Fix build, obivous typos in cca510640

18 months ago[MLIR][doc] Minor fixes the Action documentation
Mehdi Amini [Mon, 24 Apr 2023 21:38:58 +0000 (14:38 -0700)]
[MLIR][doc] Minor fixes the Action documentation

Fix some reviews comments missed when pushing the initial version of the doc.

18 months agoRemove deprecated `preloadDialectInContext` flag for MlirOptMain that has been deprec...
Mehdi Amini [Mon, 24 Apr 2023 05:24:52 +0000 (22:24 -0700)]
Remove deprecated `preloadDialectInContext` flag for MlirOptMain that has been deprecated for 2 years

See https://discourse.llvm.org/t/psa-preloaddialectincontext-has-been-deprecated-for-1y-and-will-be-removed/68992

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

18 months agoRemove deprecated entry point for MlirOptMain
Mehdi Amini [Mon, 24 Apr 2023 05:15:32 +0000 (22:15 -0700)]
Remove deprecated entry point for MlirOptMain

See: https://discourse.llvm.org/t/psa-migrating-mlir-opt-like-tools-to-use-mliroptmainconfig/68991

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

18 months agoRefactor the mlir-opt command line options related to debugging in a helper
Mehdi Amini [Sun, 26 Feb 2023 06:01:18 +0000 (01:01 -0500)]
Refactor the mlir-opt command line options related to debugging in a helper

This makes it reusable across various tooling and reduces the amount of
boilerplate needed.

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

18 months agoAdd user doc on the website for the Action framework
Mehdi Amini [Sun, 23 Apr 2023 22:55:15 +0000 (16:55 -0600)]
Add user doc on the website for the Action framework

The old DebugAction documentation is deleted: the code in-tree does not
match it anymore.

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