platform/upstream/llvm.git
13 months agoRevert "[msan] Intercept dladdr1, and refactor dladdr"
Thurston Dang [Sat, 1 Jul 2023 20:27:11 +0000 (20:27 +0000)]
Revert "[msan] Intercept dladdr1, and refactor dladdr"

Reverting my commit because of buildbot breakage.

This reverts commit d0b0dbeae17756f7ba99e0867cfb867fcb375066.

13 months ago[msan] Intercept dladdr1, and refactor dladdr
Thurston Dang [Fri, 30 Jun 2023 23:08:20 +0000 (23:08 +0000)]
[msan] Intercept dladdr1, and refactor dladdr

This patch adds an msan interceptor for dladdr1 (with support
for RTLD_DL_LINKMAP and RTLD_DL_SYMENT) and an accompanying
test. It also adds a helper file, msan_dl.cpp, that contains
UnpoisonDllAddrInfo (refactored out of the dladdr interceptor)
and UnpoisonDllAddr1ExtraInfo.

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

13 months ago[AArch64] Remove duplicate code (NFC)
Evandro Menezes [Sat, 1 Jul 2023 18:26:14 +0000 (13:26 -0500)]
[AArch64] Remove duplicate code (NFC)

Remove multiple versions of the predicate that checks if the
instruction operand is shifted by up to 4.

13 months ago[libc] Missing FEnvImpl.h dependency on math.h
Petr Hosek [Thu, 29 Jun 2023 06:48:10 +0000 (06:48 +0000)]
[libc] Missing FEnvImpl.h dependency on math.h

FEnvImpl.h includes math.h and so needs an explicit dependency.

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

13 months ago[RISCV] Add a test with unknown argument of .attribute directive
Sergei Barannikov [Sat, 1 Jul 2023 02:11:31 +0000 (05:11 +0300)]
[RISCV] Add a test with unknown argument of .attribute directive

13 months ago[AArch64] Add scheduling model for Neoverse N1
Evandro Menezes [Thu, 22 Jun 2023 23:40:53 +0000 (18:40 -0500)]
[AArch64] Add scheduling model for Neoverse N1

Add the scheduling model for Neoverse N1.

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

