platform/upstream/llvm.git
16 months ago[mlir][sparse] add support for direct prod/and/min/max reductions
Aart Bik [Fri, 9 Jun 2023 19:48:45 +0000 (12:48 -0700)]
[mlir][sparse] add support for direct prod/and/min/max reductions

We recently fixed a bug in "sparsifying" such reductions, since
it incorrectly changed this into reductions over stored elements
only , which only works for add/sub/or/xor. However, we still want
to be able to "sparsify" the reductions even in the general case,
and this is a first step by rewriting them into a custom reduction
that feeds in the implicit zeros. NOTE HOWEVER, that in the long run
we want to do this better and feed in any implicit zero only ONCE
for efficiency.

Reviewed By: Peiming

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

16 months ago[SelectionDAG][AArch64] Legalize FMAXIMUM/FMINIMUM
Anna Thomas [Mon, 12 Jun 2023 15:55:05 +0000 (11:55 -0400)]
[SelectionDAG][AArch64] Legalize FMAXIMUM/FMINIMUM

The missing legalization in SelectionDAG was identified when adding the
intrinsic support for vector reduction for maximum/minimum (D152370).

Fixes part of PR: https://github.com/llvm/llvm-project/issues/63267

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

16 months ago[DebugInfo] Add DW_ATE_complex_float case to assert in isUnsignedDIType
OCHyams [Mon, 12 Jun 2023 16:06:50 +0000 (17:06 +0100)]
[DebugInfo] Add DW_ATE_complex_float case to assert in isUnsignedDIType

Without this patch a `DW_ATE_complex_float` encoding trips an assertion in
`DebugHandlerBase::isUnsignedDIType` with the message `"Unsupported
encoding"`.

By adding a case to the `assert` for `DW_ATE_complex_float` it becomes
supported, behaving in the same way as the already supported `DW_ATE_float`
type (return false).

Note: For the reported reproducer:

    #include <complex.h>
    int main() {
      long double complex r1;
    }

The assertion isn't tripped without assignment tracking because instcombine
deletes everything, including the `dbg.declare`, without recovering any
location information. Whereas with assignment tracking we track a zeroing
memset that is emitted by clang.

Reviewed By: probinson

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

16 months ago[ConstraintElim] Extend monotonic phi test coverage.
Florian Hahn [Mon, 12 Jun 2023 16:07:01 +0000 (17:07 +0100)]
[ConstraintElim] Extend monotonic phi test coverage.

Add additional tests which exposed some crashes in upcoming patches and
test for and-implied-by-operands handling.

16 months agoRevert "[RDF] Allow RegisterRef to contain register unit" and follow-ups
Nico Weber [Mon, 12 Jun 2023 15:32:29 +0000 (11:32 -0400)]
Revert "[RDF] Allow RegisterRef to contain register unit" and follow-ups

This reverts commit 859b05b02d3fd9ab6b77f2bed8df6902fe704806.

Also reverts these follow-ups:

Revert "[RDF] Remove `constexpr` from `hash"
This reverts commit 621507ce20ad8eef2986be2712631165e53b7d91.

Revert "[RDF] Do not use trailing return type after all, NFC"
This reverts commit 46e19e3a2c45e7fb5f501bdb983a7151c158304f.

Revert "[RDF] Stop looking when reached code node in getNextRef with NextOnly"
This reverts commit a049ce9d1bd5a7c1c4fcccc6a801b72b00ea8e0f.

Revert "[RDF] Use trailing return type syntax, NFC"
This reverts commit d3b34b7f3a7cbfc96aea897419f167b5ee19e61a.

Revert "[RDF] Define short type names: NodeAddr<XyzNode*> -> Xyz, NFC"
This reverts commit f8ed60b56d1948422dda924fcf450560591e8a19.

16 months agoRevert "[Driver] Mark many target-specific driver-only options as TargetSpecific"
Hans Wennborg [Mon, 12 Jun 2023 15:02:37 +0000 (17:02 +0200)]
Revert "[Driver] Mark many target-specific driver-only options as TargetSpecific"

This broke building the TSan runtime on Mac, see comment on
https://github.com/llvm/llvm-project/commit/5548843d692a92a7840f14002debc3cebcb3cdc3

> so that they get an error on other targets. This change uses let statements to
> apply `Flags = [TargetSpecific]` to options (mostly -m*) without specifying `Flags`.
> Follow-up to D151590.
>
> For some options, e.g. -mdefault-build-attributes (D31813), -mbranch-likely
> (D38168), -mfpu=/-mabi= (6890b9b71e525020ab58d436336664beede71575), a warning
> seems desired in at least certain cases. This is not the best practice, but this
> change works around them by not applying `Flags = [TargetSpecific]`.
>
> (
> For Intel CPU errata -malign-branch= family options, we also drop the unneeded
> NotXarchOption flag. This flag reports an error if the option is used with
> -Xarch_*. This error reporting does not seem very useful.
> )

This reverts commit 5548843d692a92a7840f14002debc3cebcb3cdc3.

16 months ago[test][ASAN] Fix incorrect REQUIRES directive for scandir.c
Justin Cady [Mon, 12 Jun 2023 14:58:38 +0000 (10:58 -0400)]
[test][ASAN] Fix incorrect REQUIRES directive for scandir.c

The missing colon caused the test to run on unintended platforms.

Reviewed By: emaste

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

16 months ago[FlowSensitive] Use {DenseMapBase,StringMap}::lookup (NFC)
Kazu Hirata [Mon, 12 Jun 2023 15:11:01 +0000 (08:11 -0700)]
[FlowSensitive] Use {DenseMapBase,StringMap}::lookup (NFC)

16 months ago[IR] Remove getABITypeAlignment
Kazu Hirata [Mon, 12 Jun 2023 15:10:59 +0000 (08:10 -0700)]
[IR] Remove getABITypeAlignment

