platform/upstream/llvm.git
18 months ago[SLP][NFC]Make adjustExtracts/needToDelay members of ShuffleInstructionBuilder.
Alexey Bataev [Thu, 6 Apr 2023 18:02:10 +0000 (11:02 -0700)]
[SLP][NFC]Make adjustExtracts/needToDelay members of ShuffleInstructionBuilder.

Make adjustExtracts/needToDelay lambdas members of ShuffleInstructionBuilder to allow to overload them later for cost model.

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

18 months ago[LV][NFC] Improve complexity of fixing users of recurrences
Michael Maitland [Mon, 27 Mar 2023 20:14:38 +0000 (13:14 -0700)]
[LV][NFC] Improve complexity of fixing users of recurrences

The original loop has O(MxN) since `is_contained` iterates over
all incoming values. This change makes it so only the phis
which use the value as an incoming value are iterated over so
it is now O(M).

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

18 months agoRevert "Revert "[Modules] Remove unnecessary check when generating name lookup table...
Richard Smith [Thu, 6 Apr 2023 22:22:06 +0000 (15:22 -0700)]
Revert "Revert "[Modules] Remove unnecessary check when generating name lookup table in ASTWriter""

This re-lands commit db987b9589be1eb604fcb74c85b410469e31485f,
previously reverted in commit 1e0709167f5edd330889f51bb203c458bdb5e359,
with a fix for a pre-existing bug in how we write constructor names into
lookup tables that was exposed by that change.

As yet, we've been unable to produce a reduced testcase for this bug,
but we understand the problem: if we write out a lookup table for a
class which has two constructor names, and we only have local lookup
results for one of those constructor names, then we will write out a
lookup table where the "all the constructors" lookup result contains
results for only one of the constructor names.

18 months ago[lldb] Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED
Jonas Devlieghere [Thu, 6 Apr 2023 19:47:14 +0000 (12:47 -0700)]
[lldb] Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED

Add an LLDB_DEPRECATED macro similar to LLVM_DEPRECATED. We cannot
directly reuse the LLVM one, because it's defined in Compiler.h which is
not something we can include in the SB API.

For the SB API, the macro is undef'd if:

  1. We're building the SWIG bindings. We might still want to expose
     deprecated methods to our scripting users.

  2. We're targeting anything older than C++14 as the [[deprecated]]
     attribute was added for C++14 and the SB API can be used by
     projects compiling against an older language version.

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