13 months ago[clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression
Piotr Zegar [Sat, 1 Jul 2023 16:20:36 +0000 (16:20 +0000)]
[clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

Fixed issue with the comparison of UnaryExprOrTypeTraitExpr
objects in which only the argument type was checked, without
considering the kind of expression. This led to false positives when
using sizeof(x) and alignof(x) expressions, as only the
comparison x = x was performed without checking if sizeof
was equal to alignof.

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

Reviewed By: Izaron

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

13 months ago[libc++] Implement stringbuf members of P0408R7 (Efficient Access to basic_stringbuf...
Piotr Fusik [Sat, 1 Jul 2023 11:33:48 +0000 (13:33 +0200)]
[libc++] Implement stringbuf members of P0408R7 (Efficient Access to basic_stringbuf's Buffer)

Reviewed By: #libc, Mordante

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

13 months ago[libc++][doc] Updates spaceship status.
Mark de Wever [Sat, 1 Jul 2023 10:37:02 +0000 (12:37 +0200)]
[libc++][doc] Updates spaceship status.

Work on the missing chrono parts has started, but their operators will
be added in different patches. So split the remaining chrono part to one
entry per line and mark them in progress.

13 months ago[libc++] Enables constexpr string tests.
Mark de Wever [Fri, 30 Jun 2023 15:33:47 +0000 (17:33 +0200)]
[libc++] Enables constexpr string tests.

These tests were disabled during constant evaluation in D90569. At that
time constexpr string was not implemented. It now is.

Reviewed By: #libc, philnik

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

13 months ago[clang-tidy] Improve documentation for modernize-use-std-print check
Mike Crowe [Sat, 1 Jul 2023 08:40:20 +0000 (08:40 +0000)]
[clang-tidy] Improve documentation for modernize-use-std-print check

Remove incorrect use of double colons so that the code blocks are
rendered correctly to HTML.

Wrap the name of another check in single backticks. Wrap the name of a
macro in double backticks.

Explain that with the default settings the check is only enabled with
C++23 or later standards.

Correct std::string_data() to std::string::data().

Reviewed By: PiotrZSL

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

13 months ago[LTO] Fix a missing comment
Haojian Wu [Sat, 1 Jul 2023 06:33:45 +0000 (08:33 +0200)]
[LTO] Fix a missing comment

Address a missing code-review comment: https://reviews.llvm.org/D154191#inline-1490951

13 months ago[bazel] Port bazel support for 5bf8efd269f8b75b5be40f087f231d71f744885c
Haojian Wu [Sat, 1 Jul 2023 06:27:26 +0000 (08:27 +0200)]
[bazel] Port bazel support for 5bf8efd269f8b75b5be40f087f231d71f744885c

13 months ago[LTO] Replace llvm::writeFileAtomically with llvm::writeToOutput API.
Haojian Wu [Fri, 30 Jun 2023 08:38:59 +0000 (10:38 +0200)]
[LTO] Replace llvm::writeFileAtomically with llvm::writeToOutput API.

13 months ago[FuncSpec] Avoid crashing when SwitchInst doesn't see ConstantInt
Vincent Lee [Thu, 29 Jun 2023 22:05:56 +0000 (15:05 -0700)]
[FuncSpec] Avoid crashing when SwitchInst doesn't see ConstantInt

D150464 updated the cost model for function specialization. Unfortunately, this
also crashes when trying to build stage2 LLD with thinLTO and assertions. It looks
like the issue is caused by a mishandling of the Constant in a SwitchInst since the
Constant cannot always be assumed to safely casted to a ConstantInt. In the case
of the crash, Constant was a ConstantExpr which triggered the assertion.

Reviewed By: ChuanqiXu

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

13 months ago[AArch64] Remove duplicate code (NFC)
Evandro Menezes [Sat, 1 Jul 2023 02:37:12 +0000 (21:37 -0500)]
[AArch64] Remove duplicate code (NFC)

13 months ago[MC] Add three-state parseDirective as a replacement for ParseDirective
Sergei Barannikov [Thu, 29 Jun 2023 14:22:41 +0000 (17:22 +0300)]
[MC] Add three-state parseDirective as a replacement for ParseDirective

Conventionally, parsing methods return false on success and true on
error. However, directive parsing methods need a third state: the
directive is not target specific. AsmParser::parseStatement detected
this case by using a fragile heuristic: if the target parser did not
consume any tokens, the directive is assumed to be not target-specific.

Some targets fail to follow the convention: they return success after
emitting an error or do not consume the entire line and return failure
on successful parsing. This was partially worked around by checking for
pending errors in parseStatement.

This patch tries to improve the situation by introducing parseDirective
method that returns ParseStatus -- three-state class. The new method
should eventually replace the old one returning bool.

ParseStatus is intentionally implicitly constructible from bool to allow
uses like `return Error(Loc, "message")`. It also has a potential to
replace OperandMatchResulTy as it is more convenient to use due to the
implicit construction from bool and more type safe.

Reviewed By: MaskRay

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

13 months agoChange the dyld notification function that lldb puts a breakpoint in
Jason Molenda [Sat, 1 Jul 2023 01:26:06 +0000 (18:26 -0700)]
Change the dyld notification function that lldb puts a breakpoint in

On Darwin systems, the dynamic linker dyld has an empty function
it calls when binaries are added/removed from the process.  lldb puts
a breakpoint on this dyld function to catch the notifications.  The
function arguments are used by lldb to tell what is happening.

The linker has a natural representation when the addresses of
binaries being added/removed are in the pointer size of the process.
There is then a second function where the addresses of the binaries
are in a uint64_t array, which the debugger has been using before -
dyld allocates memory for the array, copies the values in to it,
and calls it for lldb's benefit.

This changes to using the native notifier function, with pointer-sized
addresses.

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

13 months ago[lld/COFF] Add /dwodir to enable DWARF fission with LTO
Haohai Wen [Sat, 1 Jul 2023 00:58:56 +0000 (08:58 +0800)]
[lld/COFF] Add /dwodir to enable DWARF fission with LTO

This patch added /dwodir to lld/COFF which is equivalent to lld/ELF
option -plugin-opt=dwo_dir=. This option tells LTO backend to create
dwo directory and files and all dwo files will be in it. Otherwise all
dwarf sections will be embeded into image even if -gsplit-dwarf is
specified when using LTO.

Reviewed By: MaskRay

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

13 months ago[lldb] Add log indicating which kind of data formatter
Dave Lee [Wed, 28 Jun 2023 22:48:15 +0000 (15:48 -0700)]
[lldb] Add log indicating which kind of data formatter

The `formatter` logs include a function name, but these functions are mostly templates
and the template type parameter is not printed, which is useful context.

This change adds a new log which is printed upon entry of `FormatManager::Get`, which
shows the formatter context as either `format`, `summary`, or `synthetic`.

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

13 months ago[clang] detect integer overflow through temporary values
Lucile Nihlen [Fri, 30 Jun 2023 19:48:40 +0000 (19:48 +0000)]
[clang] detect integer overflow through temporary values

Fixes #63629.

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

13 months ago[clang] Fix leak in LoadFromCommandLineWorkingDirectory unit test
Hamish Knight [Fri, 30 Jun 2023 23:01:20 +0000 (16:01 -0700)]
[clang] Fix leak in LoadFromCommandLineWorkingDirectory unit test

Change `ASTUnit::LoadFromCommandLine` to return a `std::unique_ptr` instead of a +1 pointer, fixing a leak in the unit test `LoadFromCommandLineWorkingDirectory`.

Reviewed By: bnbarham, benlangmuir

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

13 months ago[mlir][NVGPU]: Fix op description of nvgpu.device_async_wait.
Yuan Yao [Wed, 28 Jun 2023 20:50:25 +0000 (13:50 -0700)]
[mlir][NVGPU]: Fix op description of nvgpu.device_async_wait.

According to the NVIDIA documentation on `cp.async.wait_group`
(https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group-cp-async-wait-all),
the `numGroups` attribute in `nvgpu.device_async_wait` should give an upper
bound of pending async group count (instead of a lower bound) when the
executing thread can be unblocked.

Reviewed By: christopherbate

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

13 months ago[mlir][NFC] Sort dialects
Ivan Butygin [Fri, 30 Jun 2023 21:51:01 +0000 (23:51 +0200)]
[mlir][NFC] Sort dialects

Sort dialects cmake and registry.

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

13 months agoExpose DataflowAnalysisContext.querySolver().
Samira Bazuzi [Fri, 30 Jun 2023 21:40:03 +0000 (23:40 +0200)]
Expose DataflowAnalysisContext.querySolver().

This allows for use of the same solver used by the DAC for additional solving post-analysis and thus shared use of MaxIterations in WatchedLiteralsSolver.

Reviewed By: ymandel, gribozavr2, sammccall

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

13 months ago[mlir][sparse][gpu] reuse CUDA environment handle throughout instance lifetime
Kun Wu [Fri, 16 Jun 2023 21:38:40 +0000 (21:38 +0000)]
[mlir][sparse][gpu] reuse CUDA environment handle throughout instance lifetime

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

13 months ago[mlir][sparse] add affine parsing to new surface syntax for STEA
Aart Bik [Fri, 30 Jun 2023 20:05:01 +0000 (13:05 -0700)]
[mlir][sparse] add affine parsing to new surface syntax for STEA

(1) uses the previously introduce API to reuse AffineExpr parser without codedup
(2) solves the look-ahead problem when parsing level spec

Reviewed By: Peiming

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

13 months ago[libc] Fix more inline definitions
Roland McGrath [Fri, 30 Jun 2023 20:20:22 +0000 (13:20 -0700)]
[libc] Fix more inline definitions

Fix a bunch more instances of incorrect use of the `static`
keyword and missing use of LIBC_INLINE and LIBC_INLINE_VAR
macros. Note that even forward declarations and generic template
declarations must follow the prescribed patterns for libc code so
that they match every definition, all template specializations.

Reviewed By: Caslyn

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

13 months ago[lldb] Delete RewriteObjCClassReferences (NFC)
Dave Lee [Mon, 26 Jun 2023 17:34:41 +0000 (10:34 -0700)]
[lldb] Delete RewriteObjCClassReferences (NFC)

The `RewriteObjCClassReferences` pass was applicable only to the code generated for the
fragile ObjC ABI (v1). That ABI is no longer active (last used for i386 macOS), which
means this pass has no effect.

Sources: `OBJC_CLASS_REFERENCES_` is emitted only by `CGObjCMac`, and not by
`CGObjCNonFragileABIMac`.

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

13 months ago[clang] Replace uses of CreateElementBitCast (NFC)
Youngsuk Kim [Fri, 30 Jun 2023 21:33:28 +0000 (17:33 -0400)]
[clang] Replace uses of CreateElementBitCast (NFC)

Partial progress towards replacing uses of CreateElementBitCast, as it
no longer does what its name suggests.

Reviewed By: barannikov88

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

13 months ago[mlir][sparse] make UnpackOp return the actual filled length of unpacked memory
Peiming Liu [Fri, 30 Jun 2023 18:07:21 +0000 (18:07 +0000)]
[mlir][sparse] make UnpackOp return the actual filled length of unpacked memory

This might simplify frontend implementation by avoiding recomputation for the same value.

Reviewed By: aartbik

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

13 months ago[gn build] Port c4e98722ca79
LLVM GN Syncbot [Fri, 30 Jun 2023 21:17:57 +0000 (21:17 +0000)]
[gn build] Port c4e98722ca79

13 months ago[libc] Add missing cast in x86 big_endian_cmp_mask
Roland McGrath [Fri, 30 Jun 2023 20:27:52 +0000 (13:27 -0700)]
[libc] Add missing cast in x86 big_endian_cmp_mask

Implicit narrowing conversions from int to uint16_t
get a compiler warning with the warning settings used
in the Fuchsia build.

Reviewed By: michaelrj

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

13 months ago[LV] Pass bool to requiresScalarEpilogue (NFC).
Florian Hahn [Fri, 30 Jun 2023 21:08:27 +0000 (22:08 +0100)]
[LV] Pass bool to requiresScalarEpilogue (NFC).

requiresScalarEpilogue only checks if the selected VF is vectorizing
(and not scalar). Update it to just take a boolean, to make it clearer
what information is used and to allow callers without a VF (used in a
follow-up patch).

13 months agoAdd Int4 support for tosa::ConstOp
Jerry Ge [Fri, 30 Jun 2023 20:49:58 +0000 (13:49 -0700)]
Add Int4 support for tosa::ConstOp

- Also added Tosa_Weight and Tosa_WeightTensorXD specifically for weights

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
Reviewed By: eric-k256

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

13 months ago[scudo] Improve Secondary Cache Dump
fernandosalas [Fri, 30 Jun 2023 20:55:40 +0000 (20:55 +0000)]
[scudo] Improve Secondary Cache Dump

Exclude cached blocks with invalid start address. Mainly concerned with
cached blocks that are still available/unused.

Reviewed By: Chia-hungDuan, cferris

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

13 months ago[scudo] Restore Freelist when we fail on PageMap creation
Chia-hung Duan [Thu, 29 Jun 2023 04:23:21 +0000 (04:23 +0000)]
[scudo] Restore Freelist when we fail on PageMap creation

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

13 months ago[msan] Add lit test for dladdr
Thurston Dang [Fri, 30 Jun 2023 20:18:53 +0000 (20:18 +0000)]
[msan] Add lit test for dladdr

This adds a simple lit test for dladdr. (There is currently a dladdr testcase in
compiler-rt/lib/msan/tests/msan_test.cpp, but not a stand-alone lit test.)

This is an incremental step towards adding a test case (and, eventually, an interceptor)
for the more complicated dladdr1 function.

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

13 months agocorrect misspelled _LIBCPP___TYPE_TRAITS_IS_EQUAILITY_COMPARABLE_H to _LIBCPP___TYPE_...
Amirreza Ashouri [Fri, 30 Jun 2023 20:50:27 +0000 (13:50 -0700)]
correct misspelled _LIBCPP___TYPE_TRAITS_IS_EQUAILITY_COMPARABLE_H to _LIBCPP___TYPE_TRAITS_IS_EQUALITY_COMPARABLE_H

I just corrected a mistakenly misspelled macro

Reviewed By: philnik, #libc

Spies: libcxx-commits, #llvm, philnik

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

13 months ago[libc++] Fix std::copy and std::move for ranges with potentially overlapping tail...
Nikolas Klauser [Fri, 30 Jun 2023 20:47:39 +0000 (13:47 -0700)]
[libc++] Fix std::copy and std::move for ranges with potentially overlapping tail padding

This fixes thr bug reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108846.

Reviewed By: ldionne, #libc

Spies: mstorsjo, libcxx-commits

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

13 months ago[RISCV] Fix vfwcvt/vfncvt pseudos w/ rounding mode lowering
Luke Lau [Fri, 30 Jun 2023 16:44:47 +0000 (17:44 +0100)]
[RISCV] Fix vfwcvt/vfncvt pseudos w/ rounding mode lowering

Some signed opcodes were being lowered to their unsigned counterparts and
vice-versa.

Reviewed By: craig.topper

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

13 months ago[test] Add a couple of missing REQUIRES
Justin Bogner [Fri, 30 Jun 2023 20:41:23 +0000 (14:41 -0600)]
[test] Add a couple of missing REQUIRES

These tests only work if the targets in the input are available.

13 months ago[flang][openmp] Parallel reduction FIR lowering
Ethan Luis McDonough [Fri, 30 Jun 2023 20:32:21 +0000 (15:32 -0500)]
[flang][openmp] Parallel reduction FIR lowering

This patch extends the logic for lowering loop construct reductions to parallel block reductions.

Reviewed By: kiranchandramohan

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

13 months ago[flang][NFC] Fix typos
Valentin Clement [Fri, 30 Jun 2023 20:15:25 +0000 (13:15 -0700)]
[flang][NFC] Fix typos

13 months ago[UBSan] Fix shared library linking in test for Darwin.
usama hameed [Fri, 30 Jun 2023 19:58:55 +0000 (12:58 -0700)]
[UBSan] Fix shared library linking in test for Darwin.

Without rpath information, the test fails on some Darwin platforms since the binary fails to find the shared library.

rdar://110010041

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

13 months ago[OpenMP][NVPTX] Handle additional invalid PTX characters
Jeffrey Sandoval [Fri, 30 Jun 2023 19:57:05 +0000 (14:57 -0500)]
[OpenMP][NVPTX] Handle additional invalid PTX characters

For OpenMP offload, Clang emits global symbols containing the string
'<captured>', which contains characters that are invalid in PTX.
Extend the existing pass that replaces '.'  and '@' characters with
'_$_' to also replace '<' and '>' characters.

Reviewed By: cchen

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

13 months ago[openacc][NFC] Bump parser support number to OpenACC 3.3
Valentin Clement [Fri, 30 Jun 2023 19:56:00 +0000 (12:56 -0700)]
[openacc][NFC] Bump parser support number to OpenACC 3.3

Parser support reached OpenACC 3.3 specification.
Bump the numbers to reflect the latest specs.

Reviewed By: razvanlupusoru, awarzynski

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

13 months ago[llvm-exegesis] Make sure auxiliary memory is unlinked after usage
Aiden Grossman [Fri, 30 Jun 2023 19:42:37 +0000 (12:42 -0700)]
[llvm-exegesis] Make sure auxiliary memory is unlinked after usage

Currently the shm_unlink is never called on the auxiliary memory shared
memory, so it stays around after running llvm-exegesis (including
running the llvm-exegesis tests). This patch adds the auxiliary memory
shared memory name to the SharedMemoryNames list so that it gets
unlinked when the destructor of SubprocessMemory is called.

13 months agoRevert "[SimplifyCFG] Allow dropping block that only contains ephemeral values"
Nikita Popov [Fri, 30 Jun 2023 19:05:59 +0000 (21:05 +0200)]
Revert "[SimplifyCFG] Allow dropping block that only contains ephemeral values"

This reverts commit 20f0c68fd83a0147a8ec1722bd2e848180610288.

https://reviews.llvm.org/D153966#4464594 reports an optimization
regression in Rust.

Additionally this change has caused an unexpected 0.3% compile-time
regression.

13 months ago[mlir][Vector] Update the lowering of `vector.transfer_write` to SCF
Andrzej Warzynski [Fri, 30 Jun 2023 15:04:28 +0000 (16:04 +0100)]
[mlir][Vector] Update the lowering of `vector.transfer_write` to SCF

This change updates the lowering of `vector.transfer_write` to SCF when
scalable vectors are used. Specifically, when lowering
`vector.transfer_write` to a loop of `vector.extractelement` ops, make
sure that the upper bound of the generated loop is scaled by
`vector.vscale`:
```
    %10 = vector.vscale
    %11 = arith.muli %10, %c16 : index
    scf.for %arg2 = %c0 to %11 step %c1
```

For reference, this is the current version (i.e. before this change):
```
    scf.for %arg2 = %c0 to %c16 step %c1
```
Note that this only valid for fixed-width vectors.

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

13 months ago[mlir][sparse][gpu] Add explaining string to three static_assert stmts
Kun Wu [Fri, 30 Jun 2023 18:32:13 +0000 (13:32 -0500)]
[mlir][sparse][gpu] Add explaining string to three static_assert stmts

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

13 months ago[OpenMP] Added memory scope to atomic::inc API and used the device scope in reduction.
Dhruva Chakrabarti [Fri, 30 Jun 2023 18:02:12 +0000 (14:02 -0400)]
[OpenMP] Added memory scope to atomic::inc API and used the device scope in reduction.

With https://reviews.llvm.org/D137524, memory scope and ordering
attributes are being used to generate the required instructions for
atomic inc/dec on AMDGPU. This patch adds the memory scope attribute to
the atomic::inc API and uses the device scope in reduction. Without
the device scope in atomic_inc, the default system scope leads to
unnecessary L2 write-backs/invalidates.

Reviewed By: arsenm

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

13 months agoOpenMP: Don't use target regions in library function test
Matt Arsenault [Tue, 13 Jun 2023 21:22:29 +0000 (17:22 -0400)]
OpenMP: Don't use target regions in library function test

Use pragma omp declare target to reduce the IR noise around the call
we're actually trying to test.

13 months agoAMDGPU: Fix opaque pointer conversion error in test
Matt Arsenault [Mon, 26 Jun 2023 22:36:06 +0000 (18:36 -0400)]
AMDGPU: Fix opaque pointer conversion error in test

The * was in the wrong place so this was missed by the script.

13 months agoAMDGPU: Fold away mbcnt.hi in wave32 mode
Matt Arsenault [Thu, 29 Jun 2023 14:07:28 +0000 (10:07 -0400)]
AMDGPU: Fold away mbcnt.hi in wave32 mode

This will allow libraries to drop some of the special casing based on
wave size.

13 months agoAMDGPU: Add baseline tests for mbcnt.hi combine
Matt Arsenault [Thu, 29 Jun 2023 14:05:20 +0000 (10:05 -0400)]
AMDGPU: Add baseline tests for mbcnt.hi combine

13 months ago[SLP] Fix crash on attempt to access on invalid iterator state.
Valery N Dmitriev [Fri, 30 Jun 2023 01:15:57 +0000 (18:15 -0700)]
[SLP] Fix crash on attempt to access on invalid iterator state.

The patch fixes corner case when no of scalar instructions
required scheduling for vectorized node.

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

13 months ago[WebAssembly] Fix incorrect assertion in SIMD reduction codegen
Thomas Lively [Fri, 30 Jun 2023 18:30:17 +0000 (11:30 -0700)]
[WebAssembly] Fix incorrect assertion in SIMD reduction codegen

The codegen routine introduced in 18077e9fd688 did not account for vectors with
more than 16 lanes. Remove the incorrect assertion and bail out of the
optimization when encountering this case. Add test cases that previously
triggered the assertion. Unfortunately, these test cases now have terrible
codegen, but that is at least better than crashing.

Fixes #63500.

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

13 months ago[flang][hlfir] probe ultimate intrinsic module procedure name
Jean Perier [Fri, 30 Jun 2023 18:26:59 +0000 (20:26 +0200)]
[flang][hlfir] probe ultimate intrinsic module procedure name

HLFIR lowering was currently hitting errors like "not yet implemented:
intrinsic: z0$iso_c_binding$c_associated_c_ptr". These error were caused
by HLFIR lowering using the name with the full context instead of
the ultimate one.
I do not want to change proc.GetName() because I think it may be best
if it retains the full context for its usages in semantics, so I fixed
the helper to get the name in lowering to HLFIR.

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

13 months ago[flang] add nested DEC STRUCTURE in DerivedTypeDetails component names
Jean Perier [Fri, 30 Jun 2023 18:24:46 +0000 (20:24 +0200)]
[flang] add nested DEC STRUCTURE in DerivedTypeDetails component names

Currently, when a (legacy) DEC structure contained other DEC structure
declarations, the related component names were not added to the
containing DerivedTypeDetails component_names. This lead to bugs in
later phase when visiting the components (like in when lowering the
type to FIR/MLIR).

When an EntityDecl is visited and the scope is a DEC structure, add
the entity to the component names of this DEC structure.

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

13 months ago[flang][openacc] Lower default clause to acc.data operation attributes
Valentin Clement [Fri, 30 Jun 2023 18:21:32 +0000 (11:21 -0700)]
[flang][openacc] Lower default clause to acc.data operation attributes

Lowering of the default clause was missing on the acc.data operation. This
patch lowers the default clause to its corresponding attribute.

Reviewed By: razvanlupusoru

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

13 months ago[flang][openacc] Lower async/wait clauses for acc.data
Valentin Clement [Fri, 30 Jun 2023 18:12:14 +0000 (11:12 -0700)]
[flang][openacc] Lower async/wait clauses for acc.data

Lower async and wait clauses to the correponding
attributes and operands on the acc.data operation.

Depends on D154131

Reviewed By: razvanlupusoru

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

13 months ago[X86] Add common SSE2/SSSE3 check prefix to vector truncation tests
Simon Pilgrim [Fri, 30 Jun 2023 17:48:50 +0000 (18:48 +0100)]
[X86] Add common SSE2/SSSE3 check prefix to vector truncation tests

Reduced duplicate checks where we can

13 months ago[dfsan] Add missing functions to done_abilist.txt
Jin Xin Ng [Sat, 24 Jun 2023 01:42:21 +0000 (01:42 +0000)]
[dfsan] Add missing functions to done_abilist.txt

__sanitizer_get_allocated_begin and __sanitizer_get_allocated_size_fast
were introduced recently in D147005 and D151360, but not added here,
leading to linker errors.

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

13 months ago[flang][openacc] Lower the default clause on compute constructs
Valentin Clement [Fri, 30 Jun 2023 17:24:21 +0000 (10:24 -0700)]
[flang][openacc] Lower the default clause on compute constructs

Lower default clause to the correct attribute for compute
operation.

Reviewed By: razvanlupusoru

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

13 months ago[mlir][openacc] Add wait attribute and variadic operand
Valentin Clement [Fri, 30 Jun 2023 17:04:17 +0000 (10:04 -0700)]
[mlir][openacc] Add wait attribute and variadic operand

OpenACC 3.2 allowed the wait clause to the data construct. This patch
adds a unit attribute and a variadic operand to the data operation to model
the wait clause in a similar way it was added to other data operation.
The attribute models the presence of the clause without any argument. When
arguments are provided they are placed in the wait operand.

Depends on D154111

Reviewed By: razvanlupusoru

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

13 months ago[mlir][openacc] Add async attribute and optional operand
Valentin Clement [Fri, 30 Jun 2023 17:03:24 +0000 (10:03 -0700)]
[mlir][openacc] Add async attribute and optional operand

OpenACC 3.2 allowed the async clause to the data construct. This patch
adds a unit attribute and an optional operand to the data operation to model
the data clause in a similar way it was added to other data operation.
The attribute models the presence of the clause without any argument. When
an argument is provided it is placed in the async operand.

Reviewed By: razvanlupusoru

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

13 months ago[gn build] Port 62e4c22c95a9
LLVM GN Syncbot [Fri, 30 Jun 2023 16:58:05 +0000 (16:58 +0000)]
[gn build] Port 62e4c22c95a9

13 months ago[clang] Fix ASTUnit working directory handling
Hamish Knight [Fri, 30 Jun 2023 16:46:52 +0000 (09:46 -0700)]
[clang] Fix ASTUnit working directory handling

Fix a couple of issues with the handling of the current working directory in ASTUnit:

- Use `createPhysicalFileSystem` instead of `getRealFileSystem` to avoid affecting the process' current working directory, and set it at the top of `ASTUnit::LoadFromCommandLine` such that the driver used for argument parsing and the ASTUnit share the same VFS. This ensures that '-working-directory' correctly sets the VFS working directory in addition to the FileManager working directory.
- Ensure we preserve the FileSystemOptions set on the FileManager when re-creating it (as `ASTUnit::Reparse` will clear the currently set FileManager).

rdar://110697657

Reviewed By: bnbarham, benlangmuir

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

13 months ago[HIP] Fix -mllvm option for device lld linker
Yaxun (Sam) Liu [Thu, 29 Jun 2023 20:02:13 +0000 (16:02 -0400)]
[HIP] Fix -mllvm option for device lld linker

currently clang passes -mllvm options to the device lld linker plugin
when compiling HIP. This is against default clang behavior
which is only passing -mllvm options to linker plugin specified through -Wl
options. This patch lets clang only pass -Xoffload-linker -mllvm= options
to device lld linker plugin.

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

Reviewed by: Joseph Huber, Matt Arsenault

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

13 months agoclang: Add start of header test for __clang_hip_libdevice_declares
Matt Arsenault [Tue, 13 Jun 2023 14:05:44 +0000 (10:05 -0400)]
clang: Add start of header test for __clang_hip_libdevice_declares

It was shockingly difficult to get identical checks out of the 3
languages. The visibility, dso_local and fp-contract settings seem to
differ unless I force every test function to
static. update_cc_test_checks also isn't smart enough when the
attribute groups slightly differ.

13 months agoVerifier: Verify absolute_symbol metadata
Matt Arsenault [Wed, 28 Jun 2023 12:57:19 +0000 (08:57 -0400)]
Verifier: Verify absolute_symbol metadata

This is the same as !range except for one edge case.

13 months agoVerifier: Fix assertion on range metadata with equal bounds
Matt Arsenault [Wed, 28 Jun 2023 13:14:06 +0000 (09:14 -0400)]
Verifier: Fix assertion on range metadata with equal bounds

This only worked if the same values were the min or max. We also seem
to be missing proper assembler tests for this.

13 months agoAnalysis: Fix assertion when load alignment exceeds address space size
Matt Arsenault [Mon, 19 Jun 2023 22:03:33 +0000 (18:03 -0400)]
Analysis: Fix assertion when load alignment exceeds address space size

Apparently the maximum alignment no longer fits in 32-bits now, which
overflows a 32-bit offset and would fail on the isPowerOf2 assert.

13 months ago[libc] Make the RPC server target always available
Joseph Huber [Thu, 29 Jun 2023 16:23:47 +0000 (11:23 -0500)]
[libc] Make the RPC server target always available

This patch makes sure that we always build the RPC server. The proposed
used for this is to begin integrating this server implementation into
`libomptarget`. That requires that we build this server ahead of time
when using a `LLVM_ENABLE_PROJECTS` build. Make a few tweaks to ensure
that the GCC compiler which may be used for this build doesn't complain.

Reviewed By: JonChesterfield

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

13 months ago[libc] Add other RPC callback methods to the RPC server
Joseph Huber [Fri, 30 Jun 2023 14:48:13 +0000 (09:48 -0500)]
[libc] Add other RPC callback methods to the RPC server

This patch adds the other two methods to the server so the external
users can use the interface through the obfuscated interface.

Reviewed By: JonChesterfield

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

13 months agoReland "[BOLT][Instrumentation] Don't share counters when using append-pid"
Amir Ayupov [Fri, 30 Jun 2023 16:14:58 +0000 (09:14 -0700)]
Reland "[BOLT][Instrumentation] Don't share counters when using append-pid"

This reverts commit c15e9b6814e53bccb0194268a826c1213a84b395.

The issue appears unrelated as the crash happened in the BOLTed binary, not
instrumented binary.

13 months agoMachineFunction: -fsanitize={function,kcfi}: ensure 4-byte alignment
Fangrui Song [Fri, 30 Jun 2023 16:13:19 +0000 (09:13 -0700)]
MachineFunction: -fsanitize={function,kcfi}: ensure 4-byte alignment

Fix https://github.com/llvm/llvm-project/issues/63579
```
% cat a.c
void foo() {}
% clang --target=arm-none-eabi -mthumb -mno-unaligned-access -fsanitize=kcfi a.c -S -o - | grep p2align
        .p2align        1
% clang --target=armv6m-none-eabi -fsanitize=function a.c -S -o - | grep p2align
        .p2align        1
```

Ensure that -fsanitize={function,kcfi} instrumented functions are aligned by at
least 4, so that loading the type hash before the function label will not cause
a misaligned access. This is especially important for -mno-unaligned-access
configurations that don't set `setMinFunctionAlignment` to 4 or greater.

With this patch, the generated assembly for the examples above will contain `.p2align 2`
before the type hash.

If `__attribute__((aligned(N)))` or `-falign-functions=N` is specified, the
larger alignment will be used.

Reviewed By: simon_tatham, samitolvanen

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

13 months ago[clang] Update cxx_status for 632dd6a4ca0036009f
Yuanfang Chen [Fri, 30 Jun 2023 16:09:31 +0000 (09:09 -0700)]
[clang] Update cxx_status for 632dd6a4ca0036009f

missed this after rebase

13 months ago[NVPTX] added a hidden option to control NVPTXLowerUnreachable pass.
Artem Belevich [Thu, 29 Jun 2023 16:31:31 +0000 (09:31 -0700)]
[NVPTX] added a hidden option to control NVPTXLowerUnreachable pass.

We've ran into an issue where the pass breaks a handful of our internal tests
and need a way to temporarily disable the pass while we're investigating.

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

13 months ago[AMDGPU][Codegen] Clean up legalizeOpWithMove().
Ivan Kosarev [Fri, 30 Jun 2023 15:43:02 +0000 (16:43 +0100)]
[AMDGPU][Codegen] Clean up legalizeOpWithMove().

The removed logic was added in
<https://reviews.llvm.org/rG0c93c9ecee0624f8469f5a971a09fbc9e9cc1061>,
but now doesn't seem to be needed.

Reviewed By: arsenm

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

13 months ago[RISCV] Custom lower FP_TO_FP16 and FP16_TO_FP to correct ABI of of libcall
Alex Bradbury [Fri, 30 Jun 2023 15:39:15 +0000 (16:39 +0100)]
[RISCV] Custom lower FP_TO_FP16 and FP16_TO_FP to correct ABI of of libcall

As introduced in D99148, RISC-V uses the softPromoteHalf legalisation
for fp16 values without zfh, with logic ensuring that f16 values are
passed in lower bits of FPRs (see D98670) when F or D support is
present. This legalisation produces ISD::FP_TO_FP16 and ISD::FP16_TO_FP
nodes which (as described in ISDOpcodes.h) provide a "semi-softened
interface for dealing with f16 (as an i16)". i.e. the return type of the
FP_TO_FP16 is an integer rather than a float (and the arg of FP16_TO_FP
is an integer). The remainder of the description focuses primarily on
FP_TO_FP16 for ease of explanation.

FP_TO_FP16 is lowered to a libcall to `__truncsfhf2 (float)` or
`__truncdfhf2 (double)`. As of D92241, `_Float16` is used as the return
type of these libcalls if the host compiler accepts `_Float16` in a test
input (i.e. dst_t is set to `_Float16`). `_Float16` is enabled for the
RISC-V target as of D105001 and so the return value should be passed in
an FPR on hard float ABIs.

This patch fixes the ABI issue in what appears to be a minimally
invasive way - leaving the softPromoteHalf logic undisturbed, and
lowering FP_TO_FP16 to an f32-returning libcall, converting its result
to an XLen integer value.

As can be seen in the test changes, the custom lowering for FP16_TO_FP
means the libcall is no longer tail-callable.

Although this patch fixes the issue, there are two open items:
* Redundant fmv.x.w and fmv.w.x pairs are now somtimes produced during
  lowering (not a correctness issue).
* Now coverage for STRICT variants of FP16 conversion opcodes.

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

13 months ago[RISCV][test] Add additional RUN lines to half-convert.ll in preparation for D151824
Alex Bradbury [Fri, 30 Jun 2023 15:30:15 +0000 (16:30 +0100)]
[RISCV][test] Add additional RUN lines to half-convert.ll in preparation for D151824

There wasn't previous coverage for rv32id-ilp32, rv64id-lp64,
rv32id-ilp32d, or rv64id-lp64d. This is needed as D151284 fixes a bug
related to the ABI used for libcalls for fp<->fp16 conversion when hard
FP support is present.

13 months ago[AMDGPU][AsmParser][NFC] Simplify parsing of sopp_brtarget operands.
Ivan Kosarev [Fri, 30 Jun 2023 15:28:40 +0000 (16:28 +0100)]
[AMDGPU][AsmParser][NFC] Simplify parsing of sopp_brtarget operands.

Also refine the definitions while there.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: mbrkusanin

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

13 months ago[Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h
Paul Robinson [Wed, 28 Jun 2023 18:25:03 +0000 (11:25 -0700)]
[Headers][doc] Add load/store/cmp/cvt intrinsic descriptions to avx2intrin.h

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

13 months ago[ConstraintElim] Add phi tests with multiple GEP indices.
Florian Hahn [Fri, 30 Jun 2023 15:28:37 +0000 (16:28 +0100)]
[ConstraintElim] Add phi tests with multiple GEP indices.

Extra tests for D152730.

13 months ago[mlir][NFC] Fully qualify TableGen generated code handling properties
Markus Böck [Fri, 30 Jun 2023 15:28:15 +0000 (17:28 +0200)]
[mlir][NFC] Fully qualify TableGen generated code handling properties

This makes it possible to compile the TableGen generated files without having to use `using namespace mlir;` or being in the `mlir` namespace.

13 months ago[analyzer][NFC] Fix dangling StringRef in barely used code
Donát Nagy [Tue, 27 Jun 2023 15:49:44 +0000 (17:49 +0200)]
[analyzer][NFC] Fix dangling StringRef in barely used code

CheckerContext::getNoteTag has a shorthand version that takes a
plain 'StringRef Note' instead of a lambda that calculates the note.

The old implementation of this method was incorrect because it created a
lambda that captured the StringRef, which was dereferenced much later,
when the NoteTags were visited.

In the current codebase this does not cause errors because this method
is called only once, and there the `Note` argument is a string literal
that remains valid. However, I tried to use this method in a checker
that I was prototyping, and there it printed random memory junk (instead
of the message that I composed in a local variable).

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

13 months ago[scudo] SizeClassAllocator64: dispatch all the classes in init()
Fabio D'Urso [Fri, 30 Jun 2023 14:35:09 +0000 (16:35 +0200)]
[scudo] SizeClassAllocator64: dispatch all the classes in init()

This will make it easier to verify in a future patch that the ReservedMemory object has been fully dispatched.

Reviewed By: Chia-hungDuan

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

13 months ago[Metarenamer] Introduce option to only change inst names
Anna Thomas [Fri, 30 Jun 2023 14:21:16 +0000 (10:21 -0400)]
[Metarenamer] Introduce option to only change inst names

This is useful when needing to modify IR and test some optimizations on
them, while keeping BB names and function names intact. If
the IR uses ordered number naming (%1, %2, %3 etc), then we cannot just
remove or reorder specific instructions since the verifier expects the
numbers to be in order.

13 months agoReverting commit 0d8d718171192301f2beb10bd08ce62e70281a5e as it broke libomptarget...
Akash Banerjee [Fri, 30 Jun 2023 15:03:57 +0000 (16:03 +0100)]
Reverting commit 0d8d718171192301f2beb10bd08ce62e70281a5e as it broke libomptarget tests

13 months ago[CSKY] Optimize IR pattern icmp-select with INCT32/INCF32
Ben Shi [Wed, 21 Jun 2023 10:05:24 +0000 (18:05 +0800)]
[CSKY] Optimize IR pattern icmp-select with INCT32/INCF32

Reviewed By: zixuan-wu

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

13 months ago[CSKY][test][NFC] Add tests of IR pattern icmp-select
Ben Shi [Tue, 20 Jun 2023 10:58:00 +0000 (18:58 +0800)]
[CSKY][test][NFC] Add tests of IR pattern icmp-select

These tests will be optimized with INCT32/INCF32/DECT32/DECF32
in the future.

Reviewed By: zixuan-wu

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

13 months ago[GVN] Add tests for PR63059 (NFC)
ManuelJBrito [Thu, 29 Jun 2023 17:23:55 +0000 (18:23 +0100)]
[GVN] Add tests for PR63059 (NFC)

Besides the example from the issue, this adds some other related wrong transformations.

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

13 months ago[OpenMP][OpenMPIRBuilder] Migrate kernel launch code and host fallback code generatio...
Jan Sjodin [Thu, 29 Jun 2023 14:41:11 +0000 (10:41 -0400)]
[OpenMP][OpenMPIRBuilder] Migrate kernel launch code and host fallback code generation from Clang to the OpenMPIRBuilder

This patch refactors the code generation that emits the offloading kernel
launch and moves the core portion to the OpenMPIRBuilder so that it can be used
from flang in the future.

Reviewed By: jdoerfert

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

13 months ago[mlir][LLVM] Add section attribute to LLVMFuncOp
Christian Ulmann [Fri, 30 Jun 2023 14:19:31 +0000 (14:19 +0000)]
[mlir][LLVM] Add section attribute to LLVMFuncOp

This commit adds an optional section attribute to the `LLVMFuncOp` and
adds import and export functionality for it.

Reviewed By: gysit

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

13 months ago[dataflow] Fix complie on gcc7 part 2
Donát Nagy [Fri, 30 Jun 2023 13:43:30 +0000 (15:43 +0200)]
[dataflow] Fix complie on gcc7 part 2

Change c2bb68078eb9 triggered a bug in gcc7 by disabling a copy
constructor. Commit 2f7d30dee826 fixed one occurrence of this issue, but
after that the compilation still failed with another very similar error.

This commit eliminates this second compilation error, and ensures that
`ninja check-clang-analysis` can be successfully executed with gcc 7.5.

13 months agollvm-reduce: Fix not preserving uselistorder with bitcode
Matt Arsenault [Sun, 25 Jun 2023 12:55:52 +0000 (08:55 -0400)]
llvm-reduce: Fix not preserving uselistorder with bitcode

Fix accidentally passing pointer to bool argument This was supposed to
be writing bitcode with preserved uselistorder, but instead was only
enabling it with LTO module summaries.

13 months ago[ConstraintElim] Add extra tests and split up test file.
Florian Hahn [Fri, 30 Jun 2023 14:16:23 +0000 (15:16 +0100)]
[ConstraintElim] Add extra tests and split up test file.

Extra tests for D152730, including more tests where the step GEP doesn't
use the phi and inbounds are missing.

Also split up test file to make it easier to verify for Alive2.

13 months ago[OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder
Akash Banerjee [Tue, 27 Jun 2023 12:50:17 +0000 (13:50 +0100)]
[OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

This patch changes the emitTargetDataCalls function in clang to make use of the OpenMPIRBuilder::createTargetData function for Target Data directive code gen.

Depends on D146557

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