The last use of getABITypeAlignment was removed by:

  commit 26bd6476c61f08fc8c01895caa02b938d6a37221
  Author: Guillaume Chatelet <gchatelet@google.com>
  Date:   Fri Jan 13 15:05:24 2023 +0000

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

16 months ago[AMDGPU] Fix resource-usage-pal.ll
Kazu Hirata [Mon, 12 Jun 2023 15:06:46 +0000 (08:06 -0700)]
[AMDGPU] Fix resource-usage-pal.ll

16 months ago[OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor...
Akash Banerjee [Mon, 12 Jun 2023 14:00:17 +0000 (15:00 +0100)]
[OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

This patch migrates the emitOffloadingArrays and EmitNonContiguousDescriptor functions from Clang codegen to OpenMPIRBuilder.

Reviewed By: jdoerfert

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

16 months agoRemove unused variable 's32' in X86LegalizerInfo.cpp (NFC)
Jie Fu [Mon, 12 Jun 2023 14:34:08 +0000 (22:34 +0800)]
Remove unused variable 's32' in X86LegalizerInfo.cpp (NFC)

/data/llvm-project/llvm/lib/Target/X86/X86LegalizerInfo.cpp:470:13: error: unused variable 's32' [-Werror,-Wunused-variable]
  const LLT s32 = LLT::scalar(32);
            ^
1 error generated.

16 months ago[GlobalIsel][X86] Move G_SITOFP/G_FPTOSI getActionDefinitionsBuilder out of setLegali...
Simon Pilgrim [Mon, 12 Jun 2023 14:26:05 +0000 (15:26 +0100)]
[GlobalIsel][X86] Move G_SITOFP/G_FPTOSI getActionDefinitionsBuilder out of setLegalizerInfo64bit and add basic 32-bit support

We were using x86_64-only support as a SSE2 proxy - vector support is still missing.

16 months ago[mlir][linalg] Add scalar broadcast load case to the vectoriser
Andrzej Warzynski [Fri, 2 Jun 2023 07:45:16 +0000 (08:45 +0100)]
[mlir][linalg] Add scalar broadcast load case to the vectoriser

This patch extends the Linalg vectoriser so that scalar loads are
correctly identified as scalar rather than gather loads. Below is an
example of a scalar load (note that both indices are loop invariant):
```
func.func @example(%arg0: tensor<80x16xf32>, %arg2: tensor<1x4xf32>) -> tensor<1x4xf32> {
%c8 = arith.constant 8 : index
%c16 = arith.constant 16 : index
%1 = linalg.generic {
    indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>],
    iterator_types = ["parallel", "parallel"]
  } outs(%arg2 : tensor<1x4xf32>) {
  ^bb0(%out: f32):
    %2 = linalg.index 0 : index
    %extracted = tensor.extract %arg0[%2, %c16] : tensor<80x16xf32>
    linalg.yield %extracted : f32
  } -> tensor<1x4xf32>
  return %1 : tensor<1x4xf32>
}
```

This patch also makes sure that these scalar loads are indeed lowered to
a scalar load followed by a broadcast:
```
    %extracted = tensor.extract %arg0[%1, %c16] : tensor<80x16xf32>
    %2 = vector.broadcast %extracted : f32 to vector<1x4xf32>
```

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

16 months ago[AMDGPU] Do not assume stack size for PAL code object indirect calls
Baptiste [Mon, 12 Jun 2023 14:12:54 +0000 (10:12 -0400)]
[AMDGPU] Do not assume stack size for PAL code object indirect calls

There is no need to set a big default stack size for PAL code object indirect
calls. The driver knows the max recursion depth, so it can compute a more
accurate value from the minimum scratch size.

Reviewed By: arsenm

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

16 months ago[gn] Mac support for check-asan target
Leonard Grey [Fri, 9 Jun 2023 22:04:48 +0000 (18:04 -0400)]
[gn] Mac support for check-asan target

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

16 months ago[libc] Improve memcmp latency and codegen
Guillaume Chatelet [Mon, 12 Jun 2023 13:30:50 +0000 (13:30 +0000)]
[libc] Improve memcmp latency and codegen

This is based on ideas from @nafi to:
 - use a branchless version of 'cmp' for 'uint32_t',
 - completely resolve the lexicographic comparison through vector
   operations when wide types are available. We also get rid of byte
   reloads and serializing '__builtin_ctzll'.

I did not include the suggestion to replace comparisons of 'uint16_t'
with two 'uint8_t' as it did not seem to help the codegen. This can
be revisited in sub-sequent patches.

The code been rewritten to reduce nested function calls, making the
job of the inliner easier and preventing harmful code duplication.

Reviewed By: nafi3000

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

16 months ago[clang][tests] Replace a %clang++ with %clang
Timm Bäder [Mon, 12 Jun 2023 13:41:34 +0000 (15:41 +0200)]
[clang][tests] Replace a %clang++ with %clang

%clang++ does not work on windows, see e.g.:

https://lab.llvm.org/staging/#/builders/204/builds/2141

16 months ago[MC][MachO]Do not emit DWARF for no-personality case
oontvoo [Mon, 12 Jun 2023 12:16:08 +0000 (08:16 -0400)]
[MC][MachO]Do not emit DWARF for no-personality case

Detail: Follow up to D144999, where we emitted DWARF for non-canonical personality.

Reviewed By: jyknight

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

16 months ago[libc] Add platform independent floating point rounding mode checks.
Tue Ly [Tue, 6 Jun 2023 15:50:26 +0000 (11:50 -0400)]
[libc] Add platform independent floating point rounding mode checks.

Many math functions need to check for floating point rounding modes to
return correct values.  Currently most of them use the internal implementation
of `fegetround`, which is platform-dependent and blocking math functions to be
enabled on platforms with unimplemented `fegetround`.  In this change, we add
platform independent rounding mode checks and switching math functions to use
them instead. https://github.com/llvm/llvm-project/issues/63016

Reviewed By: sivachandra

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

16 months ago[GVN] Fix verifyRemoved() verification
Nikita Popov [Mon, 12 Jun 2023 13:14:27 +0000 (15:14 +0200)]
[GVN] Fix verifyRemoved() verification

Fix the verification failure reported in
https://reviews.llvm.org/D141712#4413647. We need to remove the
load from the VN table as well, not just the leader table.

Also make sure that this verification always runs when assertions
are enabled, rather than only when -debug is passed.

16 months ago[LoopVectorize] Convert test to opaque pointers (NFC)
Nikita Popov [Mon, 12 Jun 2023 12:49:02 +0000 (14:49 +0200)]
[LoopVectorize] Convert test to opaque pointers (NFC)

I'm keeping the bitcast in the input here, because without it
we end up introducing a stride 1 assumption and end up testing
a different case.

16 months ago[LoopVectorize] Convert test to opaque pointers (NFC)
Nikita Popov [Mon, 12 Jun 2023 12:29:52 +0000 (14:29 +0200)]
[LoopVectorize] Convert test to opaque pointers (NFC)

16 months ago[LoopVectorize] Regenerate test checks (NFC)
Nikita Popov [Mon, 12 Jun 2023 12:29:31 +0000 (14:29 +0200)]
[LoopVectorize] Regenerate test checks (NFC)

16 months ago[clang-tidy] run-clang-tidy: forward warnings-as-errors argument
indev [Mon, 12 Jun 2023 11:16:10 +0000 (11:16 +0000)]
[clang-tidy] run-clang-tidy: forward warnings-as-errors argument

Forward `warnings-as-errors` argument to clang-tidy.

Reviewed By: PiotrZSL

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

16 months ago[clang][dataflow] Model pointer value for builtin functions.
Martin Braenne [Mon, 12 Jun 2023 08:11:03 +0000 (08:11 +0000)]
[clang][dataflow] Model pointer value for builtin functions.

This fixes a false positive in the Crubit nullability verification.

Reviewed By: gribozavr2

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

16 months ago[AMDGPU][GFX11] Add test coverage for cases involving conversions from and to fp16...
Ivan Kosarev [Mon, 12 Jun 2023 11:39:21 +0000 (12:39 +0100)]
[AMDGPU][GFX11] Add test coverage for cases involving conversions from and to fp16 values.

Other such tests, of which there are many, are to be updated with
separate patches.

Reviewed By: arsenm

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

16 months ago[RFC][clangd] Move preamble index out of document open critical path
Kugan Vivekanandarajah [Mon, 12 Jun 2023 11:55:29 +0000 (12:55 +0100)]
[RFC][clangd] Move preamble index out of document open critical path

We would like to move the preamble index out of the critical path.
This patch is an RFC to get feedback on the correct implementation and potential pitfalls to keep into consideration.

I am not entirely sure if the lazy AST initialisation would create using Preamble AST in parallel. I tried with tsan enabled clangd but it seems to work OK (at least for the cases I tried)

Reviewed By: kadircet

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

16 months ago[MISched] Require asserts and AArch64 registered target for test.
Francesco Petrogalli [Mon, 12 Jun 2023 11:51:19 +0000 (13:51 +0200)]
[MISched] Require asserts and AArch64 registered target for test.

Fixes failure at https://lab.llvm.org/buildbot/#/builders/124/builds/7472:

```
llc: Unknown command line argument '-debug-only=machine-scheduler'. Try: '/home/buildbot/as-worker-91/clang-with-lto-ubuntu/build/stage1/bin/llc --help'
```

Reviewed By: fhahn

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

16 months ago[GlobalIsel][X86] Rename x86_64-select-fcmp.mir to select-fcmp.mir and add 32-bit...
Simon Pilgrim [Mon, 12 Jun 2023 11:31:27 +0000 (12:31 +0100)]
[GlobalIsel][X86] Rename x86_64-select-fcmp.mir to select-fcmp.mir and add 32-bit test coverage

x86_64 was being used as shorthand for SSE2

16 months ago[OpenMP][Flang][MLIR] Add MLIR support for OpenMP requires directive
Sergio Afonso [Wed, 29 Mar 2023 16:45:24 +0000 (17:45 +0100)]
[OpenMP][Flang][MLIR] Add MLIR support for OpenMP requires directive

This patch introduces an MLIR attribute to the OpenMP dialect
representing the clauses that a 'requires' directive can define.

The `OffloadModuleInterface` is also updated to provide methods to get
and set a new dialect attribute `omp.requires`, to allow storing and using this
information during the lowering stages to LLVM IR.

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

16 months ago[MLIR][Quant] Fix equations in `Quantization.md`
rikhuijzer [Mon, 12 Jun 2023 11:28:39 +0000 (13:28 +0200)]
[MLIR][Quant] Fix equations in `Quantization.md`

This patch fixes the equations on the Quantization page
(https://mlir.llvm.org/docs/Quantization/).

I don't know what caused the equations to be broken, it
might be https://github.com/llvm/mlir-www/pull/152, but
I'm not sure. Irregardless, let's just fix it and be
done with it.

I've fixed the equations by moving some subscripts to
the text. For some reason, the large number of subscripts
caused Mathjax to fail. I've also tried KaTeX, which
failed at exactly the same number of subscripts.

The workflow to inspect the fix is as follows:

```
$ git clone --depth=1 https://github.com/llvm/mlir-www.git /some/path/mlir-www

$ git clone --depth=1 https://github.com/llvm/llvm-project.git /some/path/llvm-project

$ cp /some/path/llvm-project/mlir/docs/Quantization.md \
    /some/path/mlir-www/website/content/Quantization.md

$ cd /some/path/mlir-www/website

$ hugo serve
[...]
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop
```
and view the page at http://localhost:1313/Quantization/.

Reviewed By: stellaraccident

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

16 months agoRemove unused variable 's8' in X86LegalizerInfo.cpp (NFC)
Jie Fu [Mon, 12 Jun 2023 11:24:56 +0000 (19:24 +0800)]
Remove unused variable 's8' in X86LegalizerInfo.cpp (NFC)

/data/llvm-project/llvm/lib/Target/X86/X86LegalizerInfo.cpp:443:13: error: unused variable 's8' [-Werror,-Wunused-variable]
  const LLT s8 = LLT::scalar(8);
            ^
1 error generated.

16 months ago[GlobalIsel][X86] Move G_FCMP getActionDefinitionsBuilder out of setLegalizerInfo64bi...
Simon Pilgrim [Mon, 12 Jun 2023 10:25:48 +0000 (11:25 +0100)]
[GlobalIsel][X86] Move G_FCMP getActionDefinitionsBuilder out of setLegalizerInfo64bit and add 32-bit support

We were using x86_64-only support as a SSE2 proxy

16 months ago[GlobalIsel][X86] Regenerate legalize-fcmp.mir
Simon Pilgrim [Mon, 12 Jun 2023 10:07:45 +0000 (11:07 +0100)]
[GlobalIsel][X86] Regenerate legalize-fcmp.mir

16 months ago[GlobalIsel][X86] Rename x86_64-legalize-fcmp to legalize-fcmp
Simon Pilgrim [Mon, 12 Jun 2023 10:01:08 +0000 (11:01 +0100)]
[GlobalIsel][X86] Rename x86_64-legalize-fcmp to legalize-fcmp

32-bit support will be added shortly - x86_64 was being used a shorthand for SSE2

16 months ago[LoopVectorize] Convert most tests to opaque pointers (NFC)
Nikita Popov [Mon, 12 Jun 2023 10:22:01 +0000 (12:22 +0200)]
[LoopVectorize] Convert most tests to opaque pointers (NFC)

The unsized-pointee-crash.ll and zero-sized-pointee-crash.ll tests
have been removed, because these issues are not relevant for opaque
pointers.

16 months ago[clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option
Timm Bäder [Sun, 4 Jun 2023 05:49:36 +0000 (07:49 +0200)]
[clang][Driver] Add -fcaret-diagnostics-max-lines= as a driver option

Since https://reviews.llvm.org/D147875 landed, setting different values
(or reverting to the old default of 1) is more important than before,
so promote this option to a driver flag.

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

16 months ago[Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)
Nikita Popov [Mon, 12 Jun 2023 10:14:02 +0000 (12:14 +0200)]
[Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)

No longer relevant with opaque pointers.

16 months ago[mlir][Linalg] Apply ClangTidy finding (NFC)
Adrian Kuegel [Mon, 12 Jun 2023 10:02:23 +0000 (12:02 +0200)]
[mlir][Linalg] Apply ClangTidy finding (NFC)

16 months ago[DAGCombine] Move setcc of freeze fold to brcond
Nikita Popov [Fri, 9 Jun 2023 15:07:15 +0000 (17:07 +0200)]
[DAGCombine] Move setcc of freeze fold to brcond

This fold goes against the usual approach of pushing freeze into
operands. The idea behind the fold is that if the setcc feeds into
a brcond, the freeze can be dropped entirely.

Move the fold to brcond, where we can remove the freeze directly.
This ensures that there can be no infinite combine loops due to
conflicting transforms.

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

16 months ago[clangd] Enforce strict unused includes by default
Kadir Cetinkaya [Fri, 9 Jun 2023 16:16:45 +0000 (18:16 +0200)]
[clangd] Enforce strict unused includes by default

Depends on D152685

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

16 months ago[clangd] Decouple IncludeCleaner implementation from Config
Kadir Cetinkaya [Fri, 9 Jun 2023 15:53:39 +0000 (17:53 +0200)]
[clangd] Decouple IncludeCleaner implementation from Config

This should help managing tests as we change defaults in configs.

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

16 months ago[LegalizeTypes][VP] Widen load/store of fixed length vectors to VP ops
Luke Lau [Tue, 6 Jun 2023 09:29:40 +0000 (09:29 +0000)]
[LegalizeTypes][VP] Widen load/store of fixed length vectors to VP ops

If we have a load/store with an illegal fixed length vector result type that
needs widened, e.g. `x:v6i32 = load p`
Instead of just widening it to: `x:v8i32 = load p`
We can widen it to the equivalent VP operation and set the EVL to the
exact number of elements needed: `x:v8i32 = vp_load a, b, mask=true, evl=6`
Provided that the target supports vp_load/vp_store on the widened type.

Scalable vectors are already widened this way where possible, so this
largely reuses the same logic.

Reviewed By: craig.topper

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

16 months ago[clang][dataflow][NFC] Expand comments on losing values in optional checker.
Martin Braenne [Wed, 7 Jun 2023 13:23:54 +0000 (13:23 +0000)]
[clang][dataflow][NFC] Expand comments on losing values in optional checker.

While working on the ongoing migration to strict handling of value
categories (see https://discourse.llvm.org/t/70086), I ran into issues related
to losing the value associated with an optional.

This issue is hinted at in the existing comments, but the issue didn't become
sufficiently clear to me from those, so I thought it would be worth capturing
more details, along with ideas for how this issue might be fixed.

Reviewed By: ymandel

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

16 months agoRevert D148717 "[libc] Improve memcmp latency and codegen"
Guillaume Chatelet [Mon, 12 Jun 2023 08:32:00 +0000 (08:32 +0000)]
Revert D148717 "[libc] Improve memcmp latency and codegen"

This broke aarch64 debug buildbot https://lab.llvm.org/buildbot/#/builders/223/builds/21703
This reverts commit bd4f978754758d5ef29d1f10370f45362da3de37.

16 months agosanitizers: intercept FreeBSD's cpuset_getaffinity call.
David Carlier [Mon, 12 Jun 2023 08:05:31 +0000 (09:05 +0100)]
sanitizers: intercept FreeBSD's cpuset_getaffinity call.

Reviewed By: melver

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

16 months ago[libc] Improve memcmp latency and codegen
Guillaume Chatelet [Mon, 12 Jun 2023 07:55:13 +0000 (07:55 +0000)]
[libc] Improve memcmp latency and codegen

This is based on ideas from @nafi to:
 - use a branchless version of 'cmp' for 'uint32_t',
 - completely resolve the lexicographic comparison through vector
   operations when wide types are available. We also get rid of byte
   reloads and serializing '__builtin_ctzll'.

I did not include the suggestion to replace comparisons of 'uint16_t'
with two 'uint8_t' as it did not seem to help the codegen. This can
be revisited in sub-sequent patches.

The code been rewritten to reduce nested function calls, making the
job of the inliner easier and preventing harmful code duplication.

Reviewed By: nafi3000

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

16 months ago[MISched] Use StartAtCycle in trace dumps.
Francesco Petrogalli [Mon, 12 Jun 2023 06:57:25 +0000 (08:57 +0200)]
[MISched] Use StartAtCycle in trace dumps.

This commit re-work the methods that dump traces with resource usage to take into account the StartAtCycle value added by https://reviews.llvm.org/D150310.

For each i, the values of the lists StartAtCycle and ReservedCycles is  are printed with the interval [StartAtCycle[i], ReservedCycles[i])

```
... | StartAtCycle[i] | ... | ReservedCycles[i] - 1 | ReservedCycles[i] | ...
    | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |                   |
```

Reviewed By: andreadb

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

16 months ago[mlir][llvm] Ensure immediate usage in intrinsics
Christian Ulmann [Mon, 12 Jun 2023 06:23:42 +0000 (06:23 +0000)]
[mlir][llvm] Ensure immediate usage in intrinsics

This commit changes intrinsics that have immarg parameter attributes to
model these parameters as attributes, instead of operands. Using
operands only works if the operation is an `llvm.mlir.constant`,
otherwise the exported LLVMIR is invalid.

Reviewed By: gysit

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

16 months ago[libc++][spaceship] P1614R2: Removed global `operator!=` from `allocator`
Hristo Hristov [Sat, 10 Jun 2023 07:52:09 +0000 (10:52 +0300)]
[libc++][spaceship] P1614R2: Removed global `operator!=` from `allocator`

Implements parts of P1614R2:
- Removed global `operator!=` from `allocator`

Reviewed By: #libc, Mordante

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

16 months agoRevert "[clang-tidy] Move formatDereference to FixitHintUtils"
Piotr Zegar [Mon, 12 Jun 2023 06:26:19 +0000 (06:26 +0000)]
Revert "[clang-tidy] Move formatDereference to FixitHintUtils"

This reverts commit 636c672751425f1c73c28bea57c1913043cd21b2.

16 months ago[libc++][spaceship] P1612R2: Removed `operator!=` from `bitset`
Hristo Hristov [Sat, 10 Jun 2023 07:28:05 +0000 (10:28 +0300)]
[libc++][spaceship] P1612R2: Removed `operator!=` from `bitset`

Implements parts of P1612R2:
- Removed `operator!=` from `bitset`

Reviewed By: #libc, Mordante

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

16 months ago[libc++][spaceship] P1614R2: Removed `operator!=` from `unordered_map`, `unordered_mu...
Hristo Hristov [Sun, 11 Jun 2023 05:28:04 +0000 (08:28 +0300)]
[libc++][spaceship] P1614R2: Removed `operator!=` from `unordered_map`, `unordered_multimap`, `__hash_map_iterator`

Implements parts of P1614R2:
- Removed ops from `unordered_map`
- Removed ops from `unordered_multimap`
- Removed ops from `__hash_map_iterator`

Reviewed By: #libc, Mordante

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

16 months ago[clang-tidy] Move formatDereference to FixitHintUtils
Mike Crowe [Mon, 12 Jun 2023 06:09:17 +0000 (06:09 +0000)]
[clang-tidy] Move formatDereference to FixitHintUtils

I'd like to use RedundantStringCStrCheck's formatDereference function
from the up-coming modernize-use-std-print check. Let's move it to
FixItHintUtils so that the implementation can be shared.

Reviewed By: PiotrZSL

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

16 months ago[clang-tidy][NFC] Sort changes by check name in ReleaseNotes
Piotr Zegar [Mon, 12 Jun 2023 06:06:41 +0000 (06:06 +0000)]
[clang-tidy][NFC] Sort changes by check name in ReleaseNotes

Sort changes listed in ClangTidy release notes by
a check name.

16 months ago[clang-tidy] Readability-container-data-pointer adds new option to ignore Containers
Felix [Mon, 12 Jun 2023 05:34:08 +0000 (05:34 +0000)]
[clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

Adds a new option to the clang-tidy's check : readability-container-data-pointer to ignore some containers.

This option is useful in the case of std::array where the size is known at compile time and there is no real risk to access the first index of the container. In that case some users might prefer to ignore this type of container.

Relates to : https://github.com/llvm/llvm-project/issues/57445

Reviewed By: PiotrZSL

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

16 months ago[doc][LoongArch] Use ``lp64s`` instead of `lp64s`. NFC
Weining Lu [Mon, 12 Jun 2023 05:47:41 +0000 (13:47 +0800)]
[doc][LoongArch] Use ``lp64s`` instead of `lp64s`. NFC

16 months ago[AST] Always set dependent-type for the CallExpr for error-recovery in C.
Haojian Wu [Fri, 9 Jun 2023 16:47:47 +0000 (18:47 +0200)]
[AST] Always set dependent-type for the CallExpr for error-recovery in C.

When build CallExpr for error-recovery where we have any dependent
child nodes), we should set a dependent type for CallExpr to avoid
running into some unexpected following semantic analysis.

This also aligns with the C++ behavior.

This fixes the symptom crashes: https://github.com/llvm/llvm-project/issues/50244

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

16 months ago[RISCV] Don't iterate SEW set again for floating-point
wangpc [Mon, 12 Jun 2023 04:06:23 +0000 (12:06 +0800)]
[RISCV] Don't iterate SEW set again for floating-point

We have already iterated over `FPList`, so there is no need to get
and loop over SEW set again. Or we will generate some useless pseudo
instructions like `PseudoXXX_VF16_M1_E64`.

We add SEW to FPR_Info so that we can get it later. And we rewrite
FPR_Info to reduce arguments incidentally.

This should reduce the size of files generated by TableGen.

Reviewed By: craig.topper

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

16 months ago[SCCP] Replace new value's value state with removed value's
luxufan [Sat, 10 Jun 2023 07:48:09 +0000 (15:48 +0800)]
[SCCP] Replace new value's value state with removed value's

In replaceSignedInst, if a signed instruction can be repalced with
unsigned instruction, we created a new instruction and removed the old
instruction's value state. If the following instructions has this new
instruction as a use operand, transformations like replaceSignedInst and
refineInstruction would be blocked. The reason is there is no value
state for the new instrution.

This patch set the new instruction's value state with the removed
instruction's value state. I believe it is correct bacause when we
repalce a signed instruction with unsigned instruction, the value state
is not changed.

Reviewed By: nikic

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

16 months ago[flang] Improve compiler_version test (NFC)
Kelvin Li [Fri, 9 Jun 2023 18:47:51 +0000 (14:47 -0400)]
[flang] Improve compiler_version test (NFC)

This patch is to allow an extra string prepended to the compiler_version.
The check is enhanced to verify that "flang version" is followed by
numbers in the form of "n.n.n".

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

16 months agoMake test more flexible for platforms that may emit extra arguments.
Douglas Yung [Mon, 12 Jun 2023 00:53:44 +0000 (17:53 -0700)]
Make test more flexible for platforms that may emit extra arguments.

16 months ago[Driver] Default to -fxray-function-index
Fangrui Song [Sun, 11 Jun 2023 22:38:13 +0000 (15:38 -0700)]
[Driver] Default to -fxray-function-index

As explained by commit 849f1dd15e92fda2b83dbb6144e6b28b2cb946e0,
-fxray-function-index was the original default but was accidentally flipped by
commit d8a8e5d6240a1db809cd95106910358e69bbf299. Restore the previous behavior.

Originally reported by Oleksii Lozovskyi in D145848.

16 months ago[XRay] Rename XRayOmitFunctionIndex to XRayFunctionIndex
Fangrui Song [Sun, 11 Jun 2023 22:27:22 +0000 (15:27 -0700)]
[XRay] Rename XRayOmitFunctionIndex to XRayFunctionIndex

Apply my post-commit comment on D81995. The negative name misguided commit
d8a8e5d6240a1db809cd95106910358e69bbf299 (`[clang][cli] Remove marshalling from
Opt{In,Out}FFlag`) to:

* accidentally flip the option to not emit the xray_fn_idx section.
* change -fno-xray-function-index (instead of -fxray-function-index) to emit xray_fn_idx

This patch renames XRayOmitFunctionIndex and makes -fxray-function-index emit
xray_fn_idx, but the default remains -fno-xray-function-index .

16 months ago[VPlan] Use step from induction recipe directly. (NFC)
Florian Hahn [Sun, 11 Jun 2023 20:40:05 +0000 (21:40 +0100)]
[VPlan] Use step from induction recipe directly. (NFC)

Directly use the step of the transformed induction instead of creating
a new step. This allows replacing all uses of strides in D147783.

16 months ago[CodeGen] Use DenseMapBase::lookup (NFC)
Kazu Hirata [Sun, 11 Jun 2023 20:19:26 +0000 (13:19 -0700)]
[CodeGen] Use DenseMapBase::lookup (NFC)

16 months ago[ExecutionEngine] Remove unused declaration executeCastOperation
Kazu Hirata [Sun, 11 Jun 2023 20:19:25 +0000 (13:19 -0700)]
[ExecutionEngine] Remove unused declaration executeCastOperation

The corresponding function definition was removed by:

  commit 7a9c62baa66ae262755db0d3221ce095d48681d5
  Author: Reid Spencer <rspencer@reidspencer.com>
  Date:   Fri Jan 12 07:05:14 2007 +0000

16 months ago[FuzzMutate] Remove unused declaration chooseType
Kazu Hirata [Sun, 11 Jun 2023 20:19:23 +0000 (13:19 -0700)]
[FuzzMutate] Remove unused declaration chooseType

The declaration was added without a corresponding function definition
by:

  commit 7d449d31a4d2fe393e32be7c478c18b16b301428
  Author: Justin Bogner <mail@justinbogner.com>
  Date:   Mon Aug 21 22:57:06 2017 +0000

16 months agoDo not unnecessarily include StringSwitch.h
Kazu Hirata [Sun, 11 Jun 2023 20:19:22 +0000 (13:19 -0700)]
Do not unnecessarily include StringSwitch.h

16 months ago[ProfileData] Remove unused class SoftInstrProfErrors
Kazu Hirata [Sun, 11 Jun 2023 20:19:20 +0000 (13:19 -0700)]
[ProfileData] Remove unused class SoftInstrProfErrors

The last use was removed by:

  commit 98cce00371d271c9da8de806e4cc4c886a85d56c
  Author: David Blaikie <dblaikie@gmail.com>
  Date:   Mon Jul 10 03:04:59 2017 +0000

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

16 months ago[Scalar] Remove RewriteStatepointsForGCLegacyPass
Kazu Hirata [Sun, 11 Jun 2023 20:19:19 +0000 (13:19 -0700)]
[Scalar] Remove RewriteStatepointsForGCLegacyPass

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

16 months ago[AArch64][ARM][X86] Split XRay tests for Linux/macOS
Oleksii Lozovskyi [Sun, 11 Jun 2023 19:53:29 +0000 (12:53 -0700)]
[AArch64][ARM][X86] Split XRay tests for Linux/macOS

XRay instrumentation works for macOS running on Apple Silicon, but
codegen is untested there. I'm going to make changes affecting this
target, get the XRay tests running on AArch64.

Data sections are going to become slightly different on x86_64 soon.
I do want the tests to be specific about symbol names, so instead of
having test check the common step, bifurcate tests a bit and check
the full symbol names.

As for ARM, XRay is not really supported on iOS at the moment, though
ARM is also really used there with modern phones. Nevertheless, codegen
tests exist and the output is going to change a little, make it easier
to write the special case for iOS.

Reviewed By: MaskRay

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

16 months ago[Driver] Simplify xray options
Fangrui Song [Sun, 11 Jun 2023 19:03:08 +0000 (12:03 -0700)]
[Driver] Simplify xray options

Also add driver test missed by D87953 (-fxray-function-groups=).
(test/Driver/XRay/lit.local.cfg misunderstands how driver testing works.
We place the test in test/Driver instead.)

16 months ago[libc++][spaceship] P1614R2: Removed ops from `unordered_multiset`, `unordered_set`
Hristo Hristov [Sun, 11 Jun 2023 05:39:49 +0000 (08:39 +0300)]
[libc++][spaceship] P1614R2: Removed ops from `unordered_multiset`, `unordered_set`

Implements parts of P1614R2:
- Removed ops from `unordered_multiset`,
- Removed ops from `unordered_set`

Reviewed By: #libc, Mordante

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

16 months ago[Driver] Simplify -fxray-instrument handling
Fangrui Song [Sun, 11 Jun 2023 18:19:02 +0000 (11:19 -0700)]
[Driver] Simplify -fxray-instrument handling

16 months ago[GlobalIsel][X86] Ensure bit count legalizer patterns keep matching result + input...
Simon Pilgrim [Sun, 11 Jun 2023 16:51:50 +0000 (17:51 +0100)]
[GlobalIsel][X86] Ensure bit count legalizer patterns keep matching result + input scalar types

16 months ago[Driver] Place -ffixed-r19 and some -m* options in m_Group
Fangrui Song [Sun, 11 Jun 2023 17:06:39 +0000 (10:06 -0700)]
[Driver] Place -ffixed-r19 and some -m* options in m_Group

For these -m* options, there is no behavior difference other than
documentation difference (Target-dependent compilation options).

16 months ago[libc++][spaceship] P1614R2: Removed ops from `complex`
Hristo Hristov [Sat, 10 Jun 2023 09:44:03 +0000 (12:44 +0300)]
[libc++][spaceship] P1614R2: Removed ops from `complex`

Implements parts of P1614R2:
- Removed ops from `complex`

Reviewed By: #libc, Mordante

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

16 months ago[libc++][spaceship] P1614R2: Added `operator==` to `slice`
Hristo Hristov [Sat, 10 Jun 2023 10:58:56 +0000 (13:58 +0300)]
[libc++][spaceship] P1614R2: Added `operator==` to `slice`

Implements parts of P1614R2:
- Added `operator==` to `slice`

Reviewed By: #libc, Mordante

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

16 months ago[libc++][spaceship] P1614R2: Removed ops from `memory_resource`, `polymorphic_allocator`
Hristo Hristov [Sat, 10 Jun 2023 20:31:17 +0000 (23:31 +0300)]
[libc++][spaceship] P1614R2: Removed ops from `memory_resource`, `polymorphic_allocator`

Implements parts of P1614R2
- Removed ops from `memory_resource`
- Removed ops from `polymorphic_allocator`

Reviewed By: #libc, Mordante

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

16 months ago[Driver] Place -mharden-sls= in m_Group
Fangrui Song [Sun, 11 Jun 2023 15:59:42 +0000 (08:59 -0700)]
[Driver] Place -mharden-sls= in m_Group

Fix https://github.com/llvm/llvm-project/issues/63237

With only a link action, we claim all CompileOnly_Group options (including -f*,
-m*, -i*, etc). -mharden-sls= is not in a Group and therefore not claimed,
leading to a spurious -Wunused-command-line-argument warning, and after
5548843d692a92a7840f14002debc3cebcb3cdc3, an error.

16 months ago[IPO] Remove unused forward declarations
Kazu Hirata [Sun, 11 Jun 2023 15:45:07 +0000 (08:45 -0700)]
[IPO] Remove unused forward declarations

16 months ago[clang-tidy] Check functions called from catch blocks
Deniz Evrenci [Wed, 7 Jun 2023 00:31:13 +0000 (01:31 +0100)]
[clang-tidy] Check functions called from catch blocks

These functions can rethrow a current exception that is caught by the
catch block. We can pass the currently caught excections to the function
declaration analyzer just like the statement analyzer to handle this
case.

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

16 months ago[InstCombine] Remove unused function createInstructionCombiningPass
Kazu Hirata [Sun, 11 Jun 2023 14:56:37 +0000 (07:56 -0700)]
[InstCombine] Remove unused function createInstructionCombiningPass

The last use was removed by:

  commit 934c82d31801e65aa3bbe99a0e64f903621c2e04
  Author: Florian Hahn <flo@fhahn.com>
  Date:   Fri Feb 24 13:39:32 2023 +0100

Once I remove createInstructionCombiningPass, then:

InstructionCombiningPass::InstructionCombiningPass(unsigned MaxIterations)

becomes unused.  Once I remove that:

InstructionCombiningPass::MaxIterations is always initialized with
InstCombineDefaultMaxIterations, so this patch does the constant
propagation and removes InstructionCombiningPass::MaxIterations as
well.

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

16 months ago[ConstraintElimination] Handle `ICMP_EQ` predicates
Antonio Frighetto [Sat, 10 Jun 2023 16:49:33 +0000 (18:49 +0200)]
[ConstraintElimination] Handle `ICMP_EQ` predicates

Simplification of equality predicates is now supported by
transferring equalities into inequalities. This is achieved
by separately checking that both `isConditionImplied(A >= B)`
and `isConditionImplied(A <= B)` hold.

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

16 months ago[NFC] Replace ;; with ;
David Green [Sun, 11 Jun 2023 09:25:24 +0000 (10:25 +0100)]
[NFC] Replace ;; with ;

16 months ago[RISCV][NFC] Fix typo in RISCVAsmPrinter::emitNTLHint
Yingwei Zheng [Sun, 11 Jun 2023 08:42:01 +0000 (16:42 +0800)]
[RISCV][NFC] Fix typo in RISCVAsmPrinter::emitNTLHint

16 months ago[AArch64] Make VECREDUCE_FMIN/FMAX legal. NFCI
David Green [Sun, 11 Jun 2023 08:42:34 +0000 (09:42 +0100)]
[AArch64] Make VECREDUCE_FMIN/FMAX legal. NFCI

VECREDUCE_FMIN/FMAX wil be lowered to fminnmv/fmaxnmv. They needn't be custom
lowered through an intrinsic to do it, and can be treated as Legal instead.

16 months ago[libcxx] Use the unoptimized routines for volatile source types
AdityaK [Sun, 11 Jun 2023 06:10:23 +0000 (23:10 -0700)]
[libcxx] Use the unoptimized routines for volatile source types

As reported in: D147741

Reviewers: philnik, var-const, ldionne, hans

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

16 months ago[ObjectYAML] Remove unused struct DebugSubsectionState
Kazu Hirata [Sun, 11 Jun 2023 04:52:52 +0000 (21:52 -0700)]
[ObjectYAML] Remove unused struct DebugSubsectionState

The last use was removed by:

  commit a3da4467fa8ed514130736c6c15f01422159d00d
  Author: Zachary Turner <zturner@google.com>
  Date:   Wed Jun 14 05:31:00 2017 +0000

16 months ago[Scalar] Remove unused function createLICMPass
Kazu Hirata [Sun, 11 Jun 2023 04:52:50 +0000 (21:52 -0700)]
[Scalar] Remove unused function createLICMPass

The last use was removed by:

  commit d623b2f95fd559901f008a0588dddd0949a8db01
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Fri Mar 10 17:24:19 2023 -0800

16 months ago[CodeGen] Remove unused declaration createNVPTXRuntimeFunction
Kazu Hirata [Sun, 11 Jun 2023 04:52:49 +0000 (21:52 -0700)]
[CodeGen] Remove unused declaration createNVPTXRuntimeFunction

The corresponding definition was removed by:

  commit 3cc1f1fc1d97952136185f4eafb827694875de17
  Author: Joseph Huber <jhuber6@vols.utk.edu>
  Date:   Thu Oct 8 12:03:11 2020 -0400

16 months ago[Transforms] Remove unused declaration createGVExtractionPass
Kazu Hirata [Sun, 11 Jun 2023 04:52:47 +0000 (21:52 -0700)]
[Transforms] Remove unused declaration createGVExtractionPass

The corresponding function definition was removed by:

  commit 2118b9d39b91e93c0146611235072cd6ca0f27b1
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Tue Dec 20 12:55:05 2022 -0800

16 months ago[TableGen] Fix indentation. NFC
Michael Liao [Sun, 11 Jun 2023 02:03:33 +0000 (22:03 -0400)]
[TableGen] Fix indentation. NFC

16 months ago[llvm] Remove unused declarations initialize.*Pass
Kazu Hirata [Sun, 11 Jun 2023 02:21:00 +0000 (19:21 -0700)]
[llvm] Remove unused declarations initialize.*Pass

16 months ago[AVR] Optimize 8-bit rotation when rotation bits == 3
Ben Shi [Sun, 11 Jun 2023 00:41:44 +0000 (08:41 +0800)]
[AVR] Optimize 8-bit rotation when rotation bits == 3

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

Reviewed By: aykevl

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

16 months ago[AVR] Optimize 8-bit rotation when rotation bits >= 4
Ben Shi [Sun, 11 Jun 2023 00:36:16 +0000 (08:36 +0800)]
[AVR] Optimize 8-bit rotation when rotation bits >= 4

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

Reviewed By: aykevl, Patryk27, jacquesguan

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

16 months ago[Transforms] Remove AddDiscriminatorsLegacyPass
Kazu Hirata [Sat, 10 Jun 2023 22:32:47 +0000 (15:32 -0700)]
[Transforms] Remove AddDiscriminatorsLegacyPass

The last use was removed by:

  commit ae0987d242e266847f21f5fa1bffa97ce3eff586
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sat Jun 10 13:51:35 2023 -0700

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

16 months ago[Scalar] Remove CallSiteSplittingLegacyPass
Kazu Hirata [Sat, 10 Jun 2023 22:20:40 +0000 (15:20 -0700)]
[Scalar] Remove CallSiteSplittingLegacyPass

The last use was removed by:

  commit fd48d0a0adaa5fcdd24d02a58ba8a6210adafc28
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sat Jun 10 13:51:37 2023 -0700

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