18 months ago[Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute
Shafik Yaghmour [Thu, 6 Apr 2023 21:40:39 +0000 (14:40 -0700)]
[Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute

There may be cases in which we want to diagnose a type as unavailable but it may
not be complete at the time. Setting MeaningfulToClassTemplateDefinition fixes
this issue.

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

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

18 months ago[lldb] Rename test module.map files to module.modulemap (NFC)
Dave Lee [Thu, 6 Apr 2023 20:50:05 +0000 (13:50 -0700)]
[lldb] Rename test module.map files to module.modulemap (NFC)

The name `module.modulemap` is convention.

> Clang will also search for a file named `module.map`. This behavior is deprecated and
> we plan to eventually remove it.

18 months ago[LV] Move conditional MaskForGaps construction to load case.
Florian Hahn [Thu, 6 Apr 2023 20:16:37 +0000 (21:16 +0100)]
[LV] Move conditional MaskForGaps construction to load case.

Conditionally setting MaskForGaps is only needed for loads. This avoid
re-computing MaskForGaps for stores.

Suggested as independent cleanup in D147467.

18 months agoAdd gpu::HostUnregisterOp
max [Thu, 6 Apr 2023 20:07:12 +0000 (15:07 -0500)]
Add gpu::HostUnregisterOp

Without explicitly unregistering you will get

```
'cuMemHostRegister(ptr, sizeBytes, 0)' failed with 'CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED'
```

in CUDA (for example) after repeated runs (e.g., during benchmarking the same kernel).

Reviewed By: ftynse

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

18 months ago[SLP][NFC]Evaluate FMF for reductions before the loop, no need to
Alexey Bataev [Thu, 6 Apr 2023 18:56:19 +0000 (11:56 -0700)]
[SLP][NFC]Evaluate FMF for reductions before the loop, no need to
reevaluate it.

18 months ago[mlir][math] Update math arith expansions for vectorization
Robert Suderman [Thu, 6 Apr 2023 18:33:29 +0000 (18:33 +0000)]
[mlir][math] Update math arith expansions for vectorization

The math arithmetic expansions do not support vectorized types.
Updated the lowerings so that they support vectorized types. This
includes a different implementation for `math.ctlz` to be a binary
search and not have variable termination time.

Reviewed By: jpienaar, NatashaKnk

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

18 months agoPrecommit test from D147662
Anna Thomas [Thu, 6 Apr 2023 18:35:02 +0000 (14:35 -0400)]
Precommit test from D147662

18 months ago[mlir][arith] Add expansion pattern for ext/trunc of bf16
Robert Suderman [Thu, 6 Apr 2023 18:23:52 +0000 (18:23 +0000)]
[mlir][arith] Add expansion pattern for ext/trunc of bf16

bf16 has a trivial truncation/extension behavior with F32 that
can be described in elementary arith operations. Include some
expansions to efficiently convert including rounding towards
infinity for f32 to bf16 truncation.

Reviewed By: jpienaar

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

18 months ago[M68k] Add subtarget features for M68881/2 FPU
Min-Yih Hsu [Mon, 3 Apr 2023 20:18:17 +0000 (13:18 -0700)]
[M68k] Add subtarget features for M68881/2 FPU

Note that technically both M68000/010 can use M68881, despite the fact
that usually only M68020 and newer ISAs are equipped with M68881/2.
M68040 and newer processors have builtin M68882.

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

18 months ago[libc] Implement strsep
Alex Brachet [Thu, 6 Apr 2023 17:48:28 +0000 (17:48 +0000)]
[libc] Implement strsep

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

18 months ago[lldb] Add an overload to SetModuleLoadAddress that takes an unsigned value
Jonas Devlieghere [Thu, 6 Apr 2023 17:27:06 +0000 (10:27 -0700)]
[lldb] Add an overload to SetModuleLoadAddress that takes an unsigned value

Currently, SBTarget::SetModuleLoadAddress does not accept large slides
needed to load images in high memory. This function should always have
taken an unsigned as the slide, as it immediately passes it to
Target::SetSectionLoadAddress which takes an unsigned.

This patch adds an overload and exposes that to SWIG instead of the
signed variant. I've marked the signed variant as deprecated and added
check that the slide is positive.

rdar://101355155

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

18 months ago[SLP]Fix emission of the masks in shuffles for undefs.
Alexey Bataev [Thu, 6 Apr 2023 13:03:03 +0000 (06:03 -0700)]
[SLP]Fix emission of the masks in shuffles for undefs.

If the value is used in the expression, need to adjust the mask before
applying the mask. Plus, need to fix the analysis of the phi nodes for
reused scalars.

18 months ago[Sema] Populate declarations inside TypeLocs for some invalid types
Ilya Biryukov [Thu, 6 Apr 2023 16:59:45 +0000 (18:59 +0200)]
[Sema] Populate declarations inside TypeLocs for some invalid types

This also reverts 282cae0b9a602267ad7ef622f770066491332a11 as the
particular crash is now handled by the new code.

Before this change Clang would always leave declarations inside the
type-locs as `null` if the declarator had an invalid type. This patch
populates declarations even for invalid types if the structure of the
type and the type-locs match.

There are certain cases that may still cause crashes. These happen when
Clang recovers the type in a way that is not reflected in the
declarator's structure, e.g. adding a pointer when it was not present in
the code for ObjC interfaces or ignoring pointers written in the code
in C++ with auto return type (`auto* foo() -> int`). Those cases look
fixable with a better recovery strategy and I plan to follow up with
more patches to address those.

The first attempt caused 31 tests from `check-clang` to crash due to
different structure of the types and type-locs after certain errors. The
good news is that the failure is localized and mismatch in structures is
discovered by assertions inside `DeclaratorLocFiller`. Some notable
cases caught by existing tests:
- Invalid chunks when type is fully ignored and replace with int or now.
  Crashed in `C/C2x/n2838.c`.
- Invalid return types in lambdas. Crashed in `CXX/drs/dr6xx.cpp`.
- Invalid member pointers. Crashed in `CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp`
- ObjC recovery that adds pointers. Crashed in `SemaObjC/blocks.m`

This change also updates the output of `Index/complete-blocks.m`.
Not entirely sure what causes the change, but the new function signature
is closer to the source code, so this seems like an improvement.

Reviewed By: aaron.ballman, erichkeane

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

18 months ago[lld-macho] Add new -reproducible flag
Keith Smiley [Wed, 5 Apr 2023 21:46:06 +0000 (14:46 -0700)]
[lld-macho] Add new -reproducible flag

As of Xcode 14.3 it passes -reproducible by default to ld64. It seems
this flag was added in ld64 with Xcode 14.0, but it is not documented.
Through my testing the only thing I have seen it do is the same as
ZERO_AR_DATE, but it's possible it does more, or will do more in the
future. Since we already default to this option, this is more about
handling the command line flag to maintain Xcode compatibility than
anything else.

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

18 months ago[Docs][typo] Done the required fix for the #61690
aabhinavg [Sun, 26 Mar 2023 05:57:46 +0000 (11:27 +0530)]
[Docs][typo]  Done the required fix for the #61690

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

18 months agoRevert "Implement Pass and Dialect plugins for mlir-opt"
Jacques Pienaar [Thu, 6 Apr 2023 16:41:22 +0000 (09:41 -0700)]
Revert "Implement Pass and Dialect plugins for mlir-opt"

Breaks bot.

This reverts commit d4c873b044aeebaa43e6989fb1f9606530ec60cf.

18 months ago[RISCV] Lower scalar_to_vector
Luke Lau [Wed, 5 Apr 2023 12:14:51 +0000 (13:14 +0100)]
[RISCV] Lower scalar_to_vector

Loads of fixed length vectors with irregular element counts are
sometimes emitted as a scalar load + scalar_to_vector.
Previously the scalar_to_vector wasn't legal and so was scalarized
further. This patch handles it by lowering it to a vmv.s.x.

Reviewed By: craig.topper

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

18 months ago[RISCV] Add tests for loads and stores of illegal fixed length vectors
Luke Lau [Wed, 5 Apr 2023 10:02:41 +0000 (11:02 +0100)]
[RISCV] Add tests for loads and stores of illegal fixed length vectors

I was investigating why getMemoryOpCost was so expensive for these fixed length vector types, so I've added these tests to see what was going on.
It looks like there's some room for codegen improvement before we adjust the cost model.

Reviewed By: craig.topper

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

18 months ago[InstCombine] Regenerate all test checks (NFC)
Nikita Popov [Thu, 6 Apr 2023 16:29:32 +0000 (18:29 +0200)]
[InstCombine] Regenerate all test checks (NFC)

Due to an improvement to name preservation, a lot of InstCombine
tests now show spurious diffs when regenerated.

Rather than regenerating individual files when they get touched,
mass-regenerate all UTC-based InstCombine tests. I have then reset
a number of files showing suspicious diffs where the UTC output
has clearly been manually adjusted. I apologize if I missed
anything in the mass of changes.

18 months agoRevert "[AMDGPU] Add Lower Bound to PipelineSolver"
Nico Weber [Thu, 6 Apr 2023 16:35:44 +0000 (12:35 -0400)]
Revert "[AMDGPU] Add Lower Bound to PipelineSolver"

This reverts commit 3c42a58c4f20ae3b621733bf5ee6d57c912994a9.
Breaks tests on mac, see https://reviews.llvm.org/rG3c42a58c4f20ae3b621733bf5ee6d57c912994a9#1191724

18 months agoImplement Pass and Dialect plugins for mlir-opt
Fabian Mora [Thu, 6 Apr 2023 16:09:00 +0000 (09:09 -0700)]
Implement Pass and Dialect plugins for mlir-opt

Implementation of Pass and Dialect Plugins that mirrors LLVM Pass Plugin  implementation from the new pass manager.

Currently the implementation only supports using the pass-pipeline option for adding passes. This restriction is imposed by the `PassPipelineCLParser` variable in mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:114 that loads the parse options statically before parsing the cmd line args.

```
mlir-opt stanalone-plugin.mlir --load-dialect-plugin=lib/libStandalonePlugin.so --pass-pipeline="builtin.module(standalone-switch-bar-foo)"
```

Reviewed By: rriddle

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

18 months ago[RISCV] Use PseudoInstExpansion for PseudoReadVLENB and PseudoReadVL. NFC
Craig Topper [Thu, 6 Apr 2023 16:33:01 +0000 (09:33 -0700)]
[RISCV] Use PseudoInstExpansion for PseudoReadVLENB and PseudoReadVL. NFC

This lets tablegen generated the code and avoids a string lookup
of the CSR name at runtime.

18 months ago[ORC][ORC-RT][ELF] Move selection of eh-frame registration APIs into orc-rt.
Lang Hames [Thu, 6 Apr 2023 04:14:45 +0000 (04:14 +0000)]
[ORC][ORC-RT][ELF] Move selection of eh-frame registration APIs into orc-rt.

ORC's ELF platform support prefers the newer libunwind registration functions
(__unw_add_dynamic_eh_frame_section, __unw_remove_dynamic_eh_frame_section) when
they're available, and falls back to the older registration functions
(__register_frame, __deregister_frame) when they're not.

Until now the choice of registration functions has been made on the controller
side in ELFNixPlatform: The platform JITDylib was searched for the registration
functions and aliases set depending on which ones were found. This patch drops
that selection logic from ELFNixPlatform and instead uses weak imports of the
registration functions in elfnix_platform.cpp to identify which ones are
available and choose which ones to use.

This has a few small benefits:
(1) The registration functions don't need to be defined in the same JITDylib as
the ORC runtime -- it's sufficient for them to be defined in a JITDylib that the
ORC runtime's JITDylib links against.

(2) THe elfnix_platfrom code is more readable, as we don't have to dig into
ELFNixPlatform.cpp on the controller side to discover the definition of the
registration aliases.

(3) We may save a separate round-trip to look up the registration APIs (the
lookup will be folded into the ordinary external symbol lookup when linking the
runtime).

18 months ago[gn] port f3d9abf1f87c more (use X86GenFoldTables.inc)
Nico Weber [Thu, 6 Apr 2023 16:27:47 +0000 (12:27 -0400)]
[gn] port f3d9abf1f87c more (use X86GenFoldTables.inc)

18 months ago[mlir][LLVM] Add an attribute to control use of bare-pointer calling convention.
Mahesh Ravishankar [Thu, 6 Apr 2023 16:10:45 +0000 (16:10 +0000)]
[mlir][LLVM] Add an attribute to control use of bare-pointer calling convention.

Currently the use of bare pointer calling convention is controlled
globally through use of an option in the `LLVMTypeConverter`. To allow
more fine-grained control use an attribute on a function to drive the
calling convention to use.

Reviewed By: ftynse

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

18 months ago[SLP]Fix delete of the extractelement with users.
Alexey Bataev [Thu, 6 Apr 2023 15:20:19 +0000 (08:20 -0700)]
[SLP]Fix delete of the extractelement with users.

Made the condition for the erasing of the gathered extractelements
stricter, remove it only if it has single vectorized use, otherwise
leave it for instcombiner/instsimplify analysis.

18 months ago[LAA] Cleanup casting in replaceSymbolicStrideSCEV [nfc]
Philip Reames [Thu, 6 Apr 2023 16:13:10 +0000 (09:13 -0700)]
[LAA] Cleanup casting in replaceSymbolicStrideSCEV [nfc]

18 months ago[gn] port f3d9abf1f87c (use X86GenFoldTables.inc)
Nico Weber [Thu, 6 Apr 2023 16:10:45 +0000 (12:10 -0400)]
[gn] port f3d9abf1f87c (use X86GenFoldTables.inc)

18 months ago[AMDGPU] NFC. Make preserve-hi16.ll test auto-generated
Joe Nash [Wed, 5 Apr 2023 21:13:22 +0000 (17:13 -0400)]
[AMDGPU] NFC. Make preserve-hi16.ll test auto-generated

18 months ago[MLIR][Affine] Fix generateUnrolledLoop utility
Akshay Baviskar [Thu, 6 Apr 2023 05:20:51 +0000 (10:50 +0530)]
[MLIR][Affine] Fix generateUnrolledLoop utility

generateUnrolledLoop was assuming that the yielded value is always generated in
the Block corresponding to the loop being unrolled. Thus, it was updating the
last yielded values with it's cloned value. However, if the yielded value is not
generated in the same Block then the cloned value and it's corresponding mapping
won't exist, resulting in a crash. Fix this.

Reviewed By: bondhugula

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

18 months agoEmit error message instead of asserting
Vimal Patel [Thu, 6 Apr 2023 05:14:43 +0000 (10:44 +0530)]
Emit error message instead of asserting

test-affine-parametric-tile pass was crashing on an incorrect input.
Instead it should emit an error message and exit.

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

Reviewed By: mehdi_amini, bondhugula

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

18 months ago[flang][NFC] Update polymorphic design document to reflect implementation
Valentin Clement [Thu, 6 Apr 2023 15:40:34 +0000 (08:40 -0700)]
[flang][NFC] Update polymorphic design document to reflect implementation

Update the design document to reflect the actual implementation
of polymorphic entities.

Reviewed By: jeanPerier, PeteSteinfeld

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

18 months agoRevert (2) "[Assignment Tracking] Enable by default"
OCHyams [Thu, 6 Apr 2023 15:32:58 +0000 (16:32 +0100)]
Revert (2) "[Assignment Tracking] Enable by default"

Revert D146987 for the 2nd time.

This reverts commit 91a0740474e3c4fe0bde8ff5699115bf808ca23f

Buildbot: https://lab.llvm.org/buildbot/#/builders/70/builds/36007

18 months ago[LAA] Continue moving utilities to sole use to isolate symbolic stride reasoning...
Philip Reames [Thu, 6 Apr 2023 15:23:08 +0000 (08:23 -0700)]
[LAA] Continue moving utilities to sole use to isolate symbolic stride reasoning [nfc]

18 months ago[LV] Remove a cover function with a single use [nfc]
Philip Reames [Thu, 6 Apr 2023 15:11:48 +0000 (08:11 -0700)]
[LV] Remove a cover function with a single use [nfc]

And more importantly, move the fixme to the sole caller where it actually makes sense in context.

18 months ago[mlir][arith] Fix CMake build
Matthias Springer [Thu, 6 Apr 2023 14:55:43 +0000 (23:55 +0900)]
[mlir][arith] Fix CMake build

18 months agoRevert "[InlineCost] isKnownNonNullInCallee - handle also dereferenceable attribute"
Dávid Bolvanský [Thu, 6 Apr 2023 14:54:26 +0000 (16:54 +0200)]
Revert "[InlineCost] isKnownNonNullInCallee - handle also dereferenceable attribute"

This reverts commit 3b5ff3a67c1f0450a100dca34d899ecd3744cb36.

18 months agoRevert "xxx"
Dávid Bolvanský [Thu, 6 Apr 2023 14:54:00 +0000 (16:54 +0200)]
Revert "xxx"

This reverts commit f60592438a7446595cfbfa3944681c689952d859.

18 months ago[AttrDocs] Enhance musttail attribute documentation
Dávid Bolvanský [Thu, 6 Apr 2023 14:50:16 +0000 (16:50 +0200)]
[AttrDocs] Enhance musttail attribute documentation

Based on info from https://github.com/llvm/llvm-project/issues/54964

18 months agoxxx
Dávid Bolvanský [Thu, 6 Apr 2023 09:09:51 +0000 (11:09 +0200)]
xxx

18 months ago[InlineCost] isKnownNonNullInCallee - handle also dereferenceable attribute
Dávid Bolvanský [Thu, 6 Apr 2023 08:02:38 +0000 (10:02 +0200)]
[InlineCost] isKnownNonNullInCallee - handle also dereferenceable attribute

18 months agoReapply "[Assignment Tracking] Enable by default"
OCHyams [Thu, 6 Apr 2023 14:26:11 +0000 (15:26 +0100)]
Reapply "[Assignment Tracking] Enable by default"

Re-land D146987.

This reverts commit 43825d19318695be48abe6f042369da00fbb808b (revert)
which reverts aa32490bfe0b957c4f5583e14304f5e34b2b9bce (original commit).

18 months ago[Assignment Tracking][SROA] Fix fragment when slice size equals variable size
OCHyams [Thu, 6 Apr 2023 13:23:19 +0000 (14:23 +0100)]
[Assignment Tracking][SROA] Fix fragment when slice size equals variable size

Correctly handle the case of splitting an alloca which backs contiguous
distinct variables, where a slice's size equals the size of a backed variable.

We need to ensure that we don't generate fragments expressions with fragments
of the same size as the variable as this is a verifier error.

Prior to this patch a fragment expression would be created in this
situation. e.g. splitting an alloca i64 with two adjacent 32-bit variables into
two 32-bit allocas, the new dbg.assign expressions would contain
(DW_OP_LLVM_fragment, 0, 32) and (DW_OP_LLVM_fragment, 32, 32) even though
those fragments cover each variable entirely.

Reviewed By: jmorse

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

18 months ago[MC] Always encode instruction into SmallVector
Alexis Engelke [Fri, 10 Mar 2023 14:20:30 +0000 (15:20 +0100)]
[MC] Always encode instruction into SmallVector

All users of MCCodeEmitter::encodeInstruction use a raw_svector_ostream
to encode the instruction into a SmallVector. The raw_ostream however
incurs some overhead for the actual encoding.

This change allows an MCCodeEmitter to directly emit an instruction into
a SmallVector without using a raw_ostream and therefore allow for
performance improvments in encoding. A default path that uses existing
raw_ostream implementations is provided.

Reviewed By: MaskRay, Amir

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

18 months agoFix a failed assertion when dumping the AST to JSON
Aaron Ballman [Thu, 6 Apr 2023 13:52:39 +0000 (09:52 -0400)]
Fix a failed assertion when dumping the AST to JSON

We were trying to mangle templated names and the Microsoft mangler does
not have an implementation for mangling dependent names. Instead, we
now skip trying to print the mangled name if the AST node is still a
templated node rather than a fully resolved node.

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

18 months ago[Bazel] Rework llvm-tblgen for X86ManualFoldTables.def
NAKAMURA Takumi [Thu, 6 Apr 2023 13:27:20 +0000 (22:27 +0900)]
[Bazel] Rework llvm-tblgen for X86ManualFoldTables.def

It is easier to introduce header-only library.

18 months ago[libc][RISCV] Let RISCV64 targets test implementations with and without FMA.
Tue Ly [Thu, 23 Mar 2023 16:06:09 +0000 (12:06 -0400)]
[libc][RISCV] Let RISCV64 targets test implementations with and without FMA.

Let RISCV64 targets math implementations with and without FMA
automatically.

Reviewed By: michaelrj

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

18 months ago[MLIR][Arith] Fold trunci with ext if the bit width of the input type of ext is great...
liqinweng [Thu, 6 Apr 2023 13:08:34 +0000 (21:08 +0800)]
[MLIR][Arith] Fold trunci with ext if the bit width of the input type of ext is greater than the

This patch is mainly to deal with folding trunci with ext,as flows:
    trunci(zexti(a)) -> trunci(a)
    trunci(zexti(a)) -> trunci(a)

Reviewed By: ftynse

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

18 months ago[bazel] Port f3d9abf1f87c308e9d7bd368b3ad54cb8f28ac4f
Dmitri Gribenko [Thu, 6 Apr 2023 12:59:38 +0000 (14:59 +0200)]
[bazel] Port f3d9abf1f87c308e9d7bd368b3ad54cb8f28ac4f

18 months ago[compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAUL...
David Spickett [Wed, 5 Apr 2023 09:00:54 +0000 (09:00 +0000)]
[compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAULT_TARGET_ONLY

COMPILER_RT_DEFAULT_TARGET_ONLY is the goto workaround for building
only one of a multilib setup while still being able to autodetect the native target.
For example only building 64 bit libraries on Intel instead of 32 and 64 bit.
Which may fail without 32 bit compatibility libs installed.

As reported in https://discourse.llvm.org/t/configuring-compiler-rt-to-use-default-target-only-does-not-work/62727
this build config hasn't worked in a while.

It relies on a variable usually set during cross compliation,
though my testing shows you can set it in other scenarios too.
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html

So the options you need to provide are:
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCMAKE_C_COMPILER_TARGET="aarch64-unknown-linux-gnu"

And we should error if CMAKE_C_COMPILER_TARGET isn't set.

Reviewed By: glaubitz

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

18 months ago[DAG] combineSelect - select(i1,vXi1,vXi1) - only cast <X x i1> constants to iX pre...
Simon Pilgrim [Thu, 6 Apr 2023 12:35:45 +0000 (13:35 +0100)]
[DAG] combineSelect - select(i1,vXi1,vXi1) - only cast <X x i1> constants to iX pre-legalization or if its a legal type

Fixes #61524

18 months ago[llvm-exegesis][AArch64] Add return statement at the end of the snippet correctly
Pavel Kosov [Thu, 6 Apr 2023 11:56:53 +0000 (14:56 +0300)]
[llvm-exegesis][AArch64] Add return statement at the end of the snippet correctly

Currently llvm-exegesis fails to do this which causes every snippet to crash

~~

Huawei RRI, OS Lab

Reviewed By: courbet

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

18 months ago[clang][ClangScanDeps][test] Remove the file before overwriting it
Dmitri Gribenko [Thu, 6 Apr 2023 11:37:35 +0000 (13:37 +0200)]
[clang][ClangScanDeps][test] Remove the file before overwriting it

Remove the file copied from the source tree before overwriting it. If
the source code is stored with readonly (0444) permissions, then
the copied files are also readonly and attempting to overwrite them
fails.

18 months ago[X86][mem-fold] Use the generated memory folding table
Shengchen Kan [Thu, 6 Apr 2023 11:21:36 +0000 (19:21 +0800)]
[X86][mem-fold] Use the generated memory folding table

Reviewed By: yubing

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

18 months ago[Test] Add expensive-range-sharpening mode for test
Max Kazantsev [Thu, 6 Apr 2023 11:26:30 +0000 (18:26 +0700)]
[Test] Add expensive-range-sharpening mode for test

Looks like it can benefit from this mode.

18 months ago[X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI
Shengchen Kan [Thu, 6 Apr 2023 11:16:46 +0000 (19:16 +0800)]
[X86][mem-fold] Refine the code in X86FoldTablesEmitter.cpp, NFCI

1. Simplify code by using conditional operator
2. Add comments for "kz" and "store" cases
3. Rename variables to match flags

18 months ago[AArch64][SME] Fix LDR and STR asm parser
Caroline Concatto [Thu, 6 Apr 2023 09:53:48 +0000 (09:53 +0000)]
[AArch64][SME] Fix LDR and STR asm parser

The LDR and STR instructions must have the same value for imm4(second operand)
and offset(fourth operand).
The disassembly guarantees that happens, but the Asm parser was not checking that.
This patch fixes that by checking if the second operand and fourth operand are
immediate and have the same value.

Reviewed By: david-arm

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

18 months ago[clang] Reset track of immediate function context when entering new function
Mariya Podchishchaeva [Thu, 6 Apr 2023 08:34:07 +0000 (04:34 -0400)]
[clang] Reset track of immediate function context when entering new function

Due to not resetting that, clang still thinks that it is in immediate
function context even if it already entered non-consteval function.
This caused consteval functions reaching codegen in some cases.

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

Reviewed By: cor3ntin, aaron.ballman

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

18 months ago[X86] LowerVectorAllEqual - don't attempt to match comparisons of float data
Simon Pilgrim [Thu, 6 Apr 2023 10:22:36 +0000 (11:22 +0100)]
[X86] LowerVectorAllEqual - don't attempt to match comparisons of float data

FCMP may use ISD::SETNE when nnan, we don't want to end up with cases where we mismatch signed zeros etc.

Thanks to @pengfei for the test case from D147688

18 months agoReapply "[LSR] Preserve LCSSA when rewriting instruction with PHI user"
Dmitry Makogon [Thu, 6 Apr 2023 09:48:56 +0000 (16:48 +0700)]
Reapply "[LSR] Preserve LCSSA when rewriting instruction with PHI user"

This reverts commit efd34ba60f3839b0a68b2e32ff9011b6823bc16f.

Reapplies 8ff4832679e1. Missed a failing test. Needed to just
update test checks.

18 months ago[SVE][InstCombine] Don't convert calls to fp binop intrinsics to instructions when...
Paul Walker [Tue, 4 Apr 2023 12:51:25 +0000 (12:51 +0000)]
[SVE][InstCombine] Don't convert calls to fp binop intrinsics to instructions when strictfp is required.

There's no support to lower scalable vector constrained operations for SVE
and thus without this change we'll crash during code generation.

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

18 months ago[RISCV] Use non-strided load if VL=1 for optimized zero stride loads
Luke Lau [Wed, 5 Apr 2023 12:35:08 +0000 (13:35 +0100)]
[RISCV] Use non-strided load if VL=1 for optimized zero stride loads

When optimizing vmv.s.x/vmv.v.x's of scalar loads, if VL is known to be
1 then we don't need to perform a stride of x0, and can just do a
regular load.

Reviewed By: craig.topper

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

18 months ago[llvm-exegesis] Make possible to execute snippets without perf counters
Pavel Kosov [Thu, 6 Apr 2023 10:08:48 +0000 (13:08 +0300)]
[llvm-exegesis] Make possible to execute snippets without perf counters

Performance counters may be unavailable due to various reasons (such as
access restriction via sysctl properties or the CPU model being unknown
to libpfm). On the other hand, for debugging llvm-exegesis itself it is
still useful to be able to run generated code snippets to ensure that
the snippet does not crash at run time.

The --use-dummy-perf-counters command line option makes llvm-exegesis
behave just as usual except for using fake event counts instead of asking
the kernel for actual values.

~~

Huawei RRI, OS Lab

Reviewed By: courbet

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

18 months ago[clang][Interp] Add missing static_assert messages
Timm Bäder [Thu, 6 Apr 2023 10:03:45 +0000 (12:03 +0200)]
[clang][Interp] Add missing static_assert messages

This broke build bots, e.g:
https://lab.llvm.org/buildbot/#/builders/139/builds/38697

18 months ago[X86][mem-fold] Avoid nestsed `if`, redundant `else` and correct comments
Shengchen Kan [Thu, 6 Apr 2023 09:54:27 +0000 (17:54 +0800)]
[X86][mem-fold] Avoid nestsed `if`, redundant `else` and correct comments

18 months ago[Sema] Fix reporting of invalid shader attribute on HLSL entry function
Richard Sandiford [Wed, 5 Apr 2023 18:25:21 +0000 (19:25 +0100)]
[Sema] Fix reporting of invalid shader attribute on HLSL entry function

If the HLSL entry function had a shader attribute that conflicted
with the pipeline stage specified in the target triple, Clang
would emit:

   error: (null) attribute parameters do not match the previous declaration
   conflicting attribute is here

(where the second line doesn't reference an attribute).

This was because the code constructed a dummy attribute that had
only a source location, but no kind or syntax.

Noticed while doing some changes to the attribute handling.

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

18 months ago[X86] MatchVectorAllZeroTest - fix bug when splitting vectors of large elements
Simon Pilgrim [Thu, 6 Apr 2023 09:55:33 +0000 (10:55 +0100)]
[X86] MatchVectorAllZeroTest - fix bug when splitting vectors of large elements

DAG::SplitVector only works with vectors with even numbers of elements, when splitting vectors with large (illegal) element widths, we are likely to split down to <1 x iXXX>.

In such cases, pre-bitcast to a <X x i64> type to ensure splitting will always succeed.

Thanks to @alexfh for identifying this.

18 months ago[GuardWidening] Re-factor freezeAndPush.
Serguei Katkov [Mon, 3 Apr 2023 15:53:11 +0000 (22:53 +0700)]
[GuardWidening] Re-factor freezeAndPush.

Re-write the code to avoid iteration over users of
constants and global values.

Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D147450

18 months ago[RISCV] Use tail agnostic policy more often when lowering insert_subvector
Luke Lau [Fri, 31 Mar 2023 18:47:08 +0000 (19:47 +0100)]
[RISCV] Use tail agnostic policy more often when lowering insert_subvector

If we're inserting a fixed length subvector into a fixed length vector,
then we can use a tail agnostic policy as long as we're inserting up to
or past the end of the main vector.
I.e., because we're overwriting all of the main vector's tail elements,
and we don't care what the elements after that are.
As noted by Philip in https://reviews.llvm.org/D146711#4220341

Reviewed By: craig.topper

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

18 months ago[Coverity] Initialize pointer memeber.
Luo, Yuanke [Mon, 3 Apr 2023 02:05:37 +0000 (10:05 +0800)]
[Coverity] Initialize pointer memeber.

18 months ago[RISCV] Move some vector tests to rvv directory. NFC
Luke Lau [Wed, 5 Apr 2023 18:10:47 +0000 (19:10 +0100)]
[RISCV] Move some vector tests to rvv directory. NFC

I personally find it handy to be able to run the check-llvm-codegen-riscv-rvv target to test anything that involves vector codegen, so this patch moves some more vector-based test cases into that directory to increase its coverage.

Reviewed By: craig.topper

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

18 months ago[X86][mem-fold] Remove redundant variable IsAligned, NFCI
Shengchen Kan [Thu, 6 Apr 2023 09:18:03 +0000 (17:18 +0800)]
[X86][mem-fold] Remove redundant variable IsAligned, NFCI

18 months ago[X86][NFC] Fix for warning C4334: '<<': result of 32-bit shift implicitly converted...
Shengchen Kan [Thu, 6 Apr 2023 09:11:30 +0000 (17:11 +0800)]
[X86][NFC] Fix for warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits

18 months ago[Inliner] Added test with nonnull callsite attribute
Dávid Bolvanský [Thu, 6 Apr 2023 09:06:36 +0000 (11:06 +0200)]
[Inliner] Added test with nonnull callsite attribute

18 months ago[FunctionAttrs] Add more nounwind tests (NFC)
Nikita Popov [Thu, 6 Apr 2023 08:53:46 +0000 (10:53 +0200)]
[FunctionAttrs] Add more nounwind tests (NFC)

Test variations where catch/filter catch all exceptions.

18 months ago[LoopVectorize] Fix zext/sext cost calculations when types are shrunk
David Sherwood [Wed, 29 Mar 2023 12:22:09 +0000 (12:22 +0000)]
[LoopVectorize] Fix zext/sext cost calculations when types are shrunk

In getInstructionCost if we know a zext/sext is going to be shrunk
we should only be changing the destination type, and leave the
source type unchanged. For example, we may change a zext from

  zext <16 x i8> %a to <16 x i32>

to

  zext <16 x i8> %a to <16 x i16>

However, we were previously calculating the cost for doing

  zext <16 x i16> %a to <16 x i16>

which is incorrect.

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

18 months ago[clang][Interp] Fix zero-initializing of floating types
Timm Bäder [Fri, 24 Mar 2023 07:33:59 +0000 (08:33 +0100)]
[clang][Interp] Fix zero-initializing of floating types

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

18 months ago[FunctionAttrs] Add additional nounwind inference tests (NFC)
Nikita Popov [Thu, 6 Apr 2023 08:41:10 +0000 (10:41 +0200)]
[FunctionAttrs] Add additional nounwind inference tests (NFC)

For PR61945.

18 months ago[clang][Interp][NFC] Context: Add getFloatSemantics()
Timm Bäder [Mon, 27 Mar 2023 13:03:01 +0000 (15:03 +0200)]
[clang][Interp][NFC] Context: Add getFloatSemantics()

We use this quite a bit, so add some convenience API for it.

18 months ago[X86][mem-fold] Simplify the logic and correct the comments for TB_ALIGN, NFCI
Shengchen Kan [Thu, 6 Apr 2023 08:36:01 +0000 (16:36 +0800)]
[X86][mem-fold] Simplify the logic and correct the comments for TB_ALIGN, NFCI

18 months ago[clang][Interp][NFC] Call emit*Ptr directly
Timm Bäder [Thu, 23 Mar 2023 14:37:09 +0000 (15:37 +0100)]
[clang][Interp][NFC] Call emit*Ptr directly

Instead of the version that uses a switch statement to figure this out.

18 months ago[GVNHoist][NFC] Regenerate test case.
luxufan [Thu, 6 Apr 2023 07:07:15 +0000 (15:07 +0800)]
[GVNHoist][NFC] Regenerate test case.

18 months ago[compiler-rt] [test] Only pass -incremental:no to the linker for MSVC/clang-cl
Martin Storsjö [Wed, 5 Apr 2023 21:05:12 +0000 (21:05 +0000)]
[compiler-rt] [test] Only pass -incremental:no to the linker for MSVC/clang-cl

The target_is_msvc variable in lit.cfg.py matches a similar pattern
used in the asan lit.cfg.py.

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

18 months ago[compiler-rt] [test] [fuzzer] Don't pass msvc/clang-cl specific flags to mingw tools
Martin Storsjö [Fri, 31 Mar 2023 15:23:57 +0000 (15:23 +0000)]
[compiler-rt] [test] [fuzzer] Don't pass msvc/clang-cl specific flags to mingw tools

This fixes building the tests so that the tests can start
executing (even if there still are lots of failures).

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

18 months ago[compiler-rt] Create the umbrella check-compiler-rt test target in non-standalone...
Martin Storsjö [Thu, 30 Mar 2023 09:35:08 +0000 (09:35 +0000)]
[compiler-rt] Create the umbrella check-compiler-rt test target in non-standalone builds too

I don't see why we can't have this target when built as a project alongside
llvm; especially in such build configs, it's useful to have one single target
for running all tests (in standalone builds, check-all does the same too),

Keep the creation of the check-all target only for standalone builds.

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

18 months ago[libunwind] [test] Add a mingw specific test config file
Martin Storsjö [Wed, 29 Mar 2023 21:36:51 +0000 (00:36 +0300)]
[libunwind] [test] Add a mingw specific test config file

This matches how it is done for libcxx and libcxxabi.

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

18 months ago[libunwind] Fflush stderr after each log message
Martin Storsjö [Wed, 5 Apr 2023 07:18:38 +0000 (10:18 +0300)]
[libunwind] Fflush stderr after each log message

In most configs, stderr is line buffered by default, but in some
cases on Windows (running in git bash, or running in Wine) stderr
can end up fully buffered.

See 2ec75a0869ab01fa9caf310e8a31eb7716182d30 for a similar change
for the output from lit itself.

This has no effect on libunwind when the log messages aren't enabled
via the environment variables.

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

18 months ago[libunwind] Fix a typo in a debug log message. NFC.
Martin Storsjö [Wed, 5 Apr 2023 07:56:42 +0000 (10:56 +0300)]
[libunwind] Fix a typo in a debug log message. NFC.

This typo (unw_step instead of unw_get_proc_info) has been around since
the initial public commit of libunwind.

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

18 months ago[libcxxabi, libunwind] [test] Quote the python path properly for LIB*_EXECUTOR
Martin Storsjö [Fri, 27 Aug 2021 11:35:02 +0000 (11:35 +0000)]
[libcxxabi, libunwind] [test] Quote the python path properly for LIB*_EXECUTOR

This is the same as c218c80c730a14a1cbcebd588b18220a879702c6,
but for libcxxabi and libunwind.

This fixes running tests on Windows with Python installed in
e.g. "C:\Program Files\Python38".

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

18 months ago[InstCombine] Remove addrspacecast bitcast extraction fold (NFC)
Nikita Popov [Thu, 6 Apr 2023 07:48:39 +0000 (09:48 +0200)]
[InstCombine] Remove addrspacecast bitcast extraction fold (NFC)

This is not relevant for opaque pointers, and as such no longer
necessary.

18 months ago[SimpleLoopUnswitch] Fix SCEV invalidation issue
Bjorn Pettersson [Tue, 28 Mar 2023 16:07:52 +0000 (18:07 +0200)]
[SimpleLoopUnswitch] Fix SCEV invalidation issue

This patch is making sure that we use getTopMostExitingLoop when
finding out which loops to forget, when dealing with
unswitchNontrivialInvariants and unswitchTrivialSwitch. It seems
to at least be needed for unswitchNontrivialInvariants as detected
by the included test case.

Note that unswitchTrivialBranch already used getTopMostExitingLoop.
This was done in commit 4a9cde5a791cd49b96993e6. The commit
message in that commit says "If the patch makes sense, I will also
update those places to a similar approach ...", referring to these
functions mentioned above. As far as I can tell that never happened,
but this is an attempt to finally fix that.

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

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

18 months ago[InstCombine] Remove various checks for opaque pointers (NFC)
Nikita Popov [Thu, 6 Apr 2023 07:26:15 +0000 (09:26 +0200)]
[InstCombine] Remove various checks for opaque pointers (NFC)

All pointers are opaque now, so these are no longer necessary.

18 months ago[clang][Interp] Record initialization via conditional operator
Timm Bäder [Wed, 11 Jan 2023 14:59:29 +0000 (15:59 +0100)]
[clang][Interp] Record initialization via conditional operator

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

18 months ago[LoopVectorize] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 6 Apr 2023 07:30:42 +0000 (09:30 +0200)]
[LoopVectorize] Convert some tests to opaque pointers (NFC)

18 months ago[libc] Remove dead code
Guillaume Chatelet [Thu, 6 Apr 2023 07:33:41 +0000 (07:33 +0000)]
[libc] Remove dead code

18 months ago[AVR] Fix incorrect expansion of pseudo instructions LPMWRdZ/ELPMWRdZ
Ben Shi [Mon, 9 Jan 2023 08:15:41 +0000 (16:15 +0800)]
[AVR] Fix incorrect expansion of pseudo instructions LPMWRdZ/ELPMWRdZ

The 'ELPM' instruction has three forms:

--------------------------
| form        | feature  |
| ----------- | -------- |
| ELPM        | hasELPM  |
| ELPM Rd, Z  | hasELPMX |
| ELPM Rd, Z+ | hasELPMX |
--------------------------

The second form is always used in the expansion of pseudo instructions
LPMWRdZ/ELPMWRdZ. But for devices without ELPMX and with only ELPM,
only the first form can be used.

Reviewed By: aykevl, Miss_Grape

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