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

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

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

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

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

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

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

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

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

18 months agoAdd a GDB/LLDB interface for interactive debugging of MLIR Actions
Mehdi Amini [Wed, 15 Feb 2023 23:56:08 +0000 (15:56 -0800)]
Add a GDB/LLDB interface for interactive debugging of MLIR Actions

This includes a small runtime acting as callback for the ExecutionEngine
and a C API that makes it possible to control from the debugger.

A python script for LLDB is included that hook a new `mlir` subcommand
and allows to set breakpoints and inspect the current action, the context
and the stack.

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

18 months ago[LV] Use the known trip count when costing non-tail folded VFs
David Green [Mon, 24 Apr 2023 21:02:30 +0000 (22:02 +0100)]
[LV] Use the known trip count when costing non-tail folded VFs

Now that we store the ScalarCost in the VectorizationFactor it is possible to
use it to get a slightly more accurate cost in isMoreProfitable between two
vector factors. This extends the logic added in D101726 to non-tail-folded
cases, using the costs of `VecCost * (TripCount / VF) + ScalarCost * (TripCount % VF)`
to compare VFs where the TripCount is known and we are not folding the tail.

This shouldn't alter very much as small trip counts are usually not vectorized,
but does seem to help in the testcase where 4 * VF4 is chosen as profitable
compared to 2 * VF8 + 4 * scalar.

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

18 months agoRevert "[OpenMP] Fix GCC build issues and restore "Additional APIs used by the"
Joseph Huber [Mon, 24 Apr 2023 20:49:16 +0000 (15:49 -0500)]
Revert "[OpenMP] Fix GCC build issues and restore "Additional APIs used by the"

This patch caused failures on the OpenMP buildbots as discussed in
https://reviews.llvm.org/D149010. We will need to investigate why we are
seeing unresolved references to the standard C++ library.

This reverts commit 5a15ca7f10bcba55a2f51281b1562cf5095ae015.

18 months ago[X86 isel] Fix permute mask calculation in lowerShuffleAsUNPCKAndPermute
Han Zhu [Thu, 20 Apr 2023 20:41:46 +0000 (13:41 -0700)]
[X86 isel] Fix permute mask calculation in lowerShuffleAsUNPCKAndPermute

This fixes [issue 62242](https://github.com/llvm/llvm-project/issues/62242)

This code block can potentially swap the order of V1 and V2 in Ops and therefore
also in the unpck instruction generated.
```
SDValue &Op = Ops[Elt & 1];
if (M < NumElts && (Op.isUndef() || Op == V1))
  Op = V1;
else if (NumElts <= M && (Op.isUndef() || Op == V2)) {
  Op = V2;
  NormM -= NumElts;
} else
  return SDValue();
```
But the permute mask is calculated assuming the first operand being V1 and
second V2, therefore causing a mis-compile.

First check if the input operands are swapped, and then calculate the permute
mask based on that.

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

18 months ago[libc] Adjust the `cpp:function` type to support lambdas
Joseph Huber [Fri, 21 Apr 2023 22:59:00 +0000 (17:59 -0500)]
[libc] Adjust the `cpp:function` type to support lambdas

The current function type does not support generic lambdas because it
relies on the lambda being implicitly convertible to a function pointer.
This patch adds support for this by copying the existing lightweight
`function_ref` type.

Reviewed By: sivachandra

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

18 months ago[libc] Add more utility functions for the GPU
Joseph Huber [Thu, 20 Apr 2023 16:16:01 +0000 (11:16 -0500)]
[libc] Add more utility functions for the GPU

This patch adds extra intrinsics for the GPU. Some of these are unused
for now but will be used later. We use these currently to update the
`RPC` handling. Currently, every thread can update the RPC client, which
isn't correct. This patch adds code neccesary to allow a single thread
to perfrom the write while the others wait.

Feedback is welcome for the naming of these functions. I'm copying the
OpenMP nomenclature where we call an AMD `wavefront` or NVIDIA `warp` a
`lane`.

Reviewed By: tra

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

18 months ago[clang] Remove workaround for old LLVM_ENABLE_PROJECTS=libcxx build
Louis Dionne [Fri, 21 Apr 2023 17:47:18 +0000 (13:47 -0400)]
[clang] Remove workaround for old LLVM_ENABLE_PROJECTS=libcxx build

We don't support the LLVM_ENABLE_PROJECTS=libcxx build anymore (and have
not for over a year), so it should be fine to remove this workaround now.

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

18 months ago[NFC][flang] Fixed typo in AVOID_NATIVE_UINT128_T macro.
Slava Zakharin [Mon, 24 Apr 2023 20:16:55 +0000 (13:16 -0700)]
[NFC][flang] Fixed typo in AVOID_NATIVE_UINT128_T macro.
Differential Revision: https://reviews.llvm.org/D149097

18 months ago[DFSAN] Add support for strsep.
Tomasz Kuchta [Mon, 24 Apr 2023 19:02:52 +0000 (19:02 +0000)]
[DFSAN] Add support for strsep.

Reviewed-by: browneee
Differential Revision: https://reviews.llvm.org/D141389

18 months ago[Docs] Fix minor issues in AdvancedBuilds documentation
Aiden Grossman [Mon, 24 Apr 2023 19:40:21 +0000 (19:40 +0000)]
[Docs] Fix minor issues in AdvancedBuilds documentation

