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

`ValueType.isOverloaded` is used for;

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

Part of D146179

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

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

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

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

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

This reverts commit 84ec1f7725d4f4575474b59467e598d7c5528a4e.

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

This reverts commit 9bd0db80784e30d40a4a65f1b47109c833f05b54.

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

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

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

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

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

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

Reviewed By: jhuber6

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

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

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

Example:

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

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

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

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

Which is what this patch addresses

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

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

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

Reviewed by: NoQ, ziqingluo-90, jkorous

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

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

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

Reviewed By: jhuber6

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

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

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

Reviewed By: michaelrj

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

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

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

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

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

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

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

Reviewed By: jhuber6

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

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

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

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

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

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

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

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

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

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

Reviewed By: tahonermann

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

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

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

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

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

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

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

14 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

14 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

14 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

14 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

14 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

14 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.

14 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

14 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

14 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

14 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

14 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

14 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

14 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

14 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

14 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

14 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

14 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.

14 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

14 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

14 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

14 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.

14 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

14 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

14 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.

14 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

14 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.

14 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

14 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

14 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

14 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

14 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

14 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

14 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.

14 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

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

14 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

14 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

14 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

14 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.

14 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.

14 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.

14 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.

14 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.

14 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

14 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

14 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

14 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.

14 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

14 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

14 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.

14 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.

14 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.

14 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.

14 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.

14 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

14 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.

14 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

14 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

14 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

14 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

14 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

14 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

14 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.

14 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

14 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.

14 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.

14 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.

14 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

14 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.

14 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

14 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

14 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

14 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

14 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

14 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

14 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.

14 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]]`

14 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

14 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.

14 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.