platform/upstream/llvm.git
2 years ago[libcxx] Fixed a number of typos
Gabriel Ravier [Tue, 2 Aug 2022 10:42:04 +0000 (12:42 +0200)]
[libcxx] Fixed a number of typos

I went over the output of the following mess of a command:

`(ulimit -m 2000000; ulimit -v 2000000; git ls-files -z | parallel --xargs -0 cat | aspell list --mode=none --ignore-case | grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n | grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less)`

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

Reviewed By: #libc, philnik

Spies: philnik, libcxx-commits, mgorny, arichardson

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

2 years ago[DAG] matchRotateSub - ensure the (pre-extended) shift amount is wide enough for...
Simon Pilgrim [Tue, 2 Aug 2022 10:38:47 +0000 (11:38 +0100)]
[DAG] matchRotateSub - ensure the (pre-extended) shift amount is wide enough for the amount mask (PR56859)

matchRotateSub is given shift amounts that will already have stripped any/zero-extend nodes from - so make sure those values are wide enough to take a mask.

2 years ago[mlir] Update comment now that DenseArrayAttr has Tensor type.
Adrian Kuegel [Tue, 2 Aug 2022 10:31:22 +0000 (12:31 +0200)]
[mlir] Update comment now that DenseArrayAttr has Tensor type.

2 years ago[flang][docs][nfc] Refine FlangOptionsDocs.td
Andrzej Warzynski [Tue, 26 Jul 2022 09:49:29 +0000 (09:49 +0000)]
[flang][docs][nfc] Refine FlangOptionsDocs.td

Currently, FlangOptionsDocs.td doesn't specify `ExcludedFlags` which
means that in the generated documentation file we expose flags that:
  * we don't necessarily won't to advertise to our users (e.g. hidden flags), or
  * are not supported altogether (e.g. CL options).
This patch defines `ExcludeFlags` to fix that. The definition of
`ExcludeFlags` was copied from Clang so that LLVM frontends have
consistent documentation.

It might be a bit counter-intuitive that IncludeFlags alone is not
sufficient here. However, the current logic in ClangOptionDocEmitter.cpp
will parse IncludeFlags and print all options that contains one of the
included flags, as well as their aliases. So, for example, for -fopenmp
(which is a supported Flang option), one would also get /fopenmp (i.e.
CL mode equivalent for -fopenmp). By adding ExcludeFlags, we make sure
that such aliases are excluded.

I've also taken the liberty and moved FlangOptionsDocs.td. Originally it
was located in Flang's "flang/include" directory, but there shouldn't be
any implementation/documentation files there. Instead, I'm moving it to
the "flang/docs" directory.

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

2 years ago[NFC] Remove some boilerplate from SmallVector header
Dawid Jurczak [Tue, 2 Aug 2022 08:17:50 +0000 (10:17 +0200)]
[NFC] Remove some boilerplate from SmallVector header

In SmallVector header we use couple of times exactly same enable_if,
in this change we de-duplicate it and declare only once.

Extracted from: https://reviews.llvm.org/D129990

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

2 years ago[mlir] Use EXPECT_DEBUG_DEATH in unit test
Stephan Herhut [Tue, 2 Aug 2022 08:21:02 +0000 (10:21 +0200)]
[mlir] Use EXPECT_DEBUG_DEATH in unit test

This allows the tests to also pass when compiled in opt mode.

2 years ago[AArch64][LoopVectorize] Disable tail-folding for SVE when loop has interleaved accesses
David Sherwood [Mon, 18 Jul 2022 09:36:11 +0000 (10:36 +0100)]
[AArch64][LoopVectorize] Disable tail-folding for SVE when loop has interleaved accesses

If we have interleave groups in the loop we want to vectorise then
we should fall back on normal vectorisation with a scalar epilogue. In
such cases when tail-folding is enabled we'll almost certainly go on to
create vplans with very high costs for all vector VFs and fall back on
VF=1 anyway. This is likely to be worse than if we'd just used an
unpredicated vector loop in the first place.

Once the vectoriser has proper support for analysing all the costs
for each combination of VF and vectorisation style, then we should
be able to remove this.

Added an extra test here:

  Transforms/LoopVectorize/AArch64/sve-tail-folding-option.ll

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

2 years ago[RISCV][NFCI] Set TransientStackAlignment and rely on it rather than RVV-specific...
Alex Bradbury [Tue, 2 Aug 2022 08:43:32 +0000 (09:43 +0100)]
[RISCV][NFCI] Set TransientStackAlignment and rely on it rather than RVV-specific logic on RVV-less functions

* TargetFrameLowering has a TransientStackAlignment field that "returns
  the number of bytes to which the stack pointer must be aligned at all
  times, even between calls.
  * As explained in the [RISC-V calling
    convention](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc),
    the stack pointer must remain fully aligned throughout execution for
    compliant code. This is important for embedded targets that might avoid
    realigning the stack pointer for interrupt service routines. Systems
    running full OSes may always realign the stack anyway.
* TransientStackAlignment is used in estimateStackSize in
  MachineFrameInfo and in PEI::calculateFrameObjectOffsets.
  * estimateStackSize is only used in the RISC-V backend for scavenging
    slots. It may be possible to craft a function where the difference
    is observable, but it wouldn't be a meaningful test.
  * calculateFrameObjectOffsets makes use of TransientStackAlignment,
    but then sets the stack alignment to the max of that alignment and
    MaxAlign, which is unconditionally set to 16 in
    RISCVFrameLowering::processFunctionBeforeFrameFinalized
  * I've changed this logic to only set MaxAlign if there are RVV frame
    objects. There should be no functional change here for either RVV
    targets (MaxAlign is set as before) or non-RVV targets
    (TransientStackAlign is now 16 anyway).

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

2 years agoOutliner: add "target-cpu" feature from source function to outlined
Tim Northover [Fri, 29 Jul 2022 13:39:44 +0000 (14:39 +0100)]
Outliner: add "target-cpu" feature from source function to outlined

The CPU is used to determine which inline asm instructions are allowed, so
needs to be copied across in case the outlined function contains any.

2 years ago[RISCV][NFC] Use defined variable instead some code.
wanglian [Tue, 2 Aug 2022 07:59:27 +0000 (15:59 +0800)]
[RISCV][NFC] Use defined variable instead some code.

Reviewed By: asb

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

2 years ago[OpenMP] Fix warnings about unused expressions when OMPT_LOOP_DISPATCH is a no-op...
Martin Storsjö [Tue, 2 Aug 2022 08:15:02 +0000 (11:15 +0300)]
[OpenMP] Fix warnings about unused expressions when OMPT_LOOP_DISPATCH is a no-op. NFC.

This fixes warnings like these:

../runtime/src/kmp_dispatch.cpp:2159:24: warning: left operand of comma operator has no effect [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                       ^~~~~
../runtime/src/kmp_dispatch.cpp:2159:31: warning: left operand of comma operator has no effect [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                              ^~~~~
../runtime/src/kmp_dispatch.cpp:2159:46: warning: left operand of comma operator has no effect [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                                     ~~~~~~~ ^~
../runtime/src/kmp_dispatch.cpp:2159:50: warning: expression result unused [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                                                 ^~~~~~

2 years agoworkflows: Fix error when searching for backport reviewers
Tom Stellard [Fri, 29 Jul 2022 20:26:29 +0000 (20:26 +0000)]
workflows: Fix error when searching for backport reviewers

2 years ago[LV] Refactor getExtendedAddReductionCost to support other extended reduction more...
jacquesguan [Mon, 1 Aug 2022 03:31:57 +0000 (11:31 +0800)]
[LV] Refactor getExtendedAddReductionCost to support other extended reduction more than Add.

Now the API getExtendedAddReductionCost is used to determine the cost of extended Add reduction with optional Mul. For Arm, it could cover the cases. But for other target, for example: RISCV, they support other kinds of extended recution, such as FAdd.

This patch does the following changes:
1, Split getExtendedAddReductionCost into 2 new API: getExtendedReductionCost which handles the extended reduction with addtional input of Opcode; getMulAccReductionCost which handle the MLA cases the getExtendedAddReductionCost.
2, Refactor getReductionPatternCost, add some contraint condition to make sure the getMulAccReductionCost should only handle the reuction of Add + Mul.

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

2 years ago[mlir] Fix calling the native mlir-tblgen tool when cross compiling flang
Martin Storsjö [Fri, 15 Jul 2022 21:11:00 +0000 (00:11 +0300)]
[mlir] Fix calling the native mlir-tblgen tool when cross compiling flang

When the mlir-tblgen tool is set up, the `MLIR_TABLEGEN_EXE` variable
is set, which either points to the mlir-tblgen tool built in the current
cmake build, or points to one built in a nested cmake build (if cross
conpiling, or if building with e.g. `LLVM_OPTIMIZED_TABLEGEN`.

The `MLIR_TABLEGEN_EXE` variable is only set within the scope of the
mlir/CMakeLists.txt file, so it's unavailable in sibling level projects
such as flang.

Set the `MLIR_TABLEGEN_EXE` and the `MLIR_TABLEGEN_TARGET` variables
as global, so that flang can use them properly without guessing.

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

2 years ago[flang] Don't try to run the newly built flang-new when cross compiling
Martin Storsjö [Fri, 15 Jul 2022 21:14:02 +0000 (00:14 +0300)]
[flang] Don't try to run the newly built flang-new when cross compiling

If CMAKE_CROSSCOMPILING, then the newly built flang-new executable was
cross compiled and thus can't be executed on the build system, and thus
can't be used for generating module files.

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

2 years ago[lldb] Silence a GCC warning about missing returns after a fully covered switch....
Martin Storsjö [Tue, 2 Aug 2022 07:28:12 +0000 (10:28 +0300)]
[lldb] Silence a GCC warning about missing returns after a fully covered switch. NFC.

2 years ago[OpenMP] Only include CMAKE_DL_LIBS on unix platforms
Martin Storsjö [Mon, 1 Aug 2022 08:50:44 +0000 (11:50 +0300)]
[OpenMP] Only include CMAKE_DL_LIBS on unix platforms

CMAKE_DL_LIBS is documented as "Name of library containing dlopen
and dlclose".

On Windows platforms, there's no system provided dlopen/dlclose, but
it can be argued that if you really intend to call dlopen/dlclose,
you're going to be using a third party compat library like
https://github.com/dlfcn-win32/dlfcn-win32, and CMAKE_DL_LIBS should
expand to its name.

This has been argued upstream in CMake in
https://gitlab.kitware.com/cmake/cmake/-/issues/17600 and
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1642, that
CMAKE_DL_LIBS should expand to "dl" on mingw platforms.

The merge request wasn't merged though, as it caused some amount of
breakage, but in practice, Fedora still carries a custom CMake patch
with the same effect.

Thus, this patch fixes cross compiling OpenMP for mingw targets
on Fedora with their custom-patched CMake.

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

2 years ago[Driver] Remove Separate form for XRay options
Fangrui Song [Tue, 2 Aug 2022 07:47:36 +0000 (00:47 -0700)]
[Driver] Remove Separate form for XRay options

Supporting something like `-fxray-instruction-threshold= 1` is not intended.

2 years ago[LangRef] Fix typo in GEP docs
Nikita Popov [Tue, 2 Aug 2022 07:29:25 +0000 (09:29 +0200)]
[LangRef] Fix typo in GEP docs

Introduced in D130356, reported here:
https://reviews.llvm.org/rG7ac7ec820296#inline-7690

2 years ago[mlir][Bazel] Fix typo in file name.
Adrian Kuegel [Tue, 2 Aug 2022 07:27:20 +0000 (09:27 +0200)]
[mlir][Bazel] Fix typo in file name.

2 years ago[mlir][Bazel] Add missing dependency.
Adrian Kuegel [Tue, 2 Aug 2022 07:23:03 +0000 (09:23 +0200)]
[mlir][Bazel] Add missing dependency.

2 years ago[mlir][Bazel] Add yet another missing dependency.
Adrian Kuegel [Tue, 2 Aug 2022 07:15:43 +0000 (09:15 +0200)]
[mlir][Bazel] Add yet another missing dependency.

2 years ago[mlir][Bazel] Add missing dependency.
Adrian Kuegel [Tue, 2 Aug 2022 07:10:18 +0000 (09:10 +0200)]
[mlir][Bazel] Add missing dependency.

2 years ago[mlir][Bazel] Update bazel build after 14d79afeae63d78de9483f750fafaba13c7ae2dc
Adrian Kuegel [Tue, 2 Aug 2022 06:53:31 +0000 (08:53 +0200)]
[mlir][Bazel] Update bazel build after 14d79afeae63d78de9483f750fafaba13c7ae2dc

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

2 years agoHandles failing driver tests of clang
Purva-Chaudhari [Tue, 2 Aug 2022 06:59:26 +0000 (12:29 +0530)]
Handles failing driver tests of clang

Added support for incremental mode 8 and 28 ie. `frontend::EmitBC:` and `frontend::PrintPreprocessedInput:`
Added supporting clang tests to test in clang-repl mode

Reviewed By: v.g.vassilev

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

2 years ago[mlir][Bazel] Remove reference to deleted header.
Adrian Kuegel [Tue, 2 Aug 2022 06:34:48 +0000 (08:34 +0200)]
[mlir][Bazel] Remove reference to deleted header.

2 years ago[ELF] --reproduce: strip directories for --print-archive-stats= and --why-extract=
Fangrui Song [Tue, 2 Aug 2022 05:06:46 +0000 (22:06 -0700)]
[ELF] --reproduce: strip directories for --print-archive-stats= and --why-extract=

Similar to -o and -Map.

2 years ago[LLDB][RISCV] Add riscv register enums
Emmmer [Mon, 1 Aug 2022 10:02:06 +0000 (18:02 +0800)]
[LLDB][RISCV] Add riscv register enums

According to [RISC-V ISA Spec](https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf) and [riscv-v-spec](https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#3-vector-extension-programmers-model)

Reviewed By: DavidSpickett

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

2 years ago[libc++][ranges][NFC] Fix a few links on the Ranges status page.
Konstantin Varlamov [Tue, 2 Aug 2022 03:43:28 +0000 (20:43 -0700)]
[libc++][ranges][NFC] Fix a few links on the Ranges status page.

2 years ago[C++20] [Modules] Handle initializer for Header Units
Chuanqi Xu [Tue, 2 Aug 2022 02:26:07 +0000 (10:26 +0800)]
[C++20] [Modules] Handle initializer for Header Units

Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

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

2 years ago[mlir][Math] Add constant folder for TanOp.
jacquesguan [Mon, 1 Aug 2022 07:52:55 +0000 (15:52 +0800)]
[mlir][Math] Add constant folder for TanOp.

This patch adds constant folder for TanOp which only supports single and double precision floating-point.

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

2 years agoRevert "[C++20] [Modules] Handle initializer for Header Units"
Chuanqi Xu [Tue, 2 Aug 2022 03:08:41 +0000 (11:08 +0800)]
Revert "[C++20] [Modules] Handle initializer for Header Units"

This reverts commit db6152ad66d7cf48f9f5c3eb28bf54c092978773.

This commit fails in ppc64. Since we want to backport it to 15.x. So
revert it now to keep the patch complete.

2 years ago[Driver] Remove deprecated -fsanitize-coverage-{black,white}list=
Fangrui Song [Tue, 2 Aug 2022 02:39:25 +0000 (19:39 -0700)]
[Driver] Remove deprecated -fsanitize-coverage-{black,white}list=

2 years ago[docs] Regenerate clang/docs/ClangCommandLineReference.rst
Fangrui Song [Tue, 2 Aug 2022 02:31:25 +0000 (19:31 -0700)]
[docs] Regenerate clang/docs/ClangCommandLineReference.rst

Also update -ftime-trace='s help to fix a recommonmark error.

2 years ago[C++20] [Modules] Handle initializer for Header Units
Chuanqi Xu [Tue, 2 Aug 2022 02:26:07 +0000 (10:26 +0800)]
[C++20] [Modules] Handle initializer for Header Units

Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

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

2 years ago[mlir] Change DenseArrayAttr to TensorType
Jeff Niu [Mon, 1 Aug 2022 18:20:26 +0000 (14:20 -0400)]
[mlir] Change DenseArrayAttr to TensorType

Previously, DenseArrayAttr used VectorType for its shaped type.
VectorType is problematic for arrays because it doesn't support zero
dimensions, meaning that an empty array would have `vector<i32>` as its
type. ElementsAttr would think that an empty dense array is size 1, not
0. This patch switches over to TensorType, which does support zero
dimensions.

Fixes #56860

Reviewed By: mehdi_amini

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

2 years ago[sancov] Remove deprecated -blacklist after D113514
Fangrui Song [Tue, 2 Aug 2022 02:00:43 +0000 (19:00 -0700)]
[sancov] Remove deprecated -blacklist after D113514

2 years ago[libc] Add GNU extension functions pthread_setname_np and pthread_getname_np.
Siva Chandra Reddy [Fri, 29 Jul 2022 19:50:35 +0000 (19:50 +0000)]
[libc] Add GNU extension functions pthread_setname_np and pthread_getname_np.

Reviewed By: michaelrj, lntue

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

2 years ago[llvm-cov] Remove deprecated -name-whitelist after D112816
Fangrui Song [Tue, 2 Aug 2022 01:53:20 +0000 (18:53 -0700)]
[llvm-cov] Remove deprecated -name-whitelist after D112816

2 years ago[clang] Only run test on x86
Alex Brachet [Tue, 2 Aug 2022 00:56:05 +0000 (00:56 +0000)]
[clang] Only run test on x86

2 years ago[SelectOpti] Auto-disable other cmov optis when the new select-opti pass is enabled
Sotiris Apostolakis [Mon, 1 Aug 2022 22:21:11 +0000 (22:21 +0000)]
[SelectOpti] Auto-disable other cmov optis when the new select-opti pass is enabled

Reviewed By: davidxl

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

2 years ago[RISCV] Simplify test case from D130931. NFC
Craig Topper [Mon, 1 Aug 2022 23:50:56 +0000 (16:50 -0700)]
[RISCV] Simplify test case from D130931. NFC

2 years ago[IntelJITEvents] Add missing include.
Sunho Kim [Mon, 1 Aug 2022 23:44:18 +0000 (08:44 +0900)]
[IntelJITEvents] Add missing include.

Fixes compilation error.

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

2 years ago[mlir][NVGPU] nvgpu.mmasync on F32 through TF32
Manish Gupta [Mon, 1 Aug 2022 23:06:23 +0000 (23:06 +0000)]
[mlir][NVGPU] nvgpu.mmasync on F32 through TF32

Adds optional attribute to support tensor cores on F32 datatype by lowering to `mma.sync` with TF32 operands. Since, TF32 is not a native datatype in LLVM we are adding `tf32Enabled` as an attribute to allow the IR to be aware of `MmaSyncOp` datatype. Additionally, this patch adds placeholders for nvgpu-to-nvgpu transformation targeting higher precision tf32x3.

For mma.sync on f32 input using tensor cores there are two possibilites:
(a) tf32   (1 `mma.sync` per warp-level matrix-multiply-accumulate)
(b) tf32x3 (3 `mma.sync` per warp-level matrix-multiply-accumulate)

Typically, tf32 tensor core acceleration comes at a cost of accuracy from missing precision bits. While f32 has 23 precision bits, tf32 has only 10 precision bits. tf32x3 aims to recover the precision bits by splitting each operand into two tf32 values and issue three `mma.sync` tensor core operations.

Reviewed By: ThomasRaoux

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

2 years ago[InstCombine] Correct strtol folding with nonnull endptr
Martin Sebor [Mon, 1 Aug 2022 22:44:53 +0000 (16:44 -0600)]
[InstCombine] Correct strtol folding with nonnull endptr

Reflect in the pointer's offset the length of the leading part
of the consumed string preceding the first converted digit.

Reviewed By: efriedma

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

2 years ago[clang] Only modify FileEntryRef names that are externally remapped
Ben Langmuir [Mon, 1 Aug 2022 20:30:41 +0000 (13:30 -0700)]
[clang] Only modify FileEntryRef names that are externally remapped

As progress towards having FileEntryRef contain the requested name of
the file, this commit narrows the "remap" hack to only apply to paths
that were remapped to an external contents path by a VFS. That was
always the original intent of this code, and the fact it was making
relative paths absolute was an unintended side effect.

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

2 years ago[RISCV] Teach RISCVMergeBaseOffset to merge %lo/%pcrel_lo into load/store after foldi...
Craig Topper [Mon, 1 Aug 2022 22:26:20 +0000 (15:26 -0700)]
[RISCV] Teach RISCVMergeBaseOffset to merge %lo/%pcrel_lo into load/store after folding arithmetic.

It's possible we have:
lui  a0, %hi(sym)
addi a0, %lo(sym)
addi a0, <offset1>
lw a0, <offset2>(a0)

We want to arrive at
lui a0, %hi(sym+offset1+offset2)
lw a0, %lo(sym+offset1+offset2)

We currently fail to do this because we only consider loads/stores
if we didn't find any arithmetic.

This patch splits arithmetic folding and load/store folding into
two separate phases. The load/store folding can no longer assume
the offset in hi/lo is 0 so we must combine the offsets. I've applied
the same simm32 limit that we applied in the arithmetic folding.

Reviewed By: luismarques

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

2 years ago[SPIRV] use tablegen to create SPIRVBaseInfo*
Ilia Diachkov [Mon, 1 Aug 2022 19:56:31 +0000 (22:56 +0300)]
[SPIRV] use tablegen to create SPIRVBaseInfo*

The patch replaces SPIRVBaseInfo.* previously created using macros by
the tablegen approach. There are many small changes in other files due to
differences in namespaces. Also, functions in SPIRVUtils are moved to
the llvm namespace.

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2 years ago[clang] Make test agnostic to file seperator character
Alex Brachet [Mon, 1 Aug 2022 22:12:04 +0000 (22:12 +0000)]
[clang] Make test agnostic to file seperator character

2 years ago[clang] Re-enable test after marking it XFAIL
Alex Brachet [Mon, 1 Aug 2022 21:52:58 +0000 (21:52 +0000)]
[clang] Re-enable test after marking it XFAIL

This test had to be disabled because ps4 targets don't support
-fuse-ld. Preferably, this should just be unsupported for ps4
targets. However no such lit feature exists so I have just gone
ahead and set the target explicitly. Moreover, this needs
to create a terminal link step, either an executable or shared
object to get the link error. With the change to the explicit
target I've had to also add -nostartfiles -nostdlib so that
clang doesn't pull crt files into the link which may not be
present. Again, this would likely be solved if this test
was unsupported for the one platform that disables -fuse-ld

2 years ago[mlir] Remove OpaqueElementsAttr
River Riddle [Sat, 16 Jul 2022 03:08:32 +0000 (20:08 -0700)]
[mlir] Remove OpaqueElementsAttr

This attribute is technical debt from the early stages of MLIR, before
ElementsAttr was an interface and when it was more difficult for
dialects to define their own types of attributes. At present it isn't
used at all in tree (aside from being convenient for eliding other
ElementsAttr), and has had little to no evolution in the past three years.

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

2 years agoFold assert-used variable into assert
David Blaikie [Mon, 1 Aug 2022 21:56:05 +0000 (21:56 +0000)]
Fold assert-used variable into assert

Fixes #56724

2 years ago[clang] Update code that assumes FileEntry::getName is absolute NFC
Ben Langmuir [Mon, 1 Aug 2022 20:18:31 +0000 (13:18 -0700)]
[clang] Update code that assumes FileEntry::getName is absolute NFC

It's an accident that we started return asbolute paths from
FileEntry::getName for all relative paths. Prepare for getName to get
(closer to) return the requested path. Note: conceptually it might make
sense for the dependency scanner to allow relative paths and have the
DependencyConsumer decide if it wants to make them absolute, but we
currently document that it's absolute and I didn't want to change
behaviour here.

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

2 years ago[libc][doc] Update implementation status of tanhf.
Tue Ly [Mon, 1 Aug 2022 21:44:39 +0000 (17:44 -0400)]
[libc][doc] Update implementation status of tanhf.

2 years ago[LLDB][NFC][Correctness] Fix bad null check
Slava Gurevich [Mon, 1 Aug 2022 20:46:37 +0000 (13:46 -0700)]
[LLDB][NFC][Correctness] Fix bad null check

Fix incorrect null-check logic, likely cause by copy-paste

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

2 years ago[BOLT][DWARF] Fix handling of multiple DW_OP_addrx in an expression
Alexander Yermolovich [Mon, 1 Aug 2022 21:38:47 +0000 (14:38 -0700)]
[BOLT][DWARF] Fix handling of multiple DW_OP_addrx in an expression

We were not handling correclty multiple DW_OP_addrx in the location expression.
This was exposed by clang-15 build in release mode with debug information.

Reviewed By: maksfb

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

2 years ago[MLIR] Reduce precision check for expm1 folder: this is dependent on libm (NFC)
Mehdi Amini [Mon, 1 Aug 2022 21:25:43 +0000 (21:25 +0000)]
[MLIR] Reduce precision check for expm1 folder: this is dependent on libm (NFC)

We noticed this failing depending on the platform, checking the last few
digit isn't necessary for this test anyway.

2 years ago[clang] Temporarily expect failure from test
Alex Brachet [Mon, 1 Aug 2022 21:10:56 +0000 (21:10 +0000)]
[clang] Temporarily expect failure from test

2 years ago[clang] Don't create executable in test
Alex Brachet [Mon, 1 Aug 2022 20:59:40 +0000 (20:59 +0000)]
[clang] Don't create executable in test

2 years ago[libc][math] Build fail fix: obsolete header.
Kirill Okhotnikov [Mon, 1 Aug 2022 20:54:26 +0000 (22:54 +0200)]
[libc][math] Build fail fix: obsolete header.

2 years ago[trace] Replace TraceCursorUP with TraceCursorSP
Jakob Johnson [Mon, 1 Aug 2022 14:34:47 +0000 (07:34 -0700)]
[trace] Replace TraceCursorUP with TraceCursorSP

The use of `std::unique_ptr` with `TraceCursor` adds unnecessary complexity to adding `SBTraceCursor` bindings
Specifically, since `TraceCursor` is an abstract class there's no clean
way to provide "deep clone" semantics for `TraceCursorUP` short of
creating a pure virtual `clone()` method (afaict).

After discussing with @wallace, we decided there is no strong reason to
favor wrapping `TraceCursor` with `std::unique_ptr` over `std::shared_ptr`, thus this diff
replaces all usages of `std::unique_ptr<TraceCursor>` with `std::shared_ptr<TraceCursor>`.

This sets the stage for future diffs to introduce `SBTraceCursor`
bindings in a more clean fashion.

Test Plan:

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

2 years ago[RISCV] Move Pre-RA pseudo expansion from addMachineSSAOptimization to addPreRegAlloc.
Craig Topper [Mon, 1 Aug 2022 20:42:01 +0000 (13:42 -0700)]
[RISCV] Move Pre-RA pseudo expansion from addMachineSSAOptimization to addPreRegAlloc.

addMachineSSAOptimization is skipped for -O0, but this pass is
required for -O0.

2 years ago[libc][math] Added tanhf function.
Kirill Okhotnikov [Thu, 28 Jul 2022 13:25:56 +0000 (15:25 +0200)]
[libc][math] Added tanhf function.

Correct rounding function. Performance ~2x faster than glibc analog.

Performance (llvm 12 intel):
```
CORE_MATH_PERF_MODE=rdtsc PERF_ARGS='' ./perf.sh tanhf
GNU libc version: 2.31
GNU libc release: stable
13.279
37.492
18.145
CORE_MATH_PERF_MODE=rdtsc PERF_ARGS='--latency' ./perf.sh tanhf
GNU libc version: 2.31
GNU libc release: stable
40.658
109.582
66.568
```

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

2 years ago[clang] Fix build when targeting ps4
Alex Brachet [Mon, 1 Aug 2022 20:31:01 +0000 (20:31 +0000)]
[clang] Fix build when targeting ps4

-fuse-ld is not available for ps4 targets

2 years ago[Libomptarget][NFC] Remove unused CMake file
Joseph Huber [Mon, 1 Aug 2022 20:20:24 +0000 (16:20 -0400)]
[Libomptarget][NFC] Remove unused CMake file

Summary:
This file is no longer used, get rid of it.

2 years ago[flang] Fix flang GCC Buildbot broken by D130731
Markus Böck [Mon, 1 Aug 2022 20:15:36 +0000 (22:15 +0200)]
[flang] Fix flang GCC Buildbot broken by D130731

GCC and that specific build bot issued warnings turned errors, due to a narrowing conversion from `unsigned` to `int32_t`. Silence these via a static_cast.

2 years ago[TTI][AArch64][SLP] Sets the cost of an ADD reduction 2xi64 to 2.
Vasileios Porpodas [Fri, 29 Jul 2022 00:01:15 +0000 (17:01 -0700)]
[TTI][AArch64][SLP] Sets the cost of an ADD reduction 2xi64 to 2.

2xi64 is the legalized type for wide reductions (like 16xi64) and setting the
cost to 2 makes `load-reduce` and `load-zext-reduce` patterns profitable.

The few performance measurments that I did on an aarch64 machine confirm that
these patterns are actually faster when vectorized.

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

2 years ago[Driver] Re-run lld with --reproduce when it crashes
Alex Brachet [Mon, 1 Aug 2022 19:59:45 +0000 (19:59 +0000)]
[Driver] Re-run lld with --reproduce when it crashes

This was discussed on https://discourse.llvm.org/t/rfc-generating-lld-reproducers-on-crashes/58071/12

When lld crashes, or errors when -gen-reproducer=error
and -fcrash-diagnostics=all clang will re-run lld with
--reproduce=$temp_file for easily reproducing the
crash/error.

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

2 years ago[Libomptarget] Replace std::vector with llvm::SmallVector
Joseph Huber [Mon, 1 Aug 2022 18:57:27 +0000 (14:57 -0400)]
[Libomptarget] Replace std::vector with llvm::SmallVector

The runtime makes some use of `std::vector` data structures. We should
be able to replace these trivially with `llvm::SmallVector` instead.
This should allow us to avoid heap allocations in the majority of cases
now.

Reviewed By: tianshilei1992

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

2 years ago[RISCV] Pre-commit tests for D130931. NFC
Craig Topper [Mon, 1 Aug 2022 19:33:11 +0000 (12:33 -0700)]
[RISCV] Pre-commit tests for D130931. NFC

2 years ago[MachineFunctionPass] Support -print-changed={,c}diff{,-quiet}
Fangrui Song [Mon, 1 Aug 2022 19:56:15 +0000 (12:56 -0700)]
[MachineFunctionPass] Support -print-changed={,c}diff{,-quiet}

Follow-up to D130434.
Move doSystemDiff to PrintPasses.cpp and call it in MachineFunctionPass.cpp.

Reviewed By: aeubanks

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

2 years ago[mlir] Add a new builtin DenseResourceElementsAttr
River Riddle [Wed, 20 Jul 2022 01:22:55 +0000 (18:22 -0700)]
[mlir] Add a new builtin DenseResourceElementsAttr

This attributes is intended cover the current set of use cases that abuse
DenseElementsAttr, e.g. when the data is large. Using resources for large
data is one of the major reasons why they were added; e.g. they can be
deallocated mid-compilation, they support a wide variety of data origins
(e.g, heap allocated, mmap'd, etc.), they can support mutation, etc.

I considered at length not having a builtin variant of this, and instead
having multiple versions of this attribute for dialects that are interested,
but they all boiled down to the exact same attribute definition. Given the
generality of this attribute, it feels more aligned to keep it next to DenseArrayAttr
(given that DenseArrayAttr covers the "small" case, and DenseResourcesElementsAttr
covers the "large" case). The underlying infra used to build this attribute is
general, and having a builtin attribute doesn't preclude users from defining
their own when it makes sense (they can even share a blob manager with the
builtin dialect to avoid data duplication).

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

2 years ago[mlir] Add a generic DialectResourceBlobManager to simplify resource blob management
River Riddle [Tue, 26 Jul 2022 01:25:26 +0000 (18:25 -0700)]
[mlir] Add a generic DialectResourceBlobManager to simplify resource blob management

The DialectResourceBlobManager class provides functionality for managing resource blobs
in a generic, dialect-agnostic fashion. In addition to this class, a dialect interface and custom
resource handle are provided to simplify referencing and interacting with the manager. These
classes intend to simplify the work required for dialects that want to manage resource blobs
during compilation, such as for large elements attrs.  The old manager for the resource example
in the test dialect has been updated to use this, which provides and cleaner and more consistent API.

This commit also adds new HeapAsmResourceBlob and ImmortalAsmResourceBlob to simplify
creating resource blobs in common scenarios.

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

2 years ago[mlir][Arith] Fix up integer range inference for truncation
Krzysztof Drewniak [Mon, 25 Jul 2022 17:22:18 +0000 (17:22 +0000)]
[mlir][Arith] Fix up integer range inference for truncation

Attempting to apply the range analysis to real code revealed that
trunci wasn't correctly handling the case where truncation would
create wider ranges - for example, if we truncate [255, 257] : i16 to
i8, the result can be 255, 0, or 1, which isn't a contiguous range of
values.

The previous implementation would naively map this to [255, 1], which
would cause issues with unsigned ranges and unification.

Reviewed By: Mogball

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

2 years ago[AMDGPU] Fix DGEMM hazard for GFX90a
Vang Thao [Wed, 27 Jul 2022 21:17:31 +0000 (14:17 -0700)]
[AMDGPU] Fix DGEMM hazard for GFX90a

For VALU write and memory (VM, L/DS, FLAT) instructions, SQ would insert
wait-states to avoid data hazard. However when there is a DGEMM instruction
in-between them, SQ incorrectly disables the wait-states thus the data hazard
needs to be handled with this workaround.

Reviewed By: rampitec

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

2 years ago[trace][intelpt] Update TraceIntelPTBundleSaver.cpp to accommodate FileSpec API changes
Jakob Johnson [Mon, 1 Aug 2022 18:41:46 +0000 (11:41 -0700)]
[trace][intelpt] Update TraceIntelPTBundleSaver.cpp to accommodate FileSpec API changes

D130309 introduced changes to the FileSpec API which broke usages of
`GetCString()` in TraceIntelPTBundleSaver.cpp. This diff replaces usages
of `GetCString()` with `GetPath().c_str()` as suggested by D130309.

Test Plan:
Building with the trace plug-in now succeeds

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

2 years ago[clangd] Add decl/def support to SymbolDetails
David Goldman [Mon, 18 Jul 2022 20:32:59 +0000 (16:32 -0400)]
[clangd] Add decl/def support to SymbolDetails

Add an optional declarationRange and definitionRange to SymbolDetails.

This will allow SourceKit-LSP to implement toggling between goto
definition/declaration based on whether the symbol at the cursor
is a definition or declaration.

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

2 years ago[NFC][TTI][AArch64][SLP] Precommit test for a TTI cost fix of i64 add reductions.
Vasileios Porpodas [Thu, 28 Jul 2022 23:40:22 +0000 (16:40 -0700)]
[NFC][TTI][AArch64][SLP] Precommit test for a TTI cost fix of i64 add reductions.

2 years ago[RISCV] Explicitly select second operand of branch condition to X0.
Craig Topper [Mon, 1 Aug 2022 18:16:48 +0000 (11:16 -0700)]
[RISCV] Explicitly select second operand of branch condition to X0.

At least based on the lit tests, the coalescer sometimes fails to
propagate the copy from X0 into the branch instruction. This patch
does it manually during isel. The majority of the changes are from
the select patterns.

Some of the changes are just register allocation changes. Only
the Select change affects the whether a b*z instruction is generated
in the tests. I changed the branch pattern for consistency.

Reviewed By: asb

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

2 years ago[tsan][test] Remaining tests requiring weak symbols for dyld64
Roy Sundahl [Mon, 1 Aug 2022 17:43:52 +0000 (10:43 -0700)]
[tsan][test] Remaining tests requiring weak symbols for dyld64

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

2 years ago[mlir][sparse] fix asan leak of two sparse vectors
Aart Bik [Mon, 1 Aug 2022 16:23:03 +0000 (09:23 -0700)]
[mlir][sparse] fix asan leak of two sparse vectors

Reviewed By: Peiming

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

2 years ago[RISCV][Clang] Add tests for all supported policy functions. (NFC)
Zakk Chen [Mon, 1 Aug 2022 17:42:43 +0000 (17:42 +0000)]
[RISCV][Clang] Add tests for all supported policy functions. (NFC)

In order to make the review easier, I split a lot of tests from
https://reviews.llvm.org/D126742

Reviewed By: rogfer01

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

2 years ago[RISCV][Clang] Support RVV policy functions.
Zakk Chen [Fri, 27 May 2022 00:19:50 +0000 (17:19 -0700)]
[RISCV][Clang] Support RVV policy functions.

1. Add policy functions support and tests for vadd, vmv, vfmv and all load
   instructions except segment load. I didn't add all combination of policy
   functions in test because it seem not to make sense.
2. Rename HasUnMaskedOverloaded to SupportOverloading.
3. vmv.s.x for ta policy could not have overloaded API.
4. This patch does not support all operations, I will have other follow-up
   patches support all.

[RFC] https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/137

Reviewed By: kito-cheng, fakepaper56, fakepaper56

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

2 years agoFixed a number of typos
Gabriel Ravier [Mon, 1 Aug 2022 17:12:11 +0000 (13:12 -0400)]
Fixed a number of typos

I went over the output of the following mess of a command:

(ulimit -m 2000000; ulimit -v 2000000; git ls-files -z |
 parallel --xargs -0 cat | aspell list --mode=none --ignore-case |
 grep -E '^[A-Za-z][a-z]*$' | sort | uniq -c | sort -n |
 grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' -f2 | less)

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

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

2 years agoclang-tidy doc: fix some typos
Sylvestre Ledru [Mon, 1 Aug 2022 16:54:10 +0000 (18:54 +0200)]
clang-tidy doc: fix some typos

2 years ago[openmp] [test] Fix prepending config.library_dir to LD_LIBRARY_PATH
Michał Górny [Sat, 30 Jul 2022 18:53:02 +0000 (20:53 +0200)]
[openmp] [test] Fix prepending config.library_dir to LD_LIBRARY_PATH

Fix the LD_LIBRARY_PATH prepending order to make sure that
config.library_path ends up before any potentially-system directories
(e.g. config.hwloc_library_dir).  This makes sure that we are testing
against the just-built openmp libraries rather than the version that is
already installed.

Also rename the function to `prepend_*` to make it clearer what it
actually does.

https://github.com/llvm/llvm-project/issues/56821
Differential Revision: https://reviews.llvm.org/D130825

2 years agomisc-const-correctness: fix the link to readability-isolate-declaration
Sylvestre Ledru [Mon, 1 Aug 2022 16:52:49 +0000 (18:52 +0200)]
misc-const-correctness: fix the link to readability-isolate-declaration

2 years ago[lldb] [llgs] Support resuming multiple processes via vCont w/ nonstop
Michał Górny [Fri, 1 Jul 2022 13:12:00 +0000 (15:12 +0200)]
[lldb] [llgs] Support resuming multiple processes via vCont w/ nonstop

Support using the vCont packet to resume multiple processes
simultaneously when in non-stop mode.  The new logic now assumes that:

- actions without a thread-id or with process id of "p-1" apply to all
  debugged processes

- actions with a thread-id without process id apply to the current
  process (m_continue_process)

As with the other continue packets, it is only possible to resume
processes that are currently stopped (or stop these that are running).
It is unsupported to resume or stop individual threads of a running
process.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128989

2 years ago[lldb] [test] Fix test_c_both_nonstop flakiness
Michał Górny [Mon, 1 Aug 2022 16:04:46 +0000 (18:04 +0200)]
[lldb] [test] Fix test_c_both_nonstop flakiness

Thanks to Pavel Labath for reporting this and suggesting a fix.

Sponsored by: The FreeBSD Foundation

2 years ago[RISCV] Eagerly delete instructions in MergeBaseOffset.
Craig Topper [Mon, 1 Aug 2022 16:32:46 +0000 (09:32 -0700)]
[RISCV] Eagerly delete instructions in MergeBaseOffset.

The only iterator we're holding points to HiLUI and we never
delete that so I think it is safe to delete everything else
immediately.

I want to split detectAndFoldOffset into two phases. First, combine
LUI+ADDI with any ADD/ADDI/SHXADD that comes after it. This may
open opportunities to fold the ADDI from the LUI+ADDI into a
load/store address. So the load/store folding should run as a
second phase even if the ADD/ADDI/SHXADD made changes.

In order to do this we need to eagerly delete instructions in the
first phase so that we don't have dead users of the LUI+ADDI
when we start the second phase.

Patches to split the phases will come later.

Reviewed By: asb, luismarques

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

2 years ago[RISCV][VP] Custom lower VP_STRIDED_LOAD and VP_STRIDED_STORE
Lorenzo Albano [Mon, 1 Aug 2022 16:23:45 +0000 (09:23 -0700)]
[RISCV][VP] Custom lower VP_STRIDED_LOAD and VP_STRIDED_STORE

Reviewed By: craig.topper

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

2 years ago[HLSL] CodeGen HLSL Resource annotations
Chris Bieneman [Mon, 18 Jul 2022 15:08:08 +0000 (10:08 -0500)]
[HLSL] CodeGen HLSL Resource annotations

HLSL Resource types need special annotations that the backend will use
to build out metadata and resource annotations that are required by
DirectX and Vulkan drivers in order to provide correct data bindings
for shader exeuction.

This patch adds some of the required data for unordered-access-views
(UAV) resource binding into the module flags. This data will evolve
over time to cover all the required use cases, but this should get
things started.

Depends on D130018.

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

2 years ago[AMDGPU] Extend cases for ReadM0MovRelInterpHazard
Piotr Sobczak [Mon, 1 Aug 2022 15:36:52 +0000 (17:36 +0200)]
[AMDGPU] Extend cases for ReadM0MovRelInterpHazard

Extend hazard recognizer of ReadM0MovRelInterpHazard with
DS_READ_ADDTID and DS_WRITE_ADDTID, as they also
require a manually inserted S_NOP after SALU writing m0.

Reviewed By: rampitec

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

2 years ago[mlir][flang] Make use of the new `GEPArg` builder of GEP Op to simplify code
Markus Böck [Thu, 28 Jul 2022 23:00:22 +0000 (01:00 +0200)]
[mlir][flang] Make use of the new `GEPArg` builder of GEP Op to simplify code

This is the follow up on https://reviews.llvm.org/D130730 which goes through upstream code and removes creating constant values in favour of using the constant indices in GEP directly. This leads to less and more readable code and more compact IR as well.

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

2 years agoAST.h - fix Wdocumentation warnings. NFC.
Simon Pilgrim [Mon, 1 Aug 2022 14:38:06 +0000 (15:38 +0100)]
AST.h - fix Wdocumentation warnings. NFC.

But ObjC code examples in quotes to stop confusing the doxygen parser

2 years agoOffloadBundler.cpp - fix Wdocumentation warnings. NFC.
Simon Pilgrim [Mon, 1 Aug 2022 14:24:47 +0000 (15:24 +0100)]
OffloadBundler.cpp - fix Wdocumentation warnings. NFC.

Fix param list instead of embedding \p tag

2 years agoSelectionDAGNodes.h - fix Wdocumentation warnings. NFC.
Simon Pilgrim [Mon, 1 Aug 2022 14:09:16 +0000 (15:09 +0100)]
SelectionDAGNodes.h - fix Wdocumentation warnings. NFC.

2 years agoMisExpect.h - fix Wdocumentation warnings. NFC.
Simon Pilgrim [Mon, 1 Aug 2022 14:06:12 +0000 (15:06 +0100)]
MisExpect.h - fix Wdocumentation warnings. NFC.

2 years ago[lldb] Fix flakyness in TestProcessList
Pavel Labath [Mon, 1 Aug 2022 14:00:46 +0000 (16:00 +0200)]
[lldb] Fix flakyness in TestProcessList

If the test is too fast it can read the process list before the forked
child process actually manages to exec the process with the right
arguments.

Use our file-based synchronization primitives to ensure the child is
up-and-running before we fetch the process list.

2 years ago[AMDGPU][MC] Verify selection of LDS MUBUF opcodes
Dmitry Preobrazhensky [Mon, 1 Aug 2022 13:40:47 +0000 (16:40 +0300)]
[AMDGPU][MC] Verify selection of LDS MUBUF opcodes

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