This patch modifies the commands under the Bootstrap builds section so
that they include the -DLLVM_ENABLE_PROJECTS flag with the value "clang"
so that the Clang build will actually get picked up. Without this patch
they error out as the CLANG_BOOTSTRAP_PASSTHROUGH variable is processed
in /clang/CMakeLists.txt which isn't picked up without the
LLVM_ENABLE_PROJECTS variable being set appropriately.

This patch also changes any remaining dangling <path to source>
references to <path to source>/llvm to better match the rest of the
file.

Reviewed By: thieta

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

18 months ago[llvm-exegesis] Fix ifdefs in X86/Target.cpp
Pavel Kosov [Mon, 24 Apr 2023 19:31:40 +0000 (22:31 +0300)]
[llvm-exegesis] Fix ifdefs in X86/Target.cpp

As discussed in https://reviews.llvm.org/D96498, the correct macro
to check together with _MSC_VER is _M_X64. Testing for _MSC_VER with
__x86_64__ made tests fail on Windows in https://reviews.llvm.org/D146301.

Additionally, this commit replaces a few calls to llvm_unreachable() with
report_fatal_error() because it is actually reached even on Linux/i686,
causing obscure segfaults when expanded to __builtin_unreachable().

~~

Huawei RRI, OS Lab

Reviewed By: courbet

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

18 months agoDisable compiler launcher on external projects and multi stage clang
Haowei Wu [Thu, 23 Feb 2023 00:50:30 +0000 (16:50 -0800)]
Disable compiler launcher on external projects and multi stage clang

When using compiler caching program like ccache, there is no point to
use them on external projects or multi-stage clang builds. As these
builds uses fresh from source code toolchain and will pollute the build
cache. If a compiler launcher is still required, a user can explicity
define `CMAKE_C_COMPILER_LAUNCHER` and `CMAKE_CXX_COMPILER_LAUNCHER` in
`CLANG_BOOTSTRAP_PASSTHROUGH` and `LLVM_EXTERNAL_PROJECT_PASSTHROUGH`
flags to enable compiler launcher in these builds.

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

18 months ago[clang][tests] Fix Flang driver tests for Windows
Ádám Kallai [Thu, 13 Apr 2023 11:26:00 +0000 (06:26 -0500)]
[clang][tests] Fix Flang driver tests for Windows

Updated the regular expression in order to match '.exe' suffix,
if these Flang tests are running on Windows.

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

18 months ago[RISCV] Rename WriteFCvtF32ToF32 sched class to WriteFRoundF32.
Craig Topper [Mon, 24 Apr 2023 19:02:04 +0000 (12:02 -0700)]
[RISCV] Rename WriteFCvtF32ToF32 sched class to WriteFRoundF32.

Round better matches the instructions this is used for.

Do the same for F16 and F64 as well as the Read classes.

18 months ago[OpenMP] Fix GCC build issues and restore "Additional APIs used by the
Natalia Glagoleva [Mon, 24 Apr 2023 17:49:25 +0000 (10:49 -0700)]
[OpenMP] Fix GCC build issues and restore "Additional APIs used by the
MSVC compiler for loop collapse (rectangular and non-rectangular loops)"

Fixes a GCC build issue (unallowed typename keyword use) in and restores
https://reviews.llvm.org/D148393

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

18 months ago[BOLT][Wrapper] Fix off-by-one when parsing 'cmp' output
Job Noorman [Mon, 24 Apr 2023 18:54:23 +0000 (20:54 +0200)]
[BOLT][Wrapper] Fix off-by-one when parsing 'cmp' output

The byte offsets in the output of 'cmp' start from 1, not from 0 as the
current parser assumes. This caused mismatched bytes to sometimes be
attributed to the wrong section.

Reviewed By: rafauler

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

18 months ago[mlir] Dialect type/attr bytecode read/write generator.
Jacques Pienaar [Mon, 24 Apr 2023 18:53:58 +0000 (11:53 -0700)]
[mlir] Dialect type/attr bytecode read/write generator.

Tool to help generate dialect bytecode Attribute & Type reader/writing.
Show usage by flipping builtin dialect.

It helps reduce boilerplate when writing dialect bytecode attribute and
type readers/writers. It is not an attempt at a generic spec mechanism
but rather practically focussing on boilerplate reduction while also
considering that it need not be the only in memory format and make it
relatively easy to change.

There should be some cleanup in follow up as we expand to more dialects.

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

18 months ago[RISCV] Prefer vmsle.vi vX, vY, -1 over vslt.vx vX, vY, x0.
Craig Topper [Mon, 24 Apr 2023 18:45:27 +0000 (11:45 -0700)]
[RISCV] Prefer vmsle.vi vX, vY, -1 over vslt.vx vX, vY, x0.

If a target hasn't optimized scalar to vector transfers for x0,
using an immediate may be more efficient.

18 months ago[BOLT] Fix many tests detected as unsupported
Job Noorman [Mon, 24 Apr 2023 18:38:42 +0000 (11:38 -0700)]
[BOLT] Fix many tests detected as unsupported

Since D148847, many tests are detected as being unsupported. This is
caused by BOLT_TARGETS_TO_BUILD being ;-separated whereas the previously
used TARGETS_TO_BUILD is space-separated.

This patch fixes this by creating config.targets lit.cfg.py by splitting
on ';'.

Reviewed By: rafauler

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

18 months agoValueTracking: Implement computeKnownFPClass for fma/fmuladd
Matt Arsenault [Sun, 9 Apr 2023 11:16:34 +0000 (07:16 -0400)]
ValueTracking: Implement computeKnownFPClass for fma/fmuladd

Copy handling from CannotBeOrderedLessThanZero

18 months agoInstCombine: Add some baseline is.fpclass combine tests
Matt Arsenault [Mon, 24 Apr 2023 13:02:34 +0000 (09:02 -0400)]
InstCombine: Add some baseline is.fpclass combine tests

Add tests for converting is.fpclass > or < 0 to fcmp with 0.

18 months agoValueTracking: Handle exp/exp2 in computeKnownFPClass
Matt Arsenault [Sun, 9 Apr 2023 11:15:45 +0000 (07:15 -0400)]
ValueTracking: Handle exp/exp2 in computeKnownFPClass

18 months agoValueTracking: Fix computeKnownFPClass for fabs
Matt Arsenault [Wed, 19 Apr 2023 02:49:37 +0000 (22:49 -0400)]
ValueTracking: Fix computeKnownFPClass for fabs

The fabs utility functions have the opposite purpose and
probably should not be a general utility.

18 months agoValueTracking: Add computeKnownFPClass baseline tests for exp
Matt Arsenault [Mon, 10 Apr 2023 13:40:54 +0000 (09:40 -0400)]
ValueTracking: Add computeKnownFPClass baseline tests for exp

18 months ago[mlir][vector] Add unroll pattern for vector.gather
Quinn Dawkins [Wed, 5 Apr 2023 04:36:51 +0000 (00:36 -0400)]
[mlir][vector] Add unroll pattern for vector.gather

This pattern is useful for SPIR-V to unroll to a supported vector size
before later lowerings. The unrolling pattern is closer to an
elementwise op than the transfer ops because the index values from which
to extract elements are captured by the index vector and thus there is
no need to update the base offsets when unrolling gather.

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

18 months ago[mlir][spirv] Fix OOB error in TestModuleCombiner
Jakub Kuderski [Mon, 24 Apr 2023 17:56:21 +0000 (13:56 -0400)]
[mlir][spirv] Fix OOB error in TestModuleCombiner

Also fix a typo in the surrounding code.

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

Reviewed By: qedawkins

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

18 months ago[mlir][linalg] Add support for lowering pack with outer_dims_perm.
Hanhan Wang [Fri, 21 Apr 2023 20:32:54 +0000 (13:32 -0700)]
[mlir][linalg] Add support for lowering pack with outer_dims_perm.

Reviewed By: chelini, qcolombet

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

18 months ago[flang][openacc] Support array section with non constant bounds
Valentin Clement [Mon, 24 Apr 2023 17:12:07 +0000 (10:12 -0700)]
[flang][openacc] Support array section with non constant bounds

Add lowering for non constant lower and upper bounds
in array section.

Reviewed By: jeanPerier

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

18 months ago[PPCMIPeephole] Fix incorrect compare elimination
Fangrui Song [Mon, 24 Apr 2023 17:02:06 +0000 (10:02 -0700)]
[PPCMIPeephole] Fix incorrect compare elimination

D38236 moves a redundant compare instruction from the loop body to the
preheader.

It has a bug: when `MBB1 == &MBB2`, there may be only one compare instruction in the
loop. The code will lift the compare instruction to the preheader, failing to
account for the change of the compare result in a tail call, leading to a miscompile.

Suppress the compare elimination to fix https://github.com/llvm/llvm-project/issues/62294

Reviewed By: #powerpc, nemanjai

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

18 months ago[VPlan] Add VPValue::isLiveIn() (NFC).
Florian Hahn [Mon, 24 Apr 2023 16:51:11 +0000 (17:51 +0100)]
[VPlan] Add VPValue::isLiveIn() (NFC).

This helps to clarify checks in multiple places.

Suggested as cleanup in D147892.

18 months ago[M68k] Add basic Clang support for M68881/2
Min-Yih Hsu [Mon, 24 Apr 2023 16:32:49 +0000 (09:32 -0700)]
[M68k] Add basic Clang support for M68881/2

  - Add the `-m68881` flag
  - Add floating point feature detection
  - Macro definitions

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

18 months ago[gn build] Port afa13ba18d9e
LLVM GN Syncbot [Mon, 24 Apr 2023 16:19:57 +0000 (16:19 +0000)]
[gn build] Port afa13ba18d9e

18 months ago[MLIR][python bindings][fix] implement `replace_all_uses_with` on `PyValue`
max [Mon, 24 Apr 2023 16:17:08 +0000 (11:17 -0500)]
[MLIR][python bindings][fix] implement `replace_all_uses_with` on `PyValue`

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

18 months agoReapply Move "auto-init" instructions to the dominator of their users
serge-sans-paille [Mon, 17 Apr 2023 08:13:31 +0000 (10:13 +0200)]
Reapply Move "auto-init" instructions to the dominator of their users

Original patch (50b2a113db197a97f60ad2aace8b7382dc9b8c31) ignored the
fact that -ftrivial-auto-var-init could affect function parameters with
the sret attribute.
Just do not move instruction that don't affect alloca.
Also add missing test case for volatile instruction.

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

18 months ago[lldb][test] TestCPP20Standard.py: skip on older compilers
Michael Buch [Mon, 24 Apr 2023 16:04:18 +0000 (12:04 -0400)]
[lldb][test] TestCPP20Standard.py: skip on older compilers

Requires C++20 support (at least for the spaceship operator).
Seems to work back to Clang-11

18 months agoAdd missing HTML closing tag
Aaron Ballman [Mon, 24 Apr 2023 15:58:07 +0000 (11:58 -0400)]
Add missing HTML closing tag

The </li> tag was missing for this entry.

18 months ago[clang][Interp][NFC] Take a QualType in visitZeroInitializer()
Timm Bäder [Sat, 1 Apr 2023 06:41:20 +0000 (08:41 +0200)]
[clang][Interp][NFC] Take a QualType in visitZeroInitializer()

The given expression is not necessarily usable to obtain a type for,
so we can't use it to get the floating point semantics. Pass a QualType
instead, which we can use--and classify() that here.

18 months agoRemove the "implement better version of existing tools" open project
Aaron Ballman [Mon, 24 Apr 2023 15:56:25 +0000 (11:56 -0400)]
Remove the "implement better version of existing tools" open project

This project doesn't really relate to improving Clang itself and it
contained stale suggestions like working on code modification
functionality in clang-format.

18 months agoReword the open project for generating documentation
Aaron Ballman [Mon, 24 Apr 2023 15:55:11 +0000 (11:55 -0400)]
Reword the open project for generating documentation

Work already began on this project, so this updates the wording to
discuss clang-doc specifically.

18 months agoAdd some more open project for Clang
Aaron Ballman [Mon, 24 Apr 2023 15:43:25 +0000 (11:43 -0400)]
Add some more open project for Clang

This adds open projects for updating the status of our C conformance,
DR conformance for both C and C++, and improving build times.

18 months ago[PowerPC] Add a new test for vperm with a swapped vector operand and a constant pool
Maryam Moghadas [Fri, 21 Apr 2023 16:59:58 +0000 (16:59 +0000)]
[PowerPC] Add a new test for vperm with a swapped vector operand and a constant pool

This patch adds a new test that includes a vperm instruction with xxswapd as its
vector operand on little-endian Power8. The test demonstrates the constant pool
for the mask operand, which is intended to indicate the optimization of vperm
and the modification of the constant pool in subsequent patches.

Reviewed By: amyk

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

18 months ago[clang] remove dereferencing of invalid pointer
Ashay Rane [Mon, 24 Apr 2023 13:01:33 +0000 (08:01 -0500)]
[clang] remove dereferencing of invalid pointer

A line in the demangling code for float literals dereferences the
`.end()` iterator, which causes the Windows debug build of llvm-cxxfilt
to crash.  The failure can be reproduced by passing the string
`_Z5dummyIXtl8wrapper1IdEtlNS1_Ut_Edi9RightNametlNS2_Ut_ELd405ec00000000000EEEEEEvv`
to `llvm-cxxfilt -n`.

This patch rewrites the code to use the `.size()` member of the
string_view type to avoid dereferencing past the buffer.

Reviewed By: DavidSpickett

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

18 months ago[VP] Add IR expansion for fneg
Simon Pilgrim [Mon, 24 Apr 2023 14:57:01 +0000 (15:57 +0100)]
[VP] Add IR expansion for fneg

Followup to D149052, it wasn't worthwhile to add general support for unary opcodes

18 months ago[VPlan] Remove unnecessary includes from VPlan.h (NFC).
Florian Hahn [Mon, 24 Apr 2023 15:10:46 +0000 (16:10 +0100)]
[VPlan] Remove unnecessary includes from VPlan.h (NFC).

Clean up some unnecessary includes from VPlan.h, which is imported in
multiple files.

18 months ago[MLIR][python bindings] implement `replace_all_uses_with` on `PyValue`
max [Mon, 24 Apr 2023 15:08:11 +0000 (10:08 -0500)]
[MLIR][python bindings] implement `replace_all_uses_with` on `PyValue`

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

18 months ago[Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module...
Andrew Gozillon [Mon, 24 Apr 2023 14:46:03 +0000 (09:46 -0500)]
[Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering

This patch ports the fopenmp-host-ir-file-path flag from Clang to Flang-new, this flag
is added by the driver to the device pass when doing two phase compilation (device + host).

This flag is then applied to the module when compiling during the OpenMP device phase.
This file can then be utilised during lowering of the OpenMP dialect to LLVM-IR, which
allows the device and host to maintain 1:1 mapping of OpenMP metadata for variables
during lowering via the OpenMPIRBuilders loadOffloadInfoMetadata facilities
(which is used for declare target and I believe target regions as well).

Reviewer: awarzynski

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

18 months ago[LICM] Minor optimization (NFC)
Nikita Popov [Mon, 24 Apr 2023 15:05:06 +0000 (17:05 +0200)]
[LICM] Minor optimization (NFC)

Simplify the match in hoistMinMax and only fetch the preheader
once.

18 months agoAdd some open projects for people to consider
Aaron Ballman [Mon, 24 Apr 2023 14:53:17 +0000 (10:53 -0400)]
Add some open projects for people to consider

These projects are ones that are already known within the community as
areas we would like to see improvements on.

18 months agoRevert "[InstSimplify] Support all instructions in simplifyWithOpReplaced()"
Nikita Popov [Mon, 24 Apr 2023 14:38:48 +0000 (16:38 +0200)]
Revert "[InstSimplify] Support all instructions in simplifyWithOpReplaced()"

This reverts commit 3e3e41b263f4aa76a5a36f02727827bebccdbf07.

This appears to cause a stage2 miscompile of llvm-profgen.

18 months ago[libc] Suppress error message from the arch tools if they fail
Joseph Huber [Mon, 24 Apr 2023 14:44:54 +0000 (09:44 -0500)]
[libc] Suppress error message from the arch tools if they fail

Summary:
These tools are used to query amdgpu-arch and nvptx-arch. We shouldn't
print their errors to the console if they do fail.

18 months ago[SLP]Fix PR58616: assert for gep nodes with different basic blocks.
Alexey Bataev [Mon, 24 Apr 2023 13:46:34 +0000 (06:46 -0700)]
[SLP]Fix PR58616: assert for gep nodes with different basic blocks.

Need to relax the assertion check in the FindFirstInst lambda for GEP
nodes with non-GEP instruction to avoid compiler crash.

18 months ago[CMake] Sort deps and reformat
NAKAMURA Takumi [Mon, 24 Apr 2023 13:54:40 +0000 (22:54 +0900)]
[CMake] Sort deps and reformat

18 months ago[Serialization] Correctly handle special files when deserializing
John Brawn [Mon, 24 Apr 2023 14:35:37 +0000 (15:35 +0100)]
[Serialization] Correctly handle special files when deserializing

This was supposed to be part of my previous commit, but I accidentally
pushed an old version of the patch.

18 months ago[clang][dataflow] Use existing accessors to check for copy and move assignment ops.
Martin Braenne [Mon, 24 Apr 2023 13:11:02 +0000 (13:11 +0000)]
[clang][dataflow] Use existing accessors to check for copy and move assignment ops.

Reviewed By: gribozavr2

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

18 months ago[VP] IR expansion for fabs/fsqrt/fma/fmadd
Simon Pilgrim [Mon, 24 Apr 2023 14:14:06 +0000 (15:14 +0100)]
[VP] IR expansion for fabs/fsqrt/fma/fmadd

Add basic handling for VP ops that can expand to FP intrinsics

Fixes #60464

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

18 months ago[Clang] Accept and forward `-fconvergent-functions` in the driver
Joseph Huber [Mon, 24 Apr 2023 14:10:31 +0000 (09:10 -0500)]
[Clang] Accept and forward `-fconvergent-functions` in the driver

Currently the `-fconvergent-functions` option is primarily used by GPU
toolchains to enforce convergent operations in line with the semantics.
This option previously was only supported via `-Xclang` and would show
up as unused if passed to the driver. This patch allows the driver to
forward it. This is mostly useful for users wishing to target GPU
toolchains directly via `--target=` without an offloading runtime.

Reviewed By: JonChesterfield, MaskRay

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

18 months ago[LLD][COFF] Add /inferasanlibs to lld-link as ignored flag
Alvin Wong [Sun, 23 Apr 2023 15:58:24 +0000 (23:58 +0800)]
[LLD][COFF] Add /inferasanlibs to lld-link as ignored flag

MSVC link.exe added this flag and MS STL started using this flag in
.drectve [1] when compiling with Clang with asan enabled, as reported
on https://github.com/llvm/llvm-project/issues/56300. This causes issues
with lld-link because it rejects any unknown flags in .drective sections.

As dc07867dc9991c982bd3441da19d6fcc16ea54d6 noted that, when using Clang
as the driver it explicitly passes the proper asan libraries. Therefore
it should be acceptable to ignore this flag in lld-link to at least
unbreak building with clang-cl and linking with lld-link.

[1]: https://github.com/microsoft/STL/blob/faaf094ee16bcbfb2c8d612fdb9334bcdef2fd0a/stl/inc/__msvc_sanitizer_annotate_container.hpp#L35

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

18 months ago[LLD][COFF] Print object file name for unsupported directives
Alvin Wong [Sun, 23 Apr 2023 15:52:55 +0000 (23:52 +0800)]
[LLD][COFF] Print object file name for unsupported directives

This is a small QoL improvement suggested by FrancescElies in
https://github.com/llvm/llvm-project/issues/56300#issuecomment-1172104966.

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

18 months ago[dataflow] HTMLLogger: fix off-by-one in the BB listing
Sam McCall [Fri, 21 Apr 2023 19:22:35 +0000 (21:22 +0200)]
[dataflow] HTMLLogger: fix off-by-one in the BB listing

The indexes of analysis state within a BB element is a bit odd:
  BB.0 is the initial state
  BB.1 is the state after the first element
etc

This means we have N+1 states and we need N+1 elements in the BB list.
We add a dummy element at the beginning rather than the end, because we want
selecting a CFG element to show the state *afterwards*.
For example, if we click on an expr, we want to be able to see its value model!

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

18 months ago[NFC][PowerPC] Added a test case to show extra clear instructions.
Stefan Pintilie [Fri, 21 Apr 2023 20:12:07 +0000 (16:12 -0400)]
[NFC][PowerPC] Added a test case to show extra clear instructions.

Added a number of functions that have a clear instruction that is not
actually required. This test is added first and then a patch will be
added later in order to remove the unnecessary instructions.

18 months ago[DAG] Add ISD::isExtVecInRegOpcode helper.
Simon Pilgrim [Mon, 24 Apr 2023 13:47:05 +0000 (14:47 +0100)]
[DAG] Add ISD::isExtVecInRegOpcode helper.

Match ISD::ANY_EXTEND_VECTOR_INREG\ZERO_EXTEND_VECTOR_INREG\SIGN_EXTEND_VECTOR_INREG opcodes

18 months ago[X86] Support EVT types in supportedVectorShift* helpers. NFCI.
Simon Pilgrim [Mon, 24 Apr 2023 13:15:14 +0000 (14:15 +0100)]
[X86] Support EVT types in supportedVectorShift* helpers. NFCI.

Move the isSimple() check inside the helpers to avoid a lot of extra checking in a future patch.

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

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

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

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

18 months ago[InstSimplify] Add additional test for select icmp of umin (NFC)
Nikita Popov [Mon, 24 Apr 2023 13:08:41 +0000 (15:08 +0200)]
[InstSimplify] Add additional test for select icmp of umin (NFC)

This is a representative test for the simplifyWithOpReplaced()
fold on intrinsics.

18 months ago[Serialization] Place command line defines in the correct file
John Brawn [Mon, 24 Apr 2023 13:07:41 +0000 (14:07 +0100)]
[Serialization] Place command line defines in the correct file

Fix several problems related to serialization causing command line
defines to be reported as being built-in defines:
 * When serializing the <built-in> and <command line> files don't
   convert them into absolute paths.
 * When deserializing SM_SLOC_BUFFER_ENTRY we need to call
   setHasLineDirectives in the same way as we do for
   SM_SLOC_FILE_ENTRY.
 * When created suggested predefines based on the current command line
   options we need to add line markers in the same way that
   InitializePreprocessor does.
 * Adjust a place in clangd where it was implicitly relying on command
   line defines being treated as builtin.

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

18 months agoRemove known-stale projects from the open projects page
Aaron Ballman [Mon, 24 Apr 2023 12:49:48 +0000 (08:49 -0400)]
Remove known-stale projects from the open projects page

This removes or modifies:

Undefined behavior checking -- we've got UBSan and it's well-known
enough that we don't need to call it out specifically as a need.

Improve target support -- this is largely already complete.

Use clang libraries to extend Ragel with a JIT -- this wasn't really
related to improving Clang.

C++1y feature work -- now talks about C++20, C++2b, and C2x instead.

Universal driver -- the bug report linked to by the UniversalDriver
web page has been closed since 2017.

XML representation of the AST -- we removed this functionality in 2013
and replaced it with a JSON representation a few years later. That is a
best-effort project.

18 months ago[LLD][ELF][AArch64] Add AArch64 short range thunk support
Peter Smith [Mon, 17 Apr 2023 17:37:05 +0000 (18:37 +0100)]
[LLD][ELF][AArch64] Add AArch64 short range thunk support

The AArch64 branch immediate instruction has a 128MiB range. This
makes it suitable for use a short range thunk in the same way as
short thunks are implemented in Arm and PPC. This patch adds
support for short range thunks to AArch64.

Adding short range thunk support should mean that OutputSections
can grow to nearly 256 MiB in size without needing long-range
indirect branches.

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

18 months ago[Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarat...
Paul Walker [Thu, 20 Apr 2023 16:45:56 +0000 (16:45 +0000)]
[Clang][Sema] Fix invalid cast when validating SVE types within CheckVariableDeclarationType.

Fixes #62087

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

18 months ago[Vectorize] Fix vectorization, scalarization and folding of llvm.is.fpclass
Jay Foad [Fri, 21 Apr 2023 13:11:31 +0000 (14:11 +0100)]
[Vectorize] Fix vectorization, scalarization and folding of llvm.is.fpclass

llvm.is.fpclass is different from other vectorizable intrinsics in that
it is overloaded on an argument type, not on the return type.

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

18 months ago[Vectorize] Pre-commit tests for D148905
Jay Foad [Fri, 21 Apr 2023 14:43:02 +0000 (15:43 +0100)]
[Vectorize] Pre-commit tests for D148905

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

18 months ago[lldb][tests] TestPreferredName.py: add missing import
Michael Buch [Mon, 24 Apr 2023 12:40:23 +0000 (08:40 -0400)]
[lldb][tests] TestPreferredName.py: add missing import

18 months ago[InstSimplify] sdiv a (1 srem b) --> a
Siyuan Zhu [Mon, 24 Apr 2023 12:29:37 +0000 (14:29 +0200)]
[InstSimplify] sdiv a (1 srem b) --> a

Extend the existing fold for division by zero or one to use known
bits, so it catches additional patterns like division by
(1 srem b).

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

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

18 months agoFix file info comment; NFC
Aaron Ballman [Mon, 24 Apr 2023 12:35:43 +0000 (08:35 -0400)]
Fix file info comment; NFC

There is no TargetInfoImpl class any longer.

18 months ago[lldb][tests] TestPreferredName.py: Fix for older compilers
Michael Buch [Mon, 24 Apr 2023 12:29:48 +0000 (08:29 -0400)]
[lldb][tests] TestPreferredName.py: Fix for older compilers

This only works as of D145803, where we re-point the
`DW_AT_type` based on existence of `[[clang::preferred_name]]`

18 months ago[InstSimplify] Test case for D149001 (NFC)
Siyuan Zhu [Mon, 24 Apr 2023 12:28:12 +0000 (14:28 +0200)]
[InstSimplify] Test case for D149001 (NFC)

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

18 months agoMinor cleanup of the Open Projects page
Aaron Ballman [Mon, 24 Apr 2023 12:25:28 +0000 (08:25 -0400)]
Minor cleanup of the Open Projects page

Sets the charset to UTF-8, fixes the page title, replaces mention of
cfe-dev with Discourse, points out Discord and IRC.

18 months ago[InstSimplify] Move more folds into simplifyDivRem() (NFCI)
Nikita Popov [Mon, 24 Apr 2023 12:25:45 +0000 (14:25 +0200)]
[InstSimplify] Move more folds into simplifyDivRem() (NFCI)

The threading folds are the same for div/rem and the isDivZero()
fold only differes in the return value.

This should be NFC, but as this slightly shuffles around the
order of the folds it might not be exactly the same.

18 months ago[AArch64] Precommit test
Jingu Kang [Mon, 24 Apr 2023 12:23:57 +0000 (13:23 +0100)]
[AArch64] Precommit test

This patch precommits tests for:

https://reviews.llvm.org/D148347

18 months ago[FuncSpec] Track the return values of specializations.
Alexandros Lamprineas [Tue, 28 Mar 2023 17:16:19 +0000 (18:16 +0100)]
[FuncSpec] Track the return values of specializations.

To track the return values of specializations, we need to invalidate all
the lattice values across the use-def chain which originates from the
callsites, recompute and propagate.

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

18 months ago[InstSimplify] Drop redundant div fold (NFCI)
Nikita Popov [Mon, 24 Apr 2023 10:56:09 +0000 (12:56 +0200)]
[InstSimplify] Drop redundant div fold (NFCI)

This is nowadays handled generically via isDivZero() and icmp
simplification, specifically the computeConstantRange() based
logic.

18 months ago[bazel] test files for IRDL 8ac8c922fb3f15706f5cb1db2cc655d30b095766
Mikhail Goncharov [Mon, 24 Apr 2023 11:58:09 +0000 (13:58 +0200)]
[bazel] test files for IRDL 8ac8c922fb3f15706f5cb1db2cc655d30b095766

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

18 months ago[AArch64][DAGCombiner]: combine <2xi64> mul add/sub.
Hassnaa Hamdi [Thu, 20 Apr 2023 05:34:05 +0000 (05:34 +0000)]
[AArch64][DAGCombiner]: combine <2xi64> mul add/sub.

64-bit vector mul is not supported in NEON,
so we use the SVE's mul.
To improve the performance, we can go one step further,
and use SVE's add/sub, so that we can use SVE's mla/mls.
That works on these patterns:
add v1, (mul v2, v3)
sub v1, (mul v2, v3)

Reviewed By: david-arm, paulwalker-arm

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

18 months ago[InstSimplify] Move fold into isDivZero() (NFCI)
Nikita Popov [Mon, 24 Apr 2023 10:40:46 +0000 (12:40 +0200)]
[InstSimplify] Move fold into isDivZero() (NFCI)

This is a special case where we know the division result is zero.
For the unsigned case this is handled by generic icmp code, for
the signed case we do need to special case it.

18 months agoRevert "[Coverity] Fix explicit null dereferences"
Tom Weaver [Mon, 24 Apr 2023 10:14:10 +0000 (11:14 +0100)]
Revert "[Coverity] Fix explicit null dereferences"

This reverts commit 22b23a5213b57ce1834f5b50fbbf8a50297efc8a.

This commit caused the following two build bots to start failing:
https://lab.llvm.org/buildbot/#/builders/216/builds/20322
https://lab.llvm.org/buildbot/#/builders/123/builds/18511

18 months ago[RISCV] Add SiFive extension support
Kito Cheng [Fri, 17 Jun 2022 09:32:51 +0000 (17:32 +0800)]
[RISCV] Add SiFive extension support

Add SiFive extension support
Depends on D147934

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

18 months ago[RISCV] Support LLVM IR intrinsics for xsfvcp extension.
Nelson Chu [Wed, 18 May 2022 09:26:16 +0000 (02:26 -0700)]
[RISCV] Support LLVM IR intrinsics for xsfvcp extension.

The sf.vc.x and sf.vc.i intrinsics don't have any vector types in the output
and inputs, but the intrinsic spec said that we still need to add vetvli for
them. Therefore, we need to encode the VTYPE to these IR names.

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

18 months ago[llvm][docs] Update "Adding a Builder" docs
David Spickett [Fri, 21 Apr 2023 09:53:50 +0000 (10:53 +0100)]
[llvm][docs] Update "Adding a Builder" docs

* Move step 8 to later, after worker credentials have
  been added to the buildmaster.
* Added command for starting the worker, in addition
  to creating the worker. The latter only sets up the
  directories.
* Noted that in step 6, it is expected that you get a
  refused connection.
* Stated that the connection should be tried once,
  and the worker then stopped.

We could mention that repeated connections with invalid
credentials will result in an IP ban, but it's probably
detail people don't need here.

If it did happen, then you would not know until you tried
the later steps. At which point you are already in contact
with Galina, who is the person who would help you with that
issue in any case.

Reviewed By: gkistanova

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

18 months ago[CodeGenPrepare] Estimate liveness of loop invariants when checking for address foldi...
Momchil Velikov [Mon, 24 Apr 2023 08:50:28 +0000 (09:50 +0100)]
[CodeGenPrepare] Estimate liveness of loop invariants when checking for address folding profitability

When checking the profitability of folding an address computation
into a memory instruction, the compiler tries to determine the liveness
of the values, comprising the address, at the point of the memory instruction.
This patch improves on the live variable estimates by including
the loop invariants which are references in the loop body.

Reviewed By: dmgreen

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

18 months ago[clang] Return `std::string_view` from `TargetInfo::getClobbers()`
Stoorx [Fri, 21 Apr 2023 14:33:15 +0000 (17:33 +0300)]
[clang] Return `std::string_view` from `TargetInfo::getClobbers()`

Change the return type of `getClobbers` function from `const char*`
to `std::string_view`. Update the function usages in CodeGen module.

The reasoning of these changes is to remove unsafe `const char*`
strings and prevent unnecessary allocations for constructing the
`std::string` in usages of `getClobbers()` function.

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

18 months ago[clang] Remove unnecessary virtual inheritance in `TargetInfo`
Stoorx [Fri, 21 Apr 2023 21:06:58 +0000 (00:06 +0300)]
[clang] Remove unnecessary virtual inheritance in `TargetInfo`

Since the `TargetInfo` has no diamond-like inheritance diagram,
the `virtual` keyword is not necessary.

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

18 months ago[clang] Make access to submodules via `iterator_range`
Stoorx [Tue, 18 Apr 2023 20:49:00 +0000 (23:49 +0300)]
[clang] Make access to submodules via `iterator_range`

In file `clang/lib/Basic/Module.cpp` the `Module` class had `submodule_begin()` and `submodule_end()` functions to retrieve corresponding iterators for private vector of Modules. This commit removes mentioned functions, and replaces all of theirs usages with `submodules()` function and range-based for-loops.

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

18 months ago[clang] Mark CWG2009 as N/A
Vlad Serebrennikov [Mon, 24 Apr 2023 08:52:31 +0000 (11:52 +0300)]
[clang] Mark CWG2009 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG2331 is resolved by defining lookup from complete-class contexts and out-of-line member definitions. The rest of CWG2009 is resolved by making it ill-formed NDR for forward lookup outside a complete-class context to change the results (before overload resolution, to avoid differences in instantiation).
Wording: The result of the search is the declaration set of S(N, T). If it is an invalid set, the program is ill-formed. If it differs from the result of a search in T for N from immediately after the class-specifier of T, the program is ill-formed, no diagnostic required. ([class.member.lookup]/7)

Reviewed By: #clang-language-wg, shafik

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

18 months agoRevert "[SCEV] Precise trip multiples"
Joshua Cao [Mon, 24 Apr 2023 08:39:13 +0000 (01:39 -0700)]
Revert "[SCEV] Precise trip multiples"

This reverts commit 027a4c8b96c7f97df8e98b1dac069b956810ab94.

18 months ago[llvm][ADT] Fix Any linker error with multiple compilers
Sebastian Neubauer [Mon, 24 Apr 2023 08:34:59 +0000 (10:34 +0200)]
[llvm][ADT] Fix Any linker error with multiple compilers

Citing the comment in the source:

Define the type id and initialize with a non-zero value.
Initializing with a zero value means the variab can end up in either the
.data or the .bss section. This can lead to multiple definition linker
errors when some object files are compiled with a compiler that puts the
variable into .data but they are linked to object files from a different
compiler that put the variable into .bss. To prevent this issue from
happening, initialize the variable with a non-zero value, which forces
it to land in .data (because .bss is zero-initialized).

Fixes https://github.com/llvm/llvm-project/issues/62270
A regression of D139974.

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

18 months agoDrop MLIR Bazel dependency on LLVM Analysis
Alex Zinenko [Mon, 24 Apr 2023 07:33:51 +0000 (07:33 +0000)]
Drop MLIR Bazel dependency on LLVM Analysis

This is no longer necessary after f5425c128a30 and significatly
decreases the build time and the binary footprint.

Reviewed By: Dinistro

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

18 months ago[Pipelines] Don't run ForceFunctionAttrs post-link
Nikita Popov [Fri, 21 Apr 2023 08:17:03 +0000 (10:17 +0200)]
[Pipelines] Don't run ForceFunctionAttrs post-link

This is effectively a debugging pass to adjust function attributes.
I don't think it makes sense to run it in the post-link pipeline.

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

18 months ago[bazel] update for ba38640b9901d239e32e12c6569f7364d00af922
Mikhail Goncharov [Mon, 24 Apr 2023 07:35:06 +0000 (09:35 +0200)]
[bazel] update for ba38640b9901d239e32e12c6569f7364d00af922