platform/upstream/llvm.git
17 months ago[X86] combineINSERT_SUBVECTOR - fold (insert_subvector X, (insert_subvector undef...
Simon Pilgrim [Sun, 5 Feb 2023 13:07:20 +0000 (13:07 +0000)]
[X86] combineINSERT_SUBVECTOR - fold (insert_subvector X, (insert_subvector undef, Y, 0), Idx) -> (insert_subvector X, Y, Idx)

Helps some shuffle combines that do a poor job of peeking through (insert_subvector undef, Y, 0) vector widening patterns

17 months agoInstCombine: Perform basic isnan combines on llvm.is.fpclass
Matt Arsenault [Fri, 11 Nov 2022 00:15:34 +0000 (16:15 -0800)]
InstCombine: Perform basic isnan combines on llvm.is.fpclass

is.fpclass(x, qnan|snan) -> fcmp uno x, 0.0
is.fpclass(nnan x, qnan|snan|other) -> is.fpclass(x, other)

Start porting the existing combines from llvm.amdgcn.class to the
generic intrinsic. Start with the ones which aren't dependent on the
FP mode.

17 months ago[SVE][Builtins] Lower X forms of binop arithmetic builtins to dedicated intrinsics.
Paul Walker [Sun, 15 Jan 2023 15:21:20 +0000 (15:21 +0000)]
[SVE][Builtins] Lower X forms of binop arithmetic builtins to dedicated intrinsics.

This patch changes the lowering for the following builtins to emit
calls to the new aarch64.sve.###.u intrinsics.
  svabd_x
  svabd_n_x
  svadd_x
  svadd_n_x
  svasr_x
  svasr_n_x
  svdiv_x
  svdiv_n_x
  svdivr_x
  svdivr_n_x
  svlsl_x
  svlsl_n_x
  svlsr_x
  svlsr_n_x
  svmax_x
  svmax_n_x
  svmin_x
  svmin_n_x
  svmul_x
  svmul_n_x
  svmulh_x
  svmulh_n_x
  svsub_x
  svsub_n_x
  svsubr_x
  svsubr_n_x

Depends on D141938

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

17 months agoLangRef: Clarify behavior of llvm.is.fpclass with "denormal-fp-math"
Matt Arsenault [Tue, 6 Dec 2022 14:16:27 +0000 (09:16 -0500)]
LangRef: Clarify behavior of llvm.is.fpclass with "denormal-fp-math"

This does not read canonicalized values, which matches the behavior of
the basic DAG expansion using integer operations. There is a buggy
expansion using FP-operations if legal which needs to be adjusted to
account for this. We need to be aware of the denormal mode to switch
between is.fpclass calls and fcmp.

There's no real spec for denormal handling anywhere, but I believe
this is the most harmonious way to deal with the question considering
the requirement to not quiet input signaling nans.

This matches the behavior of MSVC's _fpclass and AMDGPU's
v_cmp_class_f32. fpclassify currently does not use this, and has
inconsistent behavior for denormals under DAZ on different platforms
(i.e. clang and gcc report FP_ZERO return FP_ZERO for a denormal under
DAZ, MSVC reports FP_SUBNORMAL).

17 months agoIROutliner: Fix another assert with non-0 alloca addrspaces
Matt Arsenault [Thu, 5 Jan 2023 16:00:35 +0000 (11:00 -0500)]
IROutliner: Fix another assert with non-0 alloca addrspaces

Code is inserting an addrspacecast it shouldn't be, but
that's a separate CodeExtractor bug.

This also stops caring about typed pointers.

17 months ago[DAG] Add visitABD optimizations
David Green [Sun, 5 Feb 2023 10:28:54 +0000 (10:28 +0000)]
[DAG] Add visitABD optimizations

This adds basic a visitABD to optimize ABDS and ABDU nodes, similar to the
existing visitAVG method.

The fold I was initially interested in was folding shuffles though the binop.
This also:
- Marks ABDS and ABDU as commutative binops (https://alive2.llvm.org/ce/z/oCDogb
  and https://alive2.llvm.org/ce/z/7zrs86).
- Add reassociative folds.
- Add constant folding using max(x,y)-min(x,y)
- Canonicalizes constants to the RHS
- Folds abds x, 0 -> abs(x) (https://alive2.llvm.org/ce/z/4ZEibv)
- Folds abdu x, 0 -> x (https://alive2.llvm.org/ce/z/J_rKqx)
- Folds abd x, undef -> 0 (https://alive2.llvm.org/ce/z/NV6Nsv and
  https://alive2.llvm.org/ce/z/vs92hu).

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

17 months ago[ORC] Drop Comdat when discarding IR symbol
Jonas Hahnfeld [Tue, 24 Jan 2023 09:54:55 +0000 (10:54 +0100)]
[ORC] Drop Comdat when discarding IR symbol

According to the IR verifier, "Declaration[s] may not be in a Comdat!"

This is a re-commit of 76b3f0b4d5a0b8c54147c4c73a30892bbca76467 and
87d7838202267a011639fcbf97263556ccf091dc with updates to the test:
 * Force emission of the extra-module, to trigger the bug after D138264,
   by providing a second symbol @g, and making the comdat nodeduplicate.
   (Technically only one is needed, but two should be safer.)
 * Name the comdat $f to avoid failure on Windows:
   LLVM ERROR: Associative COMDAT symbol 'c' does not exist.
 * Mark the test as UNSUPPORTED on macOS, MachO doesn't support COMDATs.

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

17 months ago[AArch64] AArch64ExpandImm.cpp - fix MSVC "32-bit shift implicitly converted to 64...
Simon Pilgrim [Sun, 5 Feb 2023 09:38:15 +0000 (09:38 +0000)]
[AArch64] AArch64ExpandImm.cpp - fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFC.

17 months agoAMDGPU: Ensure flat loads are broken into dword in functions
Matt Arsenault [Thu, 26 Jan 2023 00:46:44 +0000 (20:46 -0400)]
AMDGPU: Ensure flat loads are broken into dword in functions

We were assuming we could rely on the flat scratch init detection
to imply if there are possible flat addressed stack objects, which
doesn't work outside of a kernel. We should have a way to prove
if a given flat access can't access the stack.

We could use a not-stack parameter attribute to avoid
these splits.

Make the minimally correct change for GlobalISel; I'll address
this better in my larger patch to rewrite load and store legalization.

Fixes: SWDEV-218237

17 months ago[ORC] Use JITLink as the default linker for LLJIT on Linux/arm64.
Lang Hames [Sun, 5 Feb 2023 03:36:40 +0000 (03:36 +0000)]
[ORC] Use JITLink as the default linker for LLJIT on Linux/arm64.

Also updates the OrcCAPIsTest unit test to enable the C API tests on Linux.

17 months agoTeach the AArch64 backend to materialize immediates using a pair of ORR-immediate
Owen Anderson [Wed, 4 Jan 2023 06:23:31 +0000 (23:23 -0700)]
Teach the AArch64 backend to materialize immediates using a pair of ORR-immediate
instructions.

Credit to czwarich for figuring out the algorithm to test for this.

Re-applied with fix for ubsan error on out-of-range shift.

Reviewed By: dmgreen

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

17 months agoRevert "Teach the AArch64 backend to materialize immediates using a pair of ORR-immed...
Owen Anderson [Sun, 5 Feb 2023 04:13:31 +0000 (22:13 -0600)]
Revert "Teach the AArch64 backend to materialize immediates using a pair of ORR-immediate"

This reverts commit 8d433a0ae55ac25ba0a77d733e1ee5e23d1eb9f7 due to test failures on
CodeGen/AArch64/GlobalISel/store-merging.ll

17 months ago[CMake] Process components and install targets separately
Petr Hosek [Sun, 5 Feb 2023 02:43:54 +0000 (02:43 +0000)]
[CMake] Process components and install targets separately

This addresses issue introduced accidentally in D117263.

17 months agoTeach the AArch64 backend to materialize immediates using a pair of ORR-immediate
Owen Anderson [Wed, 4 Jan 2023 06:23:31 +0000 (23:23 -0700)]
Teach the AArch64 backend to materialize immediates using a pair of ORR-immediate
instructions.

Credit to czwarich for figuring out the algorithm to test for this.

Reviewed By: dmgreen

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

17 months ago[RISCV] Move all isel cases for ISD::ConstantFP into RISCVDAGToDAGISel::Select.
Craig Topper [Sun, 5 Feb 2023 01:31:37 +0000 (17:31 -0800)]
[RISCV] Move all isel cases for ISD::ConstantFP into RISCVDAGToDAGISel::Select.

After D142953, non-zero cases were handled in RISCVDAGToDAGISel::Select
and zeros were handled with isel patterns. The zeros cases are
sufficiently similar to zero that we might as well handle them all
together. We already needed to detect the cases to skip out to
tablegen.

17 months ago[RISCV] Fix crash splatting f64 -0.0 into a vector on RV32 after D142953.
Craig Topper [Sat, 4 Feb 2023 21:35:58 +0000 (13:35 -0800)]
[RISCV] Fix crash splatting f64 -0.0 into a vector on RV32 after D142953.

For RV32, we now use scalar fcvt of x0, scalar fneg, splat scalar fp to vector.
For RV64, we use li of 1, slli by 63, splat GPR to vector.

17 months ago[RISCV] Make selectImm return SDValue instead of SDNode*.
Craig Topper [Sat, 4 Feb 2023 21:14:51 +0000 (13:14 -0800)]
[RISCV] Make selectImm return SDValue instead of SDNode*.

This avoids multiple places needing to convert it to SDValue. It's
simpler to convert it to SDNode * in the places that need it.

17 months ago[RISCV] Replace condition that should alwasy be true with an assert. NFC
Craig Topper [Sat, 4 Feb 2023 21:01:21 +0000 (13:01 -0800)]
[RISCV] Replace condition that should alwasy be true with an assert. NFC

17 months ago[RISCV] Use MVT enum directly instead of converting to bit width. NFC
Craig Topper [Sat, 4 Feb 2023 20:50:02 +0000 (12:50 -0800)]
[RISCV] Use MVT enum directly instead of converting to bit width. NFC

17 months ago[RISCV] Remove fimmneg0 patterns that were replaced by D142953.
Craig Topper [Sat, 4 Feb 2023 20:38:19 +0000 (12:38 -0800)]
[RISCV] Remove fimmneg0 patterns that were replaced by D142953.

17 months ago[libc++][NFC] Rename _LIBCPP_EXPLICIT_AFTER_CXX11 to _LIBCPP_EXPLICIT_SINCE_CXX14
Nikolas Klauser [Thu, 2 Feb 2023 11:12:28 +0000 (12:12 +0100)]
[libc++][NFC] Rename _LIBCPP_EXPLICIT_AFTER_CXX11 to _LIBCPP_EXPLICIT_SINCE_CXX14

We renamed the `_LIBCPP_CONSTEXPR_` a while ago. This matches the change for `_LIBCPP_EXPLICIT_`.

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

17 months ago[libc++][NFC] Rename _LIBCPP_NO_RTTI to _LIBCPP_HAS_NO_RTTI
Nikolas Klauser [Thu, 2 Feb 2023 11:06:35 +0000 (12:06 +0100)]
[libc++][NFC] Rename _LIBCPP_NO_RTTI to _LIBCPP_HAS_NO_RTTI

Other macros that disable parts of the library are named `_LIBCPP_HAS_NO_WHATEVER`.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

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

17 months ago[CMake] Support runtimes targets without specifying triple
Petr Hosek [Wed, 30 Jun 2021 06:34:18 +0000 (23:34 -0700)]
[CMake] Support runtimes targets without specifying triple

Currently, for BUILTIN_TARGETS and RUNTIME_TARGETS you can either use
the special "default" value, or a target triple.

For the "default" value, we don't set any target triple and passthrough
a subset of CMake variables into the subbuild. This is typically used
on Darwin where we build universal binaries and a single target triple
therefore isn't sufficient.

For the target triple value, you can set arbitrary CMake variables
through RUNTIMES_<target>_<variable>, but we always set target triple
to <target>. This gives more flexibility, because we can precisely
control what variables are set in the subbuild, but is unsuitable for
platforms like Darwin.

To address this, we would like to introduce a third option which is
similar to the second option, except we won't set target triple in
the subbuild (you can always do so yourself by setting the appropriate
CMake variable, e.g. RUNTIMES_<name>_CMAKE_C_COMPILER_TARGET=<triple>).

This change is a first step in that direction, by eliminating the support
of target triples from builtin_register_target and runtime_register_target
helper functions.

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

17 months agocmake: Enable 64bit off_t on 32bit glibc systems
Khem Raj [Sat, 4 Feb 2023 21:54:41 +0000 (13:54 -0800)]
cmake: Enable 64bit off_t on 32bit glibc systems

Pass -D_FILE_OFFSET_BITS=64 to compiler flags on 32bit glibc based
systems. This will make sure that 64bit versions of LFS functions are
used e.g. seek will behave same as lseek64. Also revert [1] partially
because this added a cmake test to detect lseek64 but then forgot to
pass the needed macro to actual compile, this test was incomplete too
since libc implementations like musl has 64bit off_t by default on 32bit
systems and does not bundle[2] -D_LARGEFILE64_SOURCE under -D_GNU_SOURCE
like glibc, which means the compile now fails on musl because the cmake
check passes but we do not have _LARGEFILE64_SOURCE defined. Using the
*64 function was transitional anyways so use -D_FILE_OFFSET_BITS=64
instead

[1] https://github.com/llvm/llvm-project/commit/8db7e5e4eed4c4e697dc3164f2c9351d8c3e942b
[2] https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc

Reviewed By: MaskRay

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

17 months ago[clang-linker-wrapper] Fix build after MapVector change
Fangrui Song [Sat, 4 Feb 2023 20:54:26 +0000 (12:54 -0800)]
[clang-linker-wrapper] Fix build after MapVector change

17 months ago[DAG] visitFREEZE - handle case where the folded node merges with another existing...
Simon Pilgrim [Sat, 4 Feb 2023 20:53:42 +0000 (20:53 +0000)]
[DAG] visitFREEZE - handle case where the folded node merges with another existing node

Fixes #60413

17 months ago[LV] Add users for loads to make tests more robust.
Florian Hahn [Sat, 4 Feb 2023 20:42:50 +0000 (20:42 +0000)]
[LV] Add users for loads to make tests more robust.

Update a few tests to add users to loads to avoid them being optimized
out by future changes. In cases the unused loads didn't matter for the
test, remove them.

17 months agoOffloadBinary: Switch to MapVector<StringRef, StringRef> to stabilize iteration order
Fangrui Song [Sat, 4 Feb 2023 20:34:55 +0000 (12:34 -0800)]
OffloadBinary: Switch to MapVector<StringRef, StringRef> to stabilize iteration order

D122069 incorrectly uses StringMap iteration order
(https://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h).
Switch to MapVector.

17 months agoRevert "[ORC] Drop Comdat when discarding IR symbol"
Jonas Hahnfeld [Sat, 4 Feb 2023 20:24:44 +0000 (21:24 +0100)]
Revert "[ORC] Drop Comdat when discarding IR symbol"

A number of AArch64 bots report errors in clang-repl, for example
https://lab.llvm.org/buildbot/#/builders/197/builds/3920

This reverts commit 87d7838202267a011639fcbf97263556ccf091dc.

17 months ago[lld] fix comment typos to cycle bots
Nico Weber [Sat, 4 Feb 2023 20:23:24 +0000 (15:23 -0500)]
[lld] fix comment typos to cycle bots

17 months ago[mlgo] Bump the unsupported versions for interactive tests to 3.8
Mircea Trofin [Sat, 4 Feb 2023 20:15:48 +0000 (12:15 -0800)]
[mlgo] Bump the unsupported versions for interactive tests to 3.8

e006c7dfa79a already covered the regalloc one.

17 months ago[sanitizer] Simplify with GET_CALLER_PC_BP. NFC
Fangrui Song [Sat, 4 Feb 2023 19:30:14 +0000 (11:30 -0800)]
[sanitizer] Simplify with GET_CALLER_PC_BP. NFC

17 months ago[AArch64] Add ABD combine tests. NFC
David Green [Sat, 4 Feb 2023 19:18:50 +0000 (19:18 +0000)]
[AArch64] Add ABD combine tests. NFC

17 months ago[X86] combinePredicateReduction - pull out repeated DAG.getContext() calls. NFC.
Simon Pilgrim [Sat, 4 Feb 2023 18:31:20 +0000 (18:31 +0000)]
[X86] combinePredicateReduction - pull out repeated DAG.getContext() calls. NFC.

17 months agoRevert "[Sanitizers] Fix read buffer overrun in scanning loader commands"
Douglas Yung [Sat, 4 Feb 2023 18:18:58 +0000 (10:18 -0800)]
Revert "[Sanitizers] Fix read buffer overrun in scanning loader commands"

This reverts commit abbd4da2043856f443e3d1c8d2c7627cac93a6ac.

This change is breaking many bots including:
- http://45.33.8.238/linux/98629/step_10.txt
- https://buildkite.com/llvm-project/llvm-main/builds/6461#01861c4f-9d9c-4781-88f7-d6ccddcb4b06/919-8848
- https://lab.llvm.org/buildbot/#/builders/94/builds/13196
- https://lab.llvm.org/buildbot/#/builders/45/builds/10633
- https://lab.llvm.org/buildbot/#/builders/247/builds/1238
- https://lab.llvm.org/buildbot/#/builders/70/builds/33424
- https://lab.llvm.org/buildbot/#/builders/168/builds/11693
- https://lab.llvm.org/buildbot/#/builders/74/builds/17006
- https://lab.llvm.org/buildbot/#/builders/85/builds/14120

17 months ago[LV] Add initial tests for sinking loads past other instructions.
Florian Hahn [Sat, 4 Feb 2023 18:18:17 +0000 (18:18 +0000)]
[LV] Add initial tests for sinking loads past other instructions.

Extend test coverage for sinking loads that use fixed order recurrences.

17 months ago[compiler-rt] Fix FORTIFY_SOURCE -> _FORTIFY_SOURCE reference (NFC)
Sam James [Sat, 4 Feb 2023 18:04:54 +0000 (18:04 +0000)]
[compiler-rt] Fix FORTIFY_SOURCE -> _FORTIFY_SOURCE reference (NFC)

As pointed out by maskray.

Fixes: 8ab762557fb057af1a3015211ee116a975027e78

17 months ago[compiler-rt] Disable default config files for tests
Sam James [Sat, 4 Feb 2023 18:04:05 +0000 (18:04 +0000)]
[compiler-rt] Disable default config files for tests

Without this, if hardening measures like FORTIFY_SOURCE are are in
/etc/clang/*.cfg, many sanitizer tests will die before the sanitizer
can trap the problem being tested, because e.g. the _chk variants
of common functions will abort first.

This gets the number of failing tests down from 42->3 for me (and the
remaining 3 are unrelated).

See: 52ce6776cf98e993c6ec04ae54b52e1354fff917
See: 136f77805fd89cd30e69b3d1204fbf7efedd9a12
Closes: https://github.com/llvm/llvm-project/issues/60394

Reviewed By: MaskRay

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

17 months ago[TableGen] Error.h - remove quotes to silence clang-tidy llvm-namespace-comment warning
Simon Pilgrim [Sat, 4 Feb 2023 17:31:52 +0000 (17:31 +0000)]
[TableGen] Error.h - remove quotes to silence clang-tidy llvm-namespace-comment warning

17 months ago[ADT] STLFunctionalExtras.h - fix llvm-include-order clang-tidy warning
Simon Pilgrim [Sat, 4 Feb 2023 17:30:14 +0000 (17:30 +0000)]
[ADT] STLFunctionalExtras.h - fix llvm-include-order clang-tidy warning

17 months ago[AArch64][GlobalISel] Selection for i8 buildvectors
David Green [Sat, 4 Feb 2023 16:11:29 +0000 (16:11 +0000)]
[AArch64][GlobalISel] Selection for i8 buildvectors

Legalization for i8 buildvectors is available (as in
615695de27e417d6b444cd983e6f636373afc8c9), but selection
would fail due to i8 types not being handled. This adds
basic support like other type sizes.

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

17 months ago[X86] combinePredicateReduction - fold any_of(setcc(x,y,ne)) -> pmovmskb(not(pcmpeqb()))
Simon Pilgrim [Sat, 4 Feb 2023 15:06:12 +0000 (15:06 +0000)]
[X86] combinePredicateReduction - fold any_of(setcc(x,y,ne)) -> pmovmskb(not(pcmpeqb()))

Improves codegen for v2i64 cases, similar to what we already do for all_of(setcc(x,y,eq))

17 months ago[X86] pr53419.ll - add missing v2i8/v4i8/v8i8 coverage to reduction tests
Simon Pilgrim [Sat, 4 Feb 2023 14:56:14 +0000 (14:56 +0000)]
[X86] pr53419.ll - add missing v2i8/v4i8/v8i8 coverage to reduction tests

17 months ago[mlir][SCF] Disallow multiple blocks in scf.if "else" region
Matthias Springer [Sat, 4 Feb 2023 14:44:20 +0000 (15:44 +0100)]
[mlir][SCF] Disallow multiple blocks in scf.if "else" region

The "then" region allows only a single block. The same should be the case for the "else" region.

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

17 months ago[GlobalISel] Enable patterns with multiple output operands for the GlobalISelEmitter
Remi Segard [Sat, 4 Feb 2023 12:23:46 +0000 (08:23 -0400)]
[GlobalISel] Enable patterns with multiple output operands for the GlobalISelEmitter

This enables writing patterns with mutliple output operands in the input pattern for GlobalISel

17 months ago[X86] Swap bool reduction predicates in v2i64/v4i32 tests
Simon Pilgrim [Sat, 4 Feb 2023 13:59:57 +0000 (13:59 +0000)]
[X86] Swap bool reduction predicates in v2i64/v4i32 tests

The v2i64 case has more scope for optimization with ne than ugt cases, and we already have very similar icmp sgt coverage via the v4i64 tests

17 months ago[Libomptarget] Add the same to the other AMD plugin
Samuel Thibault [Sat, 4 Feb 2023 13:46:25 +0000 (07:46 -0600)]
[Libomptarget] Add the same to the other AMD plugin

Summary:
The previous patch also needed to apply this to the other AMDGPU plugin,
this will be removed soon but it should be correct while it's here at
least.

17 months ago[Libomptarget] Fix disabling amdgpu on non-Linux.
Samuel Thibault [Sat, 4 Feb 2023 13:44:25 +0000 (07:44 -0600)]
[Libomptarget] Fix disabling amdgpu on non-Linux.

Previously, on non-Linux, amdgpu would get enabled whatever the CPU architecture.

Reviewed By: jhuber6

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

17 months ago[AArch64] Add tests for inefficient generation of ST2s. NFC
David Green [Sat, 4 Feb 2023 13:10:45 +0000 (13:10 +0000)]
[AArch64] Add tests for inefficient generation of ST2s. NFC

17 months agoAMDGPU: Add some regression tests that infinite looped combiner
Matt Arsenault [Sat, 4 Feb 2023 12:09:16 +0000 (08:09 -0400)]
AMDGPU: Add some regression tests that infinite looped combiner

Prevent a future patch from introducing an infinite combine loop.

17 months ago[SVE][CodeGen] Relax all true isel requirement for predicated operations that have...
Paul Walker [Mon, 16 Jan 2023 01:37:50 +0000 (01:37 +0000)]
[SVE][CodeGen] Relax all true isel requirement for predicated operations that have no side effects.

We have isel patterns to allow predicated operations to emit
unpredicated instructions when the predicate is all true. However,
the predicated operations named #_PRED have no requirement for the
result of the inactive lanes and so when those operations have no
side effects, floating point exceptions for example, we can also
safely emit unpredicated instructions. Doing this allows better
register allocation, instruction scheduling and also enables more
usage of instructions that take immediate operands.

NOTE: This patch does not convert all possible instances but
instead focuses on the cases that are testable once D141937 lands.

Depends on D141937

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

17 months agoRevert "[AArch64] Unconditionally use DW_EH_PE_indirect|DW_EH_PE_pcrel personality...
NAKAMURA Takumi [Sat, 4 Feb 2023 11:49:39 +0000 (20:49 +0900)]
Revert "[AArch64] Unconditionally use DW_EH_PE_indirect|DW_EH_PE_pcrel personality/lsda/ttype encodings"

It causes failurs in clang-interpreter.

This reverts commit 565a1fb1334b8cf510af1338cae3f50815a99f90, aka llvmorg-17-init-1048-g565a1fb1334b

17 months ago[X86] Add basic vector handling for ISD::ABDS/ABDU (absolute difference) nodes
Simon Pilgrim [Sat, 4 Feb 2023 11:25:46 +0000 (11:25 +0000)]
[X86] Add basic vector handling for ISD::ABDS/ABDU (absolute difference) nodes

I'm intending to add generic legalization in the future, but for now I've added basic support to targets that have the necessary MIN/MAX support to expand to SUB(MAX(X,Y),MIN(X,Y)).

This exposed a couple of issues with the DAG combines - in particular we need to catch trunc(abs(sub(ext(x),ext(y)))) patterns earlier before the SSE/AVX vector trunc expansion folds trigger.

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

17 months agollvm/test/CodeGen/MLRegalloc: Exclude python<=3.8 (D143218)
NAKAMURA Takumi [Sat, 4 Feb 2023 11:18:57 +0000 (20:18 +0900)]
llvm/test/CodeGen/MLRegalloc: Exclude python<=3.8 (D143218)

Type hint `list[foo]` isn't accepted by python-3.8
(Seems requires `typing.List`)

17 months ago[PowerPC] aix32-cc-abi-vaarg.ll - improve DAG checks
Simon Pilgrim [Sat, 4 Feb 2023 11:17:36 +0000 (11:17 +0000)]
[PowerPC] aix32-cc-abi-vaarg.ll - improve DAG checks

More closely match the actual output and should make the merge with D127115 easier.

17 months ago[X86][FP16] Lower half->i16 into vcvttph2[u]w directly
Phoebe Wang [Sat, 4 Feb 2023 10:23:39 +0000 (18:23 +0800)]
[X86][FP16] Lower half->i16 into vcvttph2[u]w directly

Reviewed By: LuoYuanke, RKSimon

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

17 months agoUpdate test to be the correct version
Jessica Paquette [Sat, 4 Feb 2023 07:21:34 +0000 (23:21 -0800)]
Update test to be the correct version

machine-outliner-mapping-stats.mir

17 months ago[RISCV] Don't use constantpool for floating-point value if the value can be easily...
Han-Kuan Chen [Tue, 31 Jan 2023 06:40:08 +0000 (22:40 -0800)]
[RISCV] Don't use constantpool for floating-point value if the value can be easily constructed by integer sequence and a floating-point move.

In addition, this commit does the following combine

vfmv.v.f + fmv.[dhw].x -> vmv.v.x
vfmv.s.f + fmv.[dhw].x -> vmv.s.x
vfmerge.vfm + fmv.[dhw].x -> vmerge.vxm

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

17 months ago[MachineOutliner] Improve mapper statistics
Jessica Paquette [Sat, 4 Feb 2023 06:26:07 +0000 (22:26 -0800)]
[MachineOutliner] Improve mapper statistics

Add a test for statistics as well.

The mapper size stats were nested in a loop unnecessarily. Move them out.

Give existing stats better names, and add one which also tracks the number of
sentinels added.

17 months ago[Driver] Remove deprecated -fsanitize-system-blacklist=
Fangrui Song [Sat, 4 Feb 2023 06:06:34 +0000 (22:06 -0800)]
[Driver] Remove deprecated -fsanitize-system-blacklist=

Unused in the wild.

17 months ago[MachineOutliner] NFC: Add debug output to populateMapper
Jessica Paquette [Sat, 4 Feb 2023 05:59:16 +0000 (21:59 -0800)]
[MachineOutliner] NFC: Add debug output to populateMapper

Adding debug output to improve outliner debuggability + testability.

Move `nooutline` attribute test into the new debug output test.

17 months agoRevert "[mlir][linalg] Make Linalg vectorizer lower affine.apply"
Diego Caballero [Sat, 4 Feb 2023 05:18:48 +0000 (05:18 +0000)]
Revert "[mlir][linalg] Make Linalg vectorizer lower affine.apply"

This reverts commit c7b1176e9afbfcc3da9482abbf7c1eb8793ff254.

17 months agoRevert "[mlir][linalg] Fix crash in vectorizer when expanding affine apply"
Diego Caballero [Sat, 4 Feb 2023 05:16:46 +0000 (05:16 +0000)]
Revert "[mlir][linalg] Fix crash in vectorizer when expanding affine apply"

This reverts commit 62570b722fa36fddde0d24bf06a245efadda66f5.

17 months ago[mlgo] only enable interactive mode tests on linux
Mircea Trofin [Sat, 4 Feb 2023 03:55:12 +0000 (19:55 -0800)]
[mlgo] only enable interactive mode tests on linux

`os.mkfifo` may not be supported everywhere (e.g. windows).

17 months ago[mlgo] Disable mlgo tests when python version is 6
Mircea Trofin [Sat, 4 Feb 2023 03:41:07 +0000 (19:41 -0800)]
[mlgo] Disable mlgo tests when python version is 6

Supporting 3.6 requires a bit too much of a change in the mlgo test python scripts.

17 months ago[AArch64] fix bug #55005 handle DW_CFA_GNU_NegateRAState
Sebastian Pop [Wed, 25 Jan 2023 18:40:48 +0000 (18:40 +0000)]
[AArch64] fix bug #55005 handle DW_CFA_GNU_NegateRAState

GCC on AArch64 uses DW_CFA_GNU_NegateRAState for return address signing.

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

17 months ago[UpdateTestChecks][NFC] Share the code to get CHECK prefix between all scripts
Shengchen Kan [Sat, 4 Feb 2023 01:35:32 +0000 (09:35 +0800)]
[UpdateTestChecks][NFC] Share the code to get CHECK prefix between all scripts

Reviewed By: MaskRay

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

17 months ago[Sanitizers] Fix read buffer overrun in scanning loader commands
Mariusz Borsa [Sat, 4 Feb 2023 01:54:10 +0000 (17:54 -0800)]
[Sanitizers] Fix read buffer overrun in scanning loader commands

The fix only affects Darwin, but to write the test I had to modify
the MemoryMappingLayout class which is used by all OSes,
to allow for mocking of image header (this change should be NFC). Hence no [Darwin] in the subject
so I can get more eyes on it.

While looking for a memory gap to put the shadow area into, the sanitizer code
scans through the loaded images, and for each image it scans through its
loader command to determine the occupied memory ranges.

While doing so, if the 'segment load' (kLCSegment) loader comand is encountered, the command scanning function
returns success (true), but does not decrement the command list iterator counter.
The result is that the function is called again and again, with the iterator counter
now being too high. The command scanner keeps updating the loader command pointer,
by using the command size field.

If the loop counter is too high, the command pointer
lands into unintended area ( beyond <header addr>+sizeof(mac_header64)+header->sizeofcmds ),
and result depends on the random content found there.

The random content interpreted as loader command might contain a large integer value in the
cmdsize field - this value is added to the current loader command pointer,
which might now point to an inaccessible memory address. It can occasionally result
in a crash if it happens to run beyond the mapped memory segment.

Note that when the area after the loader command list
contains zeros or small integers only, the loop will end normally and the problem
will go unnoticed. So it happened until now since having a some big value
after the header area, falling into command size field is a pretty rare situation.

The fix makes sure that the iterator counter gets updated when the segment load (kLCSegment)
loader command is found too, and in the same code location so the updates will always go together.

Undo the changes in the sanitizer_procmaps_mac.cpp to see the test failing.

rdar://101161047
rdar://102819707

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

17 months ago[mlgo] fixes for old python versions
Mircea Trofin [Sat, 4 Feb 2023 02:08:14 +0000 (18:08 -0800)]
[mlgo] fixes for old python versions

17 months ago[mlgo] Fix type annotation in log_reader, for older python3 versions
Mircea Trofin [Sat, 4 Feb 2023 02:03:39 +0000 (18:03 -0800)]
[mlgo] Fix type annotation in log_reader, for older python3 versions

17 months ago[mlir][gpu] Allow distributing to different level of IDs without failing
Thomas Raoux [Fri, 3 Feb 2023 22:53:16 +0000 (22:53 +0000)]
[mlir][gpu] Allow distributing to different level of IDs without failing

Change map_nested_foreach_to_threads to ignore foreach_thread not
mapping to threads, this will allow us to call
mapNestedForeachToThreadsImpl with different set of ids to lower
multiple levels. Also adds warpIds attributes.

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

17 months agoReland "[mlgo] Hook up the interactive runner to the mlgo-ed passes"
Mircea Trofin [Sat, 4 Feb 2023 01:03:11 +0000 (17:03 -0800)]
Reland "[mlgo] Hook up the interactive runner to the mlgo-ed passes"

This reverts commit a772f0bb920a4957fb94dd8dbe45943809fd0ec3.

The main problem was related to how we handled `dbgs()` from the hosted
compiler. Using explicit `subprocess.communicate`, and not relying on
dbgs() being flushed until the end appears to address the problem.

Also some fixes due to some bots running older pythons, so we can't have
nice things like `int | float` and such.

17 months ago[MachineOutliner] NFC: Add debug output to overlap pruning code
Jessica Paquette [Sat, 4 Feb 2023 01:38:56 +0000 (17:38 -0800)]
[MachineOutliner] NFC: Add debug output to overlap pruning code

This had no debug output. Since it was committed as NFC, it had no testcase.

The me of today was nerdsniped by the me of 6 years ago and decided that this
ought to have a testcase and some debug output.

17 months agoWalk back an overly-aggressive unXFAIL.
Adrian Prantl [Sat, 4 Feb 2023 01:22:32 +0000 (17:22 -0800)]
Walk back an overly-aggressive unXFAIL.

17 months agoSimplify looping over Operation users in SliceAnalysis (NFC)
Mehdi Amini [Sat, 4 Feb 2023 00:45:51 +0000 (16:45 -0800)]
Simplify looping over Operation users in SliceAnalysis (NFC)

17 months ago[MachineOutliner] NFC: Pull variable out from erase_if
Jessica Paquette [Sat, 4 Feb 2023 00:28:56 +0000 (16:28 -0800)]
[MachineOutliner] NFC: Pull variable out from erase_if

`Mapper.UnsignedVec.begin()` never changes throughout the call to
`erase_if`, so no need to recalculate it.

Also drop some redundant braces.

17 months ago[NFC] Remove redundant check for MBB being empty in outliner
Jessica Paquette [Sat, 4 Feb 2023 00:19:04 +0000 (16:19 -0800)]
[NFC] Remove redundant check for MBB being empty in outliner

If the size is < 2, then we just break anyway.

17 months ago[NFC] Remove unneccessary `llvm::` in MachineOutliner/SuffixTree
Jessica Paquette [Sat, 4 Feb 2023 00:17:35 +0000 (16:17 -0800)]
[NFC] Remove unneccessary `llvm::` in MachineOutliner/SuffixTree

We have `using llvm`, we don't need to say `llvm::`.

17 months ago[NFC] Use SmallVector/ArrayRef in MachineOutliner/SuffixTree for small types
Jessica Paquette [Sat, 4 Feb 2023 00:08:50 +0000 (16:08 -0800)]
[NFC] Use SmallVector/ArrayRef in MachineOutliner/SuffixTree for small types

The MachineOutliner + SuffixTree both used `std::vector` everywhere because I
didn't know any better at the time.

At least for small types, such as `unsigned` and iterators, I can't see any
particular reason to use std::vector over `SmallVector` here.

17 months agoRevert "[mlgo] Hook up the interactive runner to the mlgo-ed passes"
Mircea Trofin [Sat, 4 Feb 2023 00:34:31 +0000 (16:34 -0800)]
Revert "[mlgo] Hook up the interactive runner to the mlgo-ed passes"

This reverts commit a7354899d1a235a796b3a2ccb45f6596983c8672.

The way stdout/stderr get routed seems to work differently locally and
on the bots. Investigating.

17 months agoUnXFAIL test.
Adrian Prantl [Sat, 4 Feb 2023 00:24:42 +0000 (16:24 -0800)]
UnXFAIL test.

17 months ago[mlgo] Hook up the interactive runner to the mlgo-ed passes
Mircea Trofin [Wed, 1 Feb 2023 16:34:16 +0000 (08:34 -0800)]
[mlgo] Hook up the interactive runner to the mlgo-ed passes

This hooks up the interactive model runner to the passes that support
ml-based decisions. Because the interface to this runner is the exact
same as the one used during inference, we just reuse the exact same
setup we have for "release mode". This makes "release mode" a misnomer -
and that's something we needed to resolve sooner or later (e.g.
supporting more than one embedded model for the same problem was another
reason to drop that nomenclature). That will happen in a subsequent
change.

To use this evaluator, just enable the pass in (currently) "release"
mode, but also pass the base name for the 2 channel files via the
pass-specific flag.

The 2 files are the responsibilty of the hosting process. The added
tests use a minimal, toy such host, illustrating setup and
communication.

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

17 months agoUpgrade llgdb script for Python 3 compatibility.
Adrian Prantl [Sat, 4 Feb 2023 00:05:51 +0000 (16:05 -0800)]
Upgrade llgdb script for Python 3 compatibility.

17 months ago[mlir][sparse] implement bufferizableOpInterface for sparse_tensor.pack operation
Peiming Liu [Fri, 3 Feb 2023 17:31:32 +0000 (17:31 +0000)]
[mlir][sparse] implement bufferizableOpInterface for sparse_tensor.pack operation

Reviewed By: aartbik

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

17 months ago[mlir][sparse] implement lowering rules for sparse_tensor.pack operation
Peiming Liu [Fri, 3 Feb 2023 00:28:12 +0000 (00:28 +0000)]
[mlir][sparse] implement lowering rules for sparse_tensor.pack operation

Reviewed By: aartbik

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

17 months ago[Clang][SemaCXX][Coroutines] Fix misleading diagnostics with -Wunsequenced
Bruno Cardoso Lopes [Thu, 19 Jan 2023 03:17:15 +0000 (00:17 -0300)]
[Clang][SemaCXX][Coroutines] Fix misleading diagnostics with -Wunsequenced

D115187 exposed CoroutineSuspendExpr's operand, which makes some nodes to show
up twice during the traversal, confusing the check for unsequenced operations.
Skip the operand since it's already handled as part of the common expression
and get rid of the misleading warnings.

https://github.com/llvm/llvm-project/issues/56768

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

17 months ago[MachineOutliner][AArch64] NFC: Split MBBs into "outlinable ranges"
Jessica Paquette [Wed, 16 Feb 2022 20:50:31 +0000 (12:50 -0800)]
[MachineOutliner][AArch64] NFC: Split MBBs into "outlinable ranges"

Recommit with bug fixes + added testcases to the outliner. Also adds some
debug output.

We found a case in the Swift benchmarks where the MachineOutliner introduces
about a 20% compile time overhead in comparison to building without the
MachineOutliner.

The origin of this slowdown is that the benchmark has long blocks which incur
lots of LRU checks for lots of candidates.

Imagine a case like this:

```
bb:
  i1
  i2
  i3
  ...
  i123456
```

Now imagine that all of the outlining candidates appear early in the block, and
that something like, say, NZCV is defined at the end of the block.

The outliner has to check liveness for certain registers across all candidates,
because outlining from areas where those registers are used is unsafe at call
boundaries.

This is fairly wasteful because in the previously-described case, the outlining
candidates will never appear in an area where those registers are live.

To avoid this, precalculate areas where we will consider outlining from.
Anything outside of these areas is mapped to illegal and not included in the
outlining search space. This allows us to reduce the size of the outliner's
suffix tree as well, giving us a potential memory win.

By precalculating areas, we can also optimize other checks too, like whether
or not LR is live across an outlining candidate.

Doing all of this is about a 16% compile time improvement on the case.

This is likely useful for other targets (e.g. ARM + RISCV) as well, but for now,
this only implements the AArch64 path. The original "is the MBB safe" method
still works as before.

17 months ago[LLVM Utils] Update GitPython for CVE-2022-24439
John Demme [Fri, 3 Feb 2023 23:25:59 +0000 (23:25 +0000)]
[LLVM Utils] Update GitPython for CVE-2022-24439

GitPython 3.1.28 has a security vulnerability which was fixed in 3.1.30:
https://nvd.nist.gov/vuln/detail/CVE-2022-24439

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

17 months ago[libc] add printf auto float conversion
Michael Jones [Mon, 23 Jan 2023 23:11:22 +0000 (15:11 -0800)]
[libc] add printf auto float conversion

This patch adds the final conversion to printf, %g. This is a floating
point conversion that selects automatically between the %e and %f
formats based on the precision requested and resulting exponent.
Additionally it trims trailing zeroes. With this done all that's left
for finishing printf is adding long double support to the decimal float
conversions.

Reviewed By: sivachandra

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

17 months ago[clang][deps] Fix module context hash for constant strings
Ben Langmuir [Wed, 1 Feb 2023 01:56:48 +0000 (17:56 -0800)]
[clang][deps] Fix module context hash for constant strings

We were not hashing constant strings in the command-line, only ones that
required allocations. This was causing us to get the same hash across
different flag options.

rdar://101053855

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

17 months ago[Tooling/Inclusion] qualifed_name() => qualifiedName(), NFC
Haojian Wu [Fri, 3 Feb 2023 22:57:30 +0000 (23:57 +0100)]
[Tooling/Inclusion] qualifed_name() => qualifiedName(), NFC

17 months agoFix tsan problem where the per-thread shared_ptr() can be locked right before the...
Parker Schuh [Fri, 3 Feb 2023 22:53:00 +0000 (23:53 +0100)]
Fix tsan problem where the per-thread shared_ptr() can be locked right before the cache is destroyed causing a race where it tries to remove an entry from a destroyed cache.

This is a rollforward with fixes of https://reviews.llvm.org/rGbcc10817d5569172ee065015747e226280e9b698 (originally https://reviews.llvm.org/D142394). The original patch exposed an asan problem on aarch64, which is fixed by simply calling the context destructors properly.

Reviewed By: rriddle

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

17 months ago[libc++] Remove leftover LIBCXX_ENABLE_CLANG_TIDY in run-buildbot
Louis Dionne [Fri, 3 Feb 2023 22:34:55 +0000 (17:34 -0500)]
[libc++] Remove leftover LIBCXX_ENABLE_CLANG_TIDY in run-buildbot

17 months ago[mlir][sparse] introduce sparse_tensor.pack operation
Peiming Liu [Thu, 2 Feb 2023 23:34:28 +0000 (23:34 +0000)]
[mlir][sparse] introduce sparse_tensor.pack operation

Reviewed By: aartbik

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

17 months ago[libc][NFC] Print the GPU architectures to build and fix the CMake list
Joseph Huber [Fri, 3 Feb 2023 22:20:57 +0000 (16:20 -0600)]
[libc][NFC] Print the GPU architectures to build and fix the CMake list

Summary:
This list previously had empty members. Fix it and print out which
architectures we're building for as a status message.

17 months ago[libc++] Add a CI configuration to test Modules with LSV enabled
Louis Dionne [Thu, 2 Feb 2023 23:50:10 +0000 (18:50 -0500)]
[libc++] Add a CI configuration to test Modules with LSV enabled

Some clients use libc++ with modules and LSV (Local Submodule Visibility)
enabled, and we see frequent downstream breakage caused by that. Until
modules use LSV by default (which is apparently a desire), add a CI job
that tests this sub-configuration to avoid high cost downstream breakage.

For more information about LSV, see https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150504/128395.html.

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

17 months ago[mlir][sparse] start using size_hint provided in allocation op
Aart Bik [Fri, 3 Feb 2023 21:08:46 +0000 (13:08 -0800)]
[mlir][sparse] start using size_hint provided in allocation op

Even though we introduced the size_hint, we never used it.
This is a very first step, using the hint during the codegen path.
Note that we can refine the heuristics. Also, we need to start
adding the hint on all allocation generated for reading tensors,
converting tensors, etc.

Reviewed By: Peiming, bixia

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

17 months ago[mlir] Canonicalize dynamic tensor.pad ops with constant inputs
George Petterson [Fri, 3 Feb 2023 21:43:45 +0000 (16:43 -0500)]
[mlir] Canonicalize dynamic tensor.pad ops with constant inputs

This commit adds a canonicalization pattern for tensor.pad which changes the output type to static at each dimension where the input shape is static and the high and low operands are constants. This corrects an issue arising in Torch-MLIR where pad ops would sometimes introduce dynamic shapes unnecessarily.

Reviewed By: raikonenfnu

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

17 months ago[RISCV] Remove side effects from vsetvli intrinsics.
Craig Topper [Fri, 3 Feb 2023 21:03:56 +0000 (13:03 -0800)]
[RISCV] Remove side effects from vsetvli intrinsics.

Delete the opt intrinsics since they are now identical.

I left the side effects due to user expectations about how these
interact with things like inline assembly or function calls. Or
that they wouldn't be hoisted. I think we should look at other
ways to address thoughs.

If I could, I'd rename them these somehow to distance them from
the vsetvli instruction. In some sense they only query the VL for
a particular SEW and LMUL. They don't guarantee a vsetvli
instruction will be emitted.

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

Reviewed By: rogfer01, kito-cheng

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

17 months agoUpdate llgdb to use python3.
Adrian Prantl [Fri, 3 Feb 2023 20:54:10 +0000 (12:54 -0800)]
Update llgdb to use python3.