platform/upstream/llvm.git
2 years ago[Docs] Clarify the guideline on omitting braces
owenca [Thu, 26 May 2022 23:07:53 +0000 (16:07 -0700)]
[Docs] Clarify the guideline on omitting braces

While working on a clang-format option RemoveBracesLLVM that removes
braces following the guideline, we were unsure about what to do with
the braces of do-while loops. The ratio of using to omitting the
braces is about 4:1 in the llvm-project source, so it will help to
add an example to the guideline.

Also cleans up the original examples including making the nested if
example more targeted on avoiding potential dangling else situations.

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

2 years ago[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values
Endre Fülöp [Sun, 22 May 2022 21:28:10 +0000 (23:28 +0200)]
[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values

Clang Tidy check cert-oop57-cpp now checks for arbitrary-valued
arguments in memset expressions containing non-trivially
default-constructible instances. Previously it only checked literal 0 values.

Reviewed By: aaron.ballman

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

2 years agoRevert "[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values"
Endre Fülöp [Wed, 1 Jun 2022 06:21:16 +0000 (08:21 +0200)]
Revert "[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values"

Revert to fix a ReleaseNote issue.

This reverts commit d33f199910fa02cf7072f3227913e670c98d03a9.

2 years ago[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values
Endre Fülöp [Sun, 22 May 2022 21:28:10 +0000 (23:28 +0200)]
[clang-tidy] Extend cert-oop57-cpp to check non-zero memset values

Clang Tidy check cert-oop57-cpp now checks for arbitrary-valued
arguments in memset expressions containing non-trivially
default-constructible instances. Previously it only checked literal 0 values.

Reviewed By: aaron.ballman

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

2 years ago[RISCV] Set target-abi explicitly to reduce codegen results
wangpc [Wed, 1 Jun 2022 05:48:57 +0000 (13:48 +0800)]
[RISCV] Set target-abi explicitly to reduce codegen results

As mentioned in D125947, we can reduce codegen results by
adding an explicit hard single-float ABI.

Reviewed By: luismarques

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

2 years ago[AArch64][test] Replace -march with -mtriple for llc RUN lines
Fangrui Song [Wed, 1 Jun 2022 05:39:43 +0000 (22:39 -0700)]
[AArch64][test] Replace -march with -mtriple for llc RUN lines

-march is error-prone: -march inherits the OS and environment from the default
target triple. Use -mtriple which is more common.

2 years ago[X86][test] Remove unneeded -mtriple from llc RUN lines
Fangrui Song [Wed, 1 Jun 2022 05:35:07 +0000 (22:35 -0700)]
[X86][test] Remove unneeded -mtriple from llc RUN lines

2 years ago[libc] Implement FLAGS option for generating all combinations for targets.
Tue Ly [Sun, 8 May 2022 17:45:40 +0000 (13:45 -0400)]
[libc] Implement FLAGS option for generating all combinations for targets.

Add FLAGS option for add_header_library, add_object_library,
add_entrypoint_object, and add_libc_unittest.

In general, a flag is a string provided for supported functions under the
multi-valued option `FLAGS`.  It should be one of the following forms:
  FLAG_NAME
  FLAG_NAME__NO
  FLAG_NAME__ONLY
A target will inherit all the flags of its upstream dependency.

When we create a target `TARGET_NAME` with a flag using (add_header_library,
add_object_library, ...), its behavior will depend on the flag form as follow:
- FLAG_NAME: The following 2 targets will be generated:
    `TARGET_NAME` that has `FLAG_NAME` in its `FLAGS` property.
    `TARGET_NAME.__NO_FLAG_NAME` that depends on `DEP.__NO_FLAG_NAME` if
       `TARGET_NAME` depends on `DEP` and `DEP` has `FLAG_NAME` in its `FLAGS`
       property.
- FLAG_NAME__ONLY: Only generate 1 target `TARGET_NAME` that has `FLAG_NAME`
    in its `FLAGS` property.
- FLAG_NAME__NO: Only generate 1 target `TARGET_NAME.__NO_FLAG_NAME` that
    depends on `DEP.__NO_FLAG_NAME` if `DEP` is in its DEPENDS list and `DEP`
    has `FLAG_NAME` in its `FLAGS` property.

To show all the targets generated, pass SHOW_INTERMEDIATE_OBJECTS=ON to cmake.
To show all the targets' dependency and flags, pass
`SHOW_INTERMEDIATE_OBJECTS=DEPS` to cmake.

To completely disable a flag FLAG_NAME expansion, set the variable
`SKIP_FLAG_EXPANSION_FLAG_NAME=TRUE`.

Reviewed By: michaelrj, sivachandra

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

2 years agoRevert "[Bazel][GN] Reuse the GN LLVM config file generation code"
Reid Kleckner [Wed, 1 Jun 2022 04:15:46 +0000 (21:15 -0700)]
Revert "[Bazel][GN] Reuse the GN LLVM config file generation code"

This reverts commit e2ee8bf9818189b900e65d6ea8f1ae6fc75455ce.

This change is beyond my ability to integrate into Google's internal
build configuration tonight.

2 years ago[CSKY] Fix error of underestimated function size by save/restore R15(LR) when we...
Zi Xuan Wu (Zeson) [Wed, 1 Jun 2022 02:42:33 +0000 (10:42 +0800)]
[CSKY] Fix error of underestimated function size by save/restore R15(LR) when we use BSR far jump.

In CSKYConstantIslands, when fix up an unconditional branch(CSKY::BR32) whose destination is
too far away to fit in its displacement field, and if the R15(LR) register has been
spilled in the prologue, then we can use BSR to implement a far jump. So we need estimate function
size, and spill R15(LR) when the function size >= unconditional branch(CSKY::BR32) can reach.

EstimateFunctionSizeInBytes function adds up all instructions and constant pool entries(each entry is 4 bytes).

2 years ago[Hexagon][test] Fix some tests on linux-musl
Fangrui Song [Wed, 1 Jun 2022 02:55:50 +0000 (19:55 -0700)]
[Hexagon][test] Fix some tests on linux-musl

-march=hexagon uses the default target triple and changes the arch part of
hexagon. On linux-musl, this essentially becomes hexagon-unknown-linux-musl
which has different code generation. Use -mtriple instead.

Link: https://github.com/llvm/llvm-project/issues/48936
2 years ago[PowerPC] Remove const from paired vector store builtins
Nemanja Ivanovic [Wed, 1 Jun 2022 02:49:28 +0000 (21:49 -0500)]
[PowerPC] Remove const from paired vector store builtins

For some reason, we implemented the xx_stxvp intrinsics
to require a const pointer. This absolutely doesn't make
sense for a store. Remove the const from the definition.

2 years ago[Bazel][GN] Reuse the GN LLVM config file generation code
Reid Kleckner [Fri, 27 May 2022 19:21:33 +0000 (12:21 -0700)]
[Bazel][GN] Reuse the GN LLVM config file generation code

Currently, the Bazel build uses static, checked in [llvm-]config.h files
in combination with global macro definitions to mimic CMake's generated
headers. This change reuses the write_cmake_config.py script from the GN
build to generate the headers from source in the same way. The purpose
is to ensure that the Bazel build stays up to date with any changes to
the CMake config files. The write_cmake_config.py script has good error
checking to ensure that unneeded, stale variables are not passed, and
that any missing variables are reported as errors.

I tried to closely follow the logic in the GN build here:
  llvm/utils/gn/secondary/llvm/include/Config/BUILD.gn
The duplication between this file and config.bzl is significant, and we
could consider going further, but I'd like to hold off on it for now.

The GN build changes are to move the write_cmake_config.py script up to
//llvm/utils/write_cmake_config.py, and update the paths accordingly.

The next logical change is to generate Clang's config.h header.

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

2 years ago[Bazel] Add missing dep after mlgo test change f46dd19b480496d2ba0a57d12935882e530f2b93
Reid Kleckner [Wed, 1 Jun 2022 02:39:35 +0000 (19:39 -0700)]
[Bazel] Add missing dep after mlgo test change f46dd19b480496d2ba0a57d12935882e530f2b93

2 years ago[HIP] Pass -Xoffload-linker option to device linker
Yaxun (Sam) Liu [Tue, 31 May 2022 15:17:39 +0000 (11:17 -0400)]
[HIP] Pass -Xoffload-linker option to device linker

Reuse -Xoffload-linker option for HIP toolchain.

Reviewed by: Artem Belevich

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

2 years ago[HIP] Fix static lib name on windows
Yaxun (Sam) Liu [Mon, 30 May 2022 19:21:14 +0000 (15:21 -0400)]
[HIP] Fix static lib name on windows

clang by default assumes static library name to be xxx.lib
when -lxxx is specified on Windows with MSVC environment,
instead of libxxx.a.

This patch fixes static device library unbundling for that.
It falls back to libxxx.a if xxx.lib is not found.

Reviewed by: Artem Belevich

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

2 years ago[X86] Add support for `-mharden-sls=[none|all|return|indirect-jmp]`
Phoebe Wang [Wed, 1 Jun 2022 01:24:34 +0000 (09:24 +0800)]
[X86] Add support for `-mharden-sls=[none|all|return|indirect-jmp]`

The patch addresses the feature request from https://github.com/ClangBuiltLinux/linux/issues/1633. The implementation borrows a lot from aarch64.

Reviewed By: nickdesaulniers, MaskRay

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

2 years ago[InstCombine] [NFC] remove useless TODO
Chenbing Zheng [Wed, 1 Jun 2022 01:29:05 +0000 (09:29 +0800)]
[InstCombine] [NFC] remove useless TODO

2 years ago[BOLT][DWARF] Fix dwarf5-debug-line test
Alexander Yermolovich [Tue, 31 May 2022 23:56:57 +0000 (16:56 -0700)]
[BOLT][DWARF] Fix dwarf5-debug-line test

After D126484, order in .debug-line-str and .debug-line is different. Changed
test accordingly.

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

2 years ago[Sanitizers][Darwin] Deprecate SANITIZER_MAC - fail compilation if encountered
Mariusz Borsa [Fri, 27 May 2022 23:15:07 +0000 (16:15 -0700)]
[Sanitizers][Darwin] Deprecate SANITIZER_MAC - fail compilation if encountered

Previous couple commits replaced SANITIZER_MAC with SANITIZER_APPLE in bulk.
This change will prompt anyone still trying to use SANITIZER_MAC to rename.

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

2 years ago[HLSL] add -D option for dxc mode.
Xiang Li [Tue, 10 May 2022 21:22:29 +0000 (14:22 -0700)]
[HLSL] add -D option for dxc mode.

Create dxc_D as alias to option D which Define <macro> to <value> (or 1 if <value> omitted).

Reviewed By: aaron.ballman

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

2 years ago[BOLT] Add new class for symbolizing X86 instructions
Maksim Panchenko [Wed, 23 Feb 2022 03:06:25 +0000 (19:06 -0800)]
[BOLT] Add new class for symbolizing X86 instructions

Summary:
While disassembling instructions, we need to replace certain immediate
operands with symbols. This symbolizing process relies on reading
relocations against instructions. However, some X86 instructions can
have multiple immediate operands and up to two relocations against
them. Thus, correctly matching a relocation to an operand is not
always possible without knowing the operand offset within the
instruction.

Luckily, LLVM provides an interface for passing the required info from
the disassembler via a virtual MCSymbolizer class. Creating a
target-specific version allows a precise matching of relocations to
operands.

This diff adds X86MCSymbolizer class that performs X86-specific
symbolizing (currently limited to non-branch instructions).

Reviewers: yota9, Amir, ayermolo, rafauler, zr33

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

2 years ago[RISCV][NFC] Rename variables in rvv intrinsics related files.
Zakk Chen [Mon, 30 May 2022 05:31:12 +0000 (22:31 -0700)]
[RISCV][NFC] Rename variables in rvv intrinsics related files.

This patch does the same thing as D125886 did.

- Use `Overloaded` rather than `Mangled`.
- Use `Prototype` or `Desc` rather than `Seq`, it's not just a string
sequence.

Reviewed By: fakepaper56

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

2 years ago[mlir][sparse] Using x-macros in the function-suffix functions
wren romano [Tue, 31 May 2022 21:39:34 +0000 (14:39 -0700)]
[mlir][sparse] Using x-macros in the function-suffix functions

By defining the `{primary,overhead}TypeFunctionSuffix` functions via the same x-macros used to generate the runtime library's functions themselves, this helps avoid bugs from typos or things getting out of sync.

Reviewed By: bixia

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

2 years ago[mlgo] Incrementally update FunctionPropertiesInfo during inlining
Mircea Trofin [Tue, 3 May 2022 23:10:07 +0000 (16:10 -0700)]
[mlgo] Incrementally update FunctionPropertiesInfo during inlining

Re-computing FunctionPropertiesInfo after each inlining may be very time
consuming: in certain cases, e.g. large caller with lots of callsites,
and when the overall IR doesn't increase (thus not tripping a size bloat
threshold).

This patch addresses this by incrementally updating
FunctionPropertiesInfo.

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

2 years ago[LoopIdiom] Fix bailout for aliasing in memcpy transform.
Eli Friedman [Tue, 31 May 2022 23:51:03 +0000 (16:51 -0700)]
[LoopIdiom] Fix bailout for aliasing in memcpy transform.

Commit dd5991cc modified the aliasing checks here to allow transforming
a memcpy where the source and destination point into the same object.
However, the change accidentally made the code skip the alias check for
other operations in the loop.

Instead of completely skipping the alias check, just skip the check for
whether the memcpy aliases itself.

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

2 years agoFix a copy-paste error in "br com add -s py -o 'some_python' BKPT_NAME"
Jim Ingham [Wed, 1 Jun 2022 00:22:18 +0000 (17:22 -0700)]
Fix a copy-paste error in "br com add -s py -o 'some_python' BKPT_NAME"

The function that was supposed to iterate over all the breakpoints sharing
BKPT_NAME stopped after the first one because of a reversed "if success"
condition.

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

2 years agoAdapt LLDB for D120540.
Adrian Prantl [Tue, 31 May 2022 20:54:58 +0000 (13:54 -0700)]
Adapt LLDB for D120540.

In https://reviews.llvm.org/D120540 the -fcxx-modules flag changed
semantics and specifying it explicitly seems to no longer be what we
want here.

2 years ago[test] Remove an outdated FIXME
Yuki Okushi [Fri, 27 May 2022 10:49:41 +0000 (19:49 +0900)]
[test] Remove an outdated FIXME

rG6a9c719ee1be4562a9e16f2c71ac3e51ef9c4292 removed the backticks and this FIXME comment is no longer necessary.

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

2 years ago[clangd] Remove a test with a duplicate of FileCacheTests
Yuki Okushi [Sun, 29 May 2022 01:11:10 +0000 (10:11 +0900)]
[clangd] Remove a test with a duplicate of FileCacheTests

FIXME says it should be removed so followed it.

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

2 years ago[CodeGen][AArch64] Add support for LDAPR
Alexander Shaposhnikov [Tue, 31 May 2022 21:40:50 +0000 (21:40 +0000)]
[CodeGen][AArch64] Add support for LDAPR

This diff adds support for LDAPR (RCPC extension)
(https://github.com/llvm/llvm-project/issues/55561).

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

Test plan: ninja check-all

2 years ago[mlir][sparse] Improving the FATAL macro
wren romano [Tue, 31 May 2022 20:06:10 +0000 (13:06 -0700)]
[mlir][sparse] Improving the FATAL macro

The previous macro definition using `{...}` would fail to compile when the callsite uses a semicolon followed by an else-statement (i.e., `if (...) FATAL(...); else ...;`).  Replacing the simple braces with `do{...}while(0)` (n.b., semicolon not included in the macro definition) enables callsites to use the semicolon plus else-statement syntax without problems.  The new definition now requires the semicolon at all callsites, but since it was already being called that way nothing changes.

For more explanation, see <https://gcc.gnu.org/onlinedocs/cpp/Swallowing-the-Semicolon.html>

Reviewed By: aartbik

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

2 years ago[Bazel] Fix typo: startlark=>starlark
Fangrui Song [Tue, 31 May 2022 21:12:40 +0000 (14:12 -0700)]
[Bazel] Fix typo: startlark=>starlark

2 years ago[AMDGPU] Fix image opcodes GlobalISel on gfx90a.
Stanislav Mekhanoshin [Tue, 24 May 2022 18:43:00 +0000 (11:43 -0700)]
[AMDGPU] Fix image opcodes GlobalISel on gfx90a.

- Correct flavor of an instruction was not selected.
- GFX90A does not support TFE.

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

2 years ago[gn build] Port 13e1a653278b
LLVM GN Syncbot [Tue, 31 May 2022 21:00:23 +0000 (21:00 +0000)]
[gn build] Port 13e1a653278b

2 years ago[flang][nfc] Fix Windows build
Andrzej Warzynski [Tue, 31 May 2022 20:57:35 +0000 (20:57 +0000)]
[flang][nfc] Fix Windows build

* Breaking change: https://reviews.llvm.org/D125832
* Buildbot failure: https://lab.llvm.org/buildbot/#/builders/172/builds/13123

Sending this without a review - this is a rather straightforward fix.

2 years ago[libc] add fprintf and file_writer
Michael Jones [Wed, 18 May 2022 23:58:17 +0000 (16:58 -0700)]
[libc] add fprintf and file_writer

This patch adds the file_writer header, which just provides a wrapper
for File->write, as well as fprintf to use it. There are no unit tests
for file_writer since it's too simple to need them, but fprintf does
have a simple test of writing to a file.

Reviewed By: sivachandra

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

2 years ago[HLSL] Enable vector types for hlsl.
Xiang Li [Thu, 5 May 2022 22:31:22 +0000 (15:31 -0700)]
[HLSL] Enable vector types for hlsl.

Vector types in hlsl is using clang ext_vector_type.
Declaration of vector types is in builtin header hlsl.h.
hlsl.h will be included by default for hlsl shader.

Reviewed By: Anastasia

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

2 years ago[BOLT] [AArch64] Handle constant islands spanning multiple functions
Denis Revunov [Tue, 31 May 2022 18:50:59 +0000 (11:50 -0700)]
[BOLT] [AArch64] Handle constant islands spanning multiple functions

Fix BOLT's constant island mapping when a constant island marked by $d
spans multiple functions. Currently, because BOLT only marks the
constant island in the first function where $d is located, if the next
function contains data at its start, BOLT will miss the data and try
to disassemble it. This patch adds code to explicitly go through all
symbols between $d and $x markers and mark their respective offsets as
data, which stops BOLT from trying to disassemble data. It also adds
MarkerType enum and refactors related functions.

Reviewed By: yota9, rafauler

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

2 years agoRevert "[clangd] Fix hover crashing on integral or enumeral casts"
Sam McCall [Tue, 31 May 2022 20:29:37 +0000 (22:29 +0200)]
Revert "[clangd] Fix hover crashing on integral or enumeral casts"

This reverts commit ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d.

Fails on bots e.g. https://buildkite-cloud.s3.amazonaws.com/logs-by-pipeline/f8ab115f-a384-49e8-a048-0f71ab03c5d0/0181020b-0737-40e5-a05a-ab198347d8ad/0181020b-ecbe-4ac6-ad23-e04c17217893.log?response-content-disposition=inline&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQPCP3C7LT7IGTS76%2F20220531%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220531T202904Z&X-Amz-Expires=600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDwaCXVzLWVhc3QtMSJGMEQCIEfw6ocELTUWa2mj4reHKLe5OdUmQqVJpPsdZS2wNDhhAiB7qx6Q17HVVY%2BkJZ5hwTQ6b1MkOG4czysfciD9GghJmCrSBAg1EAAaDDAzMjM3OTcwNTMwMyIMgdUfJT4A6wcP2hl2Kq8EefYtGIt0yaiOSfuq05UzI6WcBY9yOOyYCs3%2FJJDvK3jkpiYQhjA1kgVluePIb3P4yOTXs8lv9U6p8HU555Vzvrv1Wg%2FGvx7U398lH8zg%2BqkvEwnpGuRf0pTInPJftg2bgm%2F7l%2BCM6PtW4mRlzjeQ0IoA3AeENqVM35RYtQdh%2BcAZIfV4l7uAySVgwY1yFu0XznuGAVVryZyYcA2cjKkkNE%2F9n2QTo80%2FbZBvoh1bxJqXRbs5WrSnWlIEj3RPX61ir7lDpRNL5tyVlqsv%2BvV01aS%2F9JbM4cNDXZ%2BDwOR1Q%2By1ajJOomuK9Bqm%2Fq8%2B9%2Byo1t8rFSN7I4X%2BGGuicXFQQnIJAkW3zSQlx9SWrf2uDg7cbXL4MukD9cQB5aN8yX85a%2BRcbb5l4%2BOC%2B8UFKMeemUZyEl5PyyJSBnAnzqvKviJPev9Thj9rZeHGEJD9vOkVM%2FG2tOlC7HUxXAE4kuLlAdeKdIOtHz%2Bx8FzRn%2Bgl6EB2nB4kSVLvfgrsrlHS0L0J1zWbN%2F6prqzum%2FEVIhT7Y5fyZRqtygAX2n7iBjQEM3vpF2GTneUI1FlDeQvGPLADFdq7bXSUOt577YOTw1mW1JzqmZljrJeIM40HdMYnuIg3%2FwW8oK6RKGADdW7URPw%2FoFeGKfrnN%2BuDwJKvrRGCpReseGse2sdYIe28rgGHpc5xsp3pzipQDLfW3hTNtM%2FNNuPJjUWZoBRTMr2eMuk2zs2c6jNvnuBTbgXjcdjCbjCX2dmUBjqqAUalggvk2TGoJzTuqAT%2Fj1kz0vnHdmsHY3B9aR2kY501gISXQMKj7l03E7OfFsu4oPzEgmnyQFKcAolRDI%2F7NRmG8HwtP40iTCjflOHIxkJ1%2FnVNqkeyIznUu6zOr589zIjNqFCm74jOfWjj2%2FO8WU4pc%2FRqeBuGzzpQkAIGGxCwsmd3WG8Z8pyMoJomij7c4LO6ep4O0OUESxbXHcIfzUfR6ajPsKFKS9lb&X-Amz-SignedHeaders=host&X-Amz-Signature=96a132be6f99b5cd5cf29f3226115e480508079047bc8639d69c672f1fe9f0c1

2 years ago[mlir][sparse] Factoring out SparseTensorFile class for readSparseTensorShape
wren romano [Tue, 31 May 2022 19:55:01 +0000 (12:55 -0700)]
[mlir][sparse] Factoring out SparseTensorFile class for readSparseTensorShape

The primary goal of this change is to define readSparseTensorShape.  Whereas the SparseTensorFile class is merely introduced as a way to reduce code duplication along the way.

Depends On D126106

Reviewed By: aartbik

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

2 years ago[HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.
Xiang Li [Fri, 13 May 2022 21:36:27 +0000 (14:36 -0700)]
[HLSL][clang][Driver] Parse target profile early to update Driver::TargetTriple.

This is to avoid err_target_unknown_abi which is caused by use default TargetTriple instead of shader model target triple.

Reviewed By: beanz

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

2 years ago[clangd] Fix hover crashing on integral or enumeral casts
Georg Kotheimer [Tue, 31 May 2022 19:57:51 +0000 (21:57 +0200)]
[clangd] Fix hover crashing on integral or enumeral casts

When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.

2 years ago[windows] Remove unused pybind exception params
Nathaniel McVicar [Tue, 31 May 2022 17:03:48 +0000 (10:03 -0700)]
[windows] Remove unused pybind exception params

Resolve MSVC warning C4104 for unreferenced variable

Reviewed By: mehdi_amini

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

2 years ago[BOLT] Allow merge-fdata to take a directory as input
Yi Kong [Tue, 31 May 2022 13:14:31 +0000 (21:14 +0800)]
[BOLT] Allow merge-fdata to take a directory as input

and recursively merge all files under said directory. This is similar
to `llvm-profdata merge`.

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

2 years ago[pseudo] Respect LLVM_USE_HOST_TOOLS
Sam McCall [Tue, 31 May 2022 18:45:22 +0000 (20:45 +0200)]
[pseudo] Respect LLVM_USE_HOST_TOOLS

This is the intended way to request that build-time tools be built in a
distinct configuration.

This is set implicitly by LLVM_OPTIMIZED_TABLEGEN, which may be
surprising, but if undesired this should be fixed elsewhere.

Should fix crbug.com/1330304

2 years ago[BOLT] Fix LIT tests on Windows VS2019
Rafael Auler [Tue, 31 May 2022 18:45:15 +0000 (11:45 -0700)]
[BOLT] Fix LIT tests on Windows VS2019

Fix newline issue in link_fdata.py, as well as how to call the tool.

Reviewed By: Amir

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

2 years ago[flang] Rename `flang` as `flang-to-external-fc`
Andrzej Warzynski [Tue, 17 May 2022 19:36:27 +0000 (19:36 +0000)]
[flang] Rename `flang` as `flang-to-external-fc`

Our ultimate goal is to rename `flang-new` as `flang`. This is "Step 1"
in which we only rename the bash wrapper script, `flang`, as
`flang-to-external-fc`. The new name more accurately reflects what the
wrapper script does.

With this patch, `flang` becomes a symbolic link pointing to
`flang-to-external-fc`. This allows a smooth transmission for any
buildbots that use this script. Once the buildbots are reconfigured to
use the updated name, CMake rule for the symbolic link will be removed.

For more context see:
  * https://discourse.llvm.org/t/rename-flang-new-as-flang,
  * https://reviews.llvm.org/D125788.

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

2 years ago[DFSan] build-libc-list.py no longer provides a list of default files.
Andrew Browne [Wed, 25 May 2022 22:40:01 +0000 (15:40 -0700)]
[DFSan] build-libc-list.py no longer provides a list of default files.

Reviewed By: vitalybuka

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

2 years ago[libc++][CI] AIX does not have alternative for time_put_byname
zhijian [Tue, 31 May 2022 18:20:34 +0000 (14:20 -0400)]
[libc++][CI] AIX does not have alternative for time_put_byname

Reviewers: David Tenty, Mark de Wever

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

2 years agoCreate specialization of -Wgnu-statement-expression for expressions found in macros.
Michael Wyman [Fri, 27 May 2022 05:39:04 +0000 (22:39 -0700)]
Create specialization of -Wgnu-statement-expression for expressions found in macros.

-Wgnu-statement-expression currently warns for both direct source uses of statement expressions but also macro expansions; since they may be used by macros to avoid multiple evaluation of macro arguments, engineers might want to suppress warnings when statement expressions are expanded from macros but see them if introduced directly in source code.

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

2 years ago[libc++][CI] fixed "LOCALE_fr_FR_UTF_8" for my_facet for AIX
zhijian [Tue, 31 May 2022 18:12:01 +0000 (14:12 -0400)]
[libc++][CI] fixed "LOCALE_fr_FR_UTF_8" for my_facet for AIX

SUMMARY:

fixed "LOCALE_fr_FR_UTF_8" for my_facet for AIX

Reviewers: David Tenty, Mark de Wever

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

2 years ago[MLIR][Presburger] Simplex::computeOptimum: slightly simplify code (NFC)
Arjun P [Wed, 25 May 2022 15:46:45 +0000 (16:46 +0100)]
[MLIR][Presburger] Simplex::computeOptimum: slightly simplify code (NFC)

2 years ago[gn build] Port 2e61dfb1249e
LLVM GN Syncbot [Tue, 31 May 2022 17:57:18 +0000 (17:57 +0000)]
[gn build] Port 2e61dfb1249e

2 years ago[libc++][CI] fixed convert_thousands_sep_ru_RU for Russian in the libcxx/test/support...
zhijian [Tue, 31 May 2022 17:55:59 +0000 (13:55 -0400)]
[libc++][CI] fixed convert_thousands_sep_ru_RU for Russian in the libcxx/test/support/locale_helpers.h for AIX

Reviewers: David Tenty, Mark de Wever

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

2 years ago[AMDGPU] Instruction Type Pipeline
jeff [Mon, 16 May 2022 18:13:20 +0000 (11:13 -0700)]
[AMDGPU] Instruction Type Pipeline

This patch implements a DAG mutation which adds edges between different groups of instructions. The purpose is to try to generate code that conforms to a pipeline (groupA instructions occur before groupB, groupB -> groupC, and so on). Currently the pipeline order is hardcoded as VMEM->DSRead->MFMA->DSWrite, but the patch was designed to be easily extensible. Alias analysis is problematic for pipelining as memory instructions will usually not be able to be reordered w.r.t one another.

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

2 years agoFix windows build
Alex Brachet [Tue, 31 May 2022 17:31:55 +0000 (17:31 +0000)]
Fix windows build

2 years ago[clang][Driver] Fix SIE builders
Alex Brachet [Tue, 31 May 2022 17:24:58 +0000 (17:24 +0000)]
[clang][Driver] Fix SIE builders

2 years ago[riscv] add test coverage for fractional lmul w/fixed length vectorization
Philip Reames [Tue, 31 May 2022 17:09:44 +0000 (10:09 -0700)]
[riscv] add test coverage for fractional lmul w/fixed length vectorization

2 years ago[RISCV] Use two ADDIs to do some stack pointer adjustments.
Craig Topper [Tue, 31 May 2022 17:14:34 +0000 (10:14 -0700)]
[RISCV] Use two ADDIs to do some stack pointer adjustments.

If the adjustment doesn't fit in 12 bits, try to break it into
two 12 bit values before falling back to movImm+add/sub.

This is based on a similar idea from isel.

Reviewed By: luismarques, reames

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

2 years ago[libc++][CI][AIX] change grouping() return value of std::moneypunct_byname for en_US...
zhijian [Tue, 31 May 2022 17:20:31 +0000 (13:20 -0400)]
[libc++][CI][AIX] change grouping() return value of std::moneypunct_byname for en_US.UTF-8

Reviewers: David Tenty, Mark de Wever
Differential Revision: https://reviews.llvm.org/D126474

2 years ago[libc++] Removes __cpp_lib_monadic_optional.
Mark de Wever [Tue, 17 May 2022 17:15:18 +0000 (19:15 +0200)]
[libc++] Removes __cpp_lib_monadic_optional.

P0798R8 "Monadic operations for std::optional" has been implemented, so
this LWG issue can be adopted.

During review it was discovered another paper bumped the macro. The
part affecting optional of this paper is done, the variant isn't. The
status page is updated to reflect the current state.

Implements
- LWG 3621 Remove feature-test macro __cpp_lib_monadic_optional

Updates status of
- P2231R1 Missing constexpr in std::optional and std::variant

Reviewed By: #libc, philnik, ldionne

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

2 years ago[scudo] Ensure pointer is not null
Alex Brachet [Tue, 31 May 2022 17:16:49 +0000 (17:16 +0000)]
[scudo] Ensure pointer is not null

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

2 years ago[InstrProf] Stop exporting lprofDirMode
Alex Brachet [Tue, 31 May 2022 17:13:00 +0000 (17:13 +0000)]
[InstrProf] Stop exporting lprofDirMode

This symbol should not be exposed and doesn't need to be.

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

2 years ago[Clang] Extend -gen-reproducer flag
Alex Brachet [Tue, 31 May 2022 17:10:16 +0000 (17:10 +0000)]
[Clang] Extend -gen-reproducer flag

`-gen-reproducer` causes crash reproduction to be emitted
even when clang didn't crash, and now can optionally take an
argument of never, on-crash (default), on-error and always.

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

2 years ago[RISCV] Fix a few corner case bugs in RISCVMergeBaseOffsetOpt::matchLargeOffset
Craig Topper [Tue, 31 May 2022 16:43:43 +0000 (09:43 -0700)]
[RISCV] Fix a few corner case bugs in RISCVMergeBaseOffsetOpt::matchLargeOffset

The immediate for LUI is stored as 20-bit unsigned value. We need
to sign extend if after shifting by 12 to match the instruction
behavior.

If we find an LUI+ADDI on RV64, it means the constant isn't a
simm32. If it was, we would have emitted LUI+ADDIW from constant
materialization. Make sure the constant is a simm32 before folding.
This appears to match gcc.

A future patch will add support for LUI+ADDIW on RV64.

2 years ago[RISCV] Pre-commit tests for D126635. NFC
Craig Topper [Tue, 31 May 2022 16:41:03 +0000 (09:41 -0700)]
[RISCV] Pre-commit tests for D126635. NFC

2 years ago[InstCombine] fold icmp of sext bool based on limited range
Sanjay Patel [Tue, 31 May 2022 15:39:29 +0000 (11:39 -0400)]
[InstCombine] fold icmp of sext bool based on limited range

X <=u (sext i1 Y) --> (X == 0) | Y

https://alive2.llvm.org/ce/z/W_tZzo

This is the conjugate/sibling pattern suggested with D126171
for a sign-extended bool value.

2 years ago[InstCombine] add tests for icmp of sext i1; NFC
Sanjay Patel [Tue, 31 May 2022 15:02:43 +0000 (11:02 -0400)]
[InstCombine] add tests for icmp of sext i1; NFC

These are adapted from the zext tests added for D126171.

2 years ago[X86] Add test case for PR55648
Simon Pilgrim [Tue, 31 May 2022 16:21:34 +0000 (17:21 +0100)]
[X86] Add test case for PR55648

2 years ago[X86] LowerMINMAX - split v4i64 types on AVX1 targets (Issue #55648)
Simon Pilgrim [Tue, 31 May 2022 16:17:39 +0000 (17:17 +0100)]
[X86] LowerMINMAX - split v4i64 types on AVX1 targets (Issue #55648)

Originally we tried to use default expansion for v4i64 types to make it easier to concatenate the results back together, but this can cause infinite loop issues with existing VSELECT splitting code in narrowExtractedVectorSelect if we have other uses of the VSELECT results (e.g. reduction patterns).

To fix the infinite loop, this patch always splits MIN/MAX v4i64 nodes during lowering and I've added a TODO for combineConcatVectorOps to investigate when we can cheaply concatenate VSELECT/BLENDV nodes together.

Fixes #55648 - regression test case will be added in a follow up.

2 years ago[Clang][Docs] Fix typo in offload packager reference
Joseph Huber [Tue, 31 May 2022 16:27:15 +0000 (12:27 -0400)]
[Clang][Docs] Fix typo in offload packager reference

2 years ago[MLIR][Math] Improve docs (NFC)
lorenzo chelini [Mon, 30 May 2022 10:19:10 +0000 (12:19 +0200)]
[MLIR][Math] Improve docs (NFC)

Remove boilerplate examples and add a text at the dialect level to describe
what kind of operands the operations accept (i.e., scalar, tensor or vector).
Left a shorter sentence describing the input operands for each operation as
this redundancy is convenient when browsing the documentation using the
website.

Reviewed By: ftynse

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

2 years ago[Clang][Docs] Document the clang-offload-packager better
Joseph Huber [Tue, 31 May 2022 15:52:44 +0000 (11:52 -0400)]
[Clang][Docs] Document the clang-offload-packager better

Summary:
This patch adds more in-depth documentation to the
clang-offload-packacker's binary format. This format is used to create
fat binaries and link them.

2 years ago[clangd] Minor fixes to ExtractVariableTests missed in D124486
David Goldman [Tue, 31 May 2022 15:32:23 +0000 (11:32 -0400)]
[clangd] Minor fixes to ExtractVariableTests missed in D124486

2 years ago[flang] Support BIND(C) variable scope check
PeixinQiao [Tue, 31 May 2022 15:26:00 +0000 (23:26 +0800)]
[flang] Support BIND(C) variable scope check

As Fortran 2018 C819, a variable with the BIND attribute shall be declared
in the specification part of a module. Add the support for this check.

Reviewed By: klausler

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

2 years ago[Scalarizer] Regenerate test checks (NFC)
Nikita Popov [Tue, 31 May 2022 15:21:58 +0000 (17:21 +0200)]
[Scalarizer] Regenerate test checks (NFC)

2 years ago[PS5] Tweak dllexport test
Paul Robinson [Tue, 31 May 2022 15:21:10 +0000 (08:21 -0700)]
[PS5] Tweak dllexport test

Post-commit review pointed out that both PS4 and PS5 were using the
same -std argument, better to use different ones just in case.

2 years ago[AMDGPU] gfx11 Image instructions
Joe Nash [Thu, 12 May 2022 13:27:48 +0000 (09:27 -0400)]
[AMDGPU] gfx11 Image instructions

MC layer support for instructions in the MIMG encoding(Image
instructions).

Contributors:
Carl Ritson <carl.ritson@amd.com>

Patch 13/N for upstreaming of AMDGPU gfx11 architecture.

Depends on D125992

Reviewed By: rampitec, #amdgpu

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

2 years ago[clangd] ExtractVariable support for C and Objective-C
David Goldman [Tue, 26 Apr 2022 19:30:50 +0000 (15:30 -0400)]
[clangd] ExtractVariable support for C and Objective-C

- Use the expression's type for non-C++ as the variable type. This works
  well, but might not preserve the typedefs due to type
  canonicalization.

- Improve support for Objective-C property references which are
  represented using `ObjCPropertyRefExpr` and `BuiltinType::PseudoObject`.

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

2 years ago[X86] combineEXTRACT_SUBVECTOR - pull out repeated getVectorNumElements() calls....
Simon Pilgrim [Tue, 31 May 2022 15:13:41 +0000 (16:13 +0100)]
[X86] combineEXTRACT_SUBVECTOR - pull out repeated getVectorNumElements() calls. NFC.

2 years agoLangRef: fix bad indentation in allockind bullets
Augie Fackler [Tue, 31 May 2022 15:06:15 +0000 (11:06 -0400)]
LangRef: fix bad indentation in allockind bullets

2 years ago[Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp
Daniel McIntosh [Mon, 30 May 2022 17:13:29 +0000 (13:13 -0400)]
[Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp

The new tests in clang/test/Driver/modules.cpp added by D120540 will fail if the
toolchain getting tested doesn't support linking. This reduces the utility of
the test since we would like a failure of this test to reflect a problem with
modules. We should already have other tests that validate linking support.

Reviewed By: ChuanqiXu

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

2 years ago[AArch64] Remove references to Streaming SVE from target features.
Sander de Smalen [Wed, 18 May 2022 06:26:50 +0000 (07:26 +0100)]
[AArch64] Remove references to Streaming SVE from target features.

Following discussion on D120261 and D121208 it seems better to remove the
concept of Streaming SVE from the subtarget/assembler predicates and
instead reason about 'SVE' and 'SME' as its higher level features, rather
than trying to model this runtime mode through explicit feature flags.

This patch is largely NFC.

Reviewed By: paulwalker-arm, david-arm

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

2 years agoRevert "[Libomptarget] Add `leaf` attribute to `vprintf` declaration"
Joseph Huber [Tue, 31 May 2022 14:14:51 +0000 (10:14 -0400)]
Revert "[Libomptarget] Add `leaf` attribute to `vprintf` declaration"

This is preventing users from calling `printf` on NVPTX code. Revert for
now until there is a fix.

This reverts commit eda4ef3add4d25345e0b29580776f1576040c525.

2 years agoBuildLibCalls: infer allockind attributes on relevant functions
Augie Fackler [Tue, 29 Mar 2022 18:27:30 +0000 (14:27 -0400)]
BuildLibCalls: infer allockind attributes on relevant functions

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

2 years agoattributes: introduce allockind attr for describing allocator fn behavior
Augie Fackler [Tue, 29 Mar 2022 15:14:07 +0000 (11:14 -0400)]
attributes: introduce allockind attr for describing allocator fn behavior

I chose to encode the allockind information in a string constant because
otherwise we would get a bit of an explosion of keywords to deal with
the possible permutations of allocation function types.

I'm not sure that CodeGen.h is the correct place for this enum, but it
seemed to kind of match the UWTableKind enum so I put it in the same
place. Constructive suggestions on a better location most certainly
encouraged.

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

2 years ago[X86] narrowExtractedVectorSelect - don't peek through bitcasts to find source vector
Simon Pilgrim [Tue, 31 May 2022 13:57:10 +0000 (14:57 +0100)]
[X86] narrowExtractedVectorSelect - don't peek through bitcasts to find source vector

We don't seem to need this for any test coverage and it was making tracking of the uses() of the source vector more difficult

Noticed while investigating Issue #55648

2 years ago[InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)
Nikita Popov [Mon, 30 May 2022 15:09:40 +0000 (17:09 +0200)]
[InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)

When reassociating GEPs, we can only keep inbounds if both original
GEPs were inbounds, and their offsets have the same sign. For the
sake of simplicity, I only handle the case where both offsets are
non-negative here.

It would probably be fine to just not preserve inbounds at all here,
but as I don't see a compile-time impact for adding the
isKnownNonNegative() calls I went with this more conservative
approach.

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

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

2 years ago[Clang] Always set opaque pointers mode
Nikita Popov [Tue, 31 May 2022 13:40:46 +0000 (15:40 +0200)]
[Clang] Always set opaque pointers mode

Always set the opaque pointers mode, to make sure that
-no-opaque-pointers continues working when the default on the LLVM
side is flipped.

2 years ago[X86] LowerTRUNCATE - avoid creating extract_subvector(bitcast(vec)) patterns
Simon Pilgrim [Tue, 31 May 2022 13:30:28 +0000 (14:30 +0100)]
[X86] LowerTRUNCATE - avoid creating extract_subvector(bitcast(vec)) patterns

We have a generic DAG combine to attempt to fold extract_subvector(bitcast(vec)) -> bitcast(extract_subvector(vec)) but if we create these patterns late in lowering then we often miss them.

Noticed while investigating Issue #55648 which gets caught in an infinite loop trying to split extract_subvector(bitcast(vselect()) patterns - this doesn't fix the issue yet but reduces the regressions from the WIP fix.

2 years ago[libc++abi][AIX] add personality and helper functions for the state table EH
Xing Xue [Tue, 31 May 2022 13:21:34 +0000 (09:21 -0400)]
[libc++abi][AIX] add personality and helper functions for the state table EH

Summary:
This patch adds the personality and helper functions for the state table based EH used by IBM legacy compilers xlC and xlclang++ on AIX.

 * A high level description of the state table based EH is provided in the code comments.

 * Function scan_state_tab() is added to scan the state table. It is invoked by the state table personality routine __xlcxx_personality_v0() and returns scan_results like scan_eh_tab() does.

 * A couple of EH helper functions used by xlC and xlclang++ generated code are also added, e.g., __xlc_catch_matchv2() which checks whether the thrown object matches the catch handler's exception type.

 * Debugging macros _LIBCXXABI_TRACE_STATETAB, _LIBCXXABI_TRACE_STATETAB0, and _LIBCXXABI_TRACING_STATETAB are added to dump state table scanning traces if environment variable LIBCXXABI_PRINT_STATTAB is set.

 * The state variable and state table data is the LSDA found from the traceback table of the function during unwinding.

Reviewed by: MaskRay, cebowleratibm, libc++abi

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

2 years ago[NFC] Change LoopVectorizationCostModel::useOrderedReductions() to be a const function.
Mel Chen [Tue, 31 May 2022 12:38:44 +0000 (05:38 -0700)]
[NFC] Change LoopVectorizationCostModel::useOrderedReductions() to be a const function.

Reviewed By: fhahn

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

2 years ago[InstCombine] Fix const folding of switches with default case
Danila Malyutin [Mon, 30 May 2022 13:30:49 +0000 (16:30 +0300)]
[InstCombine] Fix const folding of switches with default case

In case phi was in the default block it could lead to multi-edge.
Fixes #55721.

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

2 years ago[mlir][Bazel] Adjust BUILD.bazel file
Adrian Kuegel [Tue, 31 May 2022 11:35:49 +0000 (13:35 +0200)]
[mlir][Bazel] Adjust BUILD.bazel file

2 years agoApply clang-tidy fixes for llvm-else-after-return in OpPythonBindingGen.cpp (NFC)
Mehdi Amini [Mon, 30 May 2022 14:44:00 +0000 (14:44 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in OpPythonBindingGen.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in SparseTensorUtils.cpp...
Mehdi Amini [Mon, 30 May 2022 13:56:16 +0000 (13:56 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in SparseTensorUtils.cpp (NFC)

2 years ago[bazel] Port 42c17073fcba
Benjamin Kramer [Tue, 31 May 2022 11:47:01 +0000 (13:47 +0200)]
[bazel] Port 42c17073fcba

2 years ago[AMDGPU][DOC][NFC] Add GFX90C and GFX940 assembler syntax description
Dmitry Preobrazhensky [Tue, 31 May 2022 11:29:06 +0000 (14:29 +0300)]
[AMDGPU][DOC][NFC] Add GFX90C and GFX940 assembler syntax description

2 years ago[mlir] Support import llvm intrinsics.
jacquesguan [Mon, 30 May 2022 09:38:33 +0000 (09:38 +0000)]
[mlir] Support import llvm intrinsics.

This patch supports to convert the llvm intrinsic to the corresponding op. It still leaves some intrinsics to be handled specially.

Reviewed By: ftynse

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