467914 Commits

Author SHA1 Message Date
Louis Dionne
8ac71b026e [libc++] Remove internal "build-with-external-thread-library" configuration
Our threading support layer is currently a huge mess. There are too many
configurations with too many confusing names, and none of them are tested
in the usual CI. Here's a list of names related to these configurations:

  LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
  _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL

  LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY
  _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL

  LIBCXX_HAS_EXTERNAL_THREAD_API
  _LIBCPP_HAS_THREAD_API_EXTERNAL

This patch cleans this up by removing the ability to build libc++ with
an "external" threading library for testing purposes, removing 4 out of
6 "names" above. That setting was meant to be used by libc++ developers,
but we don't use it in-tree and it's not part of our CI.

I know the ability to use an external threading API is used by some folks
out-of-tree, and this patch doesn't change that. This only changes the
way they will have to test their external threading support. After this
patch, the intent would be for them to set `-DLIBCXX_HAS_EXTERNAL_THREAD_API=ON`
when building the library, and to provide their usual `<__external_threading>`
header when they are testing the library. This can be done easily now
that we support custom lit configuration files in test suites.

The motivation for this patch is that our threading support layer is
basically unmaintainable -- anything beyond adding a new "backend" in
the slot designed for it requires incredible attention. The complexity
added by this setting just doesn't pull its weigh considering the
available alternatives.

Concretely, this will also allow future patches to clean up
`<__threading_support>` significantly.

Differential Revision: https://reviews.llvm.org/D154466
2023-07-17 09:32:36 -04:00
Andrew Gozillon
062fce6f4d [Flang][OpenMP][MLIR] An mlir transformation pass for marking FuncOp's implicitly called from TargetOp's and declare target marked FuncOp's as implicitly declare target
This pass will mark functions called from TargetOp's
and declare target functions as implicitly declare
target by adding the MLIR declare target attribute
directly to the function.

This pass executes after the initial lowering of Fortran's PFT
to MLIR (FIR/OMP+Arith etc.) and is one of a series of passes
that aim to clean up the MLIR for offloading (seperate passes
in different patches, one for early outlining, another for declare
target function filtering).

Reviewers: jsjodin, skatrak, kiaranchandramohan

Differential Revision: https://reviews.llvm.org/D154247
2023-07-17 08:32:26 -05:00
Nimish Mishra
89ebea8c1e [mlir][OpenMP] Fixed internal compiler error with atomic update operation verification
Fixes https://github.com/llvm/llvm-project/issues/61089 by updating the
verification followed like translation from OpenMP+LLVM MLIR
dialect to LLVM IR.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D153217
2023-07-17 18:55:28 +05:30
Aaron Ballman
1a88292e03 Fix Clang Sphinx build
This addresses the issues accidentally introduced in
b0697a1cb0b539c773548f62402816e2d9b6f107
2023-07-17 09:01:51 -04:00
Timm Bäder
3f928e787b [clang][Interp][NFC] Fix a doc comment and a typo 2023-07-17 14:44:09 +02:00
Weining Lu
a926a2660a [Triple] Add llvm::Triple::isLoongArch{32,64}
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D155163
2023-07-17 20:34:35 +08:00
Matthias Springer
a4f4d82c35 [mlir][NVGPU][NFC] Clean up code structure
* Move passes to `Transforms` directory.
* Add `Utils.h` (will be utilized in a subsequent change).

Differential Revision: https://reviews.llvm.org/D155427
2023-07-17 14:15:42 +02:00
Jay Foad
92542f2a40 [AMDGPU] Add targets gfx1150 and gfx1151
This is the target definition only. Currently they are treated the same
as GFX 11.0.x.

Differential Revision: https://reviews.llvm.org/D155429
2023-07-17 13:06:12 +01:00
Timm Bäder
e6afacc034 [clang][Interp] Diagnose callsite for implicit functions
We don't have any code to point at here, so the diagnostics would just
point to the record declaration. Make them point to the call site
intead.

Differential Revision: https://reviews.llvm.org/D154761
2023-07-17 14:02:04 +02:00
Jay Foad
a2453c6130 [AMDGPU] Add test case for zext of f16 to i32
Preserve the test case from this abandoned review:
D51925 [AMDGPU] Fix issue for zext of f16 to i32
2023-07-17 12:55:29 +01:00
Guillaume Chatelet
b38dda74fa [libc][NFC] Split memcmp implementations per platform
This is a follow up on D154800 and D154770 to make the code structure more principled and avoid too many nested #ifdef/#endif.

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D155181
2023-07-17 11:35:31 +00:00
Simi Pallipurath
6f4f1023fa [compiler-rt] [Arm] Make the tests for the runtime functions __aeabi_c{d,f} work on Big-Endian.
We are trying to build the compiler-rt as big-endian. And found that the tests compiler-rt/test/builtins/Unit/arm/aeabi_cdcmpeq_test.c and compiler-rt/test/builtins/Unit/arm/aeabi_cfcmpeq_test.c do not work on big endian at the moment. This patch makes these tests work on big endian as well.

Reviewed By: peter.smith, simon_tatham

Differential Revision: https://reviews.llvm.org/D155208
2023-07-17 12:27:32 +01:00
Guillaume Chatelet
83f3920854 [libc][NFC] Split memset implementations per platform
This is a follow up on D154800 and D154770 to make the code structure more principled and avoid too many nested #ifdef/#endif.

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D155174
2023-07-17 11:12:19 +00:00
Jakub Chlanda
3cd3f11c17 [NFC][AMDGPU] Default initialize the Subtarget
This is to address a static analizer warning:

The pointer field will point to an arbitrary memory location, any
attempt to write may cause corruption. In <unnamed>
R600DAGToDAGISel.:R600DAGToDAGISel (llvm::TargetMachine &,
livm::CodeGenOpt::Level): A pointer field is not initialized in the
constructor (CWE-457)

Differential Revision: https://reviews.llvm.org/D154414
2023-07-17 11:39:29 +02:00
David Green
faca9fdc4f [AArch64] Regenerate CostModel tests with update_analyze_test_checks. NFC 2023-07-17 10:23:27 +01:00
Simon Pilgrim
fd2de54920 [X86] Canonicalize vXi64 SIGN_EXTEND_INREG vXi1 to use v2Xi32 splatted shifts instead
If somehow a vXi64 bool sign_extend_inreg pattern has been lowered to vector shifts (without PSRAQ support), then try to canonicalize to vXi32 shifts to improve likelihood of value tracking being able to fold them away.

Using a PSLLQ and bitcasted PSRAD node make it very difficult for later fold to recover from this.
2023-07-17 10:18:03 +01:00
Nuno Lopes
68f1391a62 [ScalarizeMaskedMemIntrin] Use poison instead of undef as placeholder [NFC]
This is used for masked out lanes, that are replaced with the passthrough value
2023-07-17 10:11:14 +01:00
Oleg Shyshkov
4592543a01 [mlir][bazel] Fix build. 2023-07-17 11:00:20 +02:00
David Spickett
3ebd6f65cb [lldb][AArch64] Add test predicate for systems with SME enabled
"sme" is just one of many cpuinfo features for SME but it's the
only one we need for testing.

The rest are related to the use of certain instructions and
don't change the register state available.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D154823
2023-07-17 09:27:12 +01:00
Sander de Smalen
ec6af93d02 [AArch64] NFC: Replace 'forceStreamingCompatibleSVE' with 'isNeonAvailable'.
The AArch64Subtarget interface 'isNeonAvailable' is more appropriate going
forward, as we may also want to generate 'streaming SVE' code (not just
'streaming-compatible SVE' code), but here we must still make sure not to
use NEON instructions which are invalid in streaming SVE mode.
2023-07-17 08:24:10 +00:00
David Sherwood
cc68e05bd2 [SVE][CodeGen] Improve codegen for some zero-extends of masked loads
When doing a masked load of an illegal unpacked type and then
zero-extending to some illegal wider types we sometimes end up
with pointless 'and' instructions that are trying to zero bits
that we already know are zero. This patch fixes that by adding
more cases to performSVEAndCombine.

Differential Revision: https://reviews.llvm.org/D155281
2023-07-17 08:19:27 +00:00
Luke Lau
b5bcd4f60b [RISCV] Add VL nodes and VP patterns for unary zvbb instructions
This follows the pattern of lowering VP nodes to equivalent
RISCVISD::*_VL nodes. The nodes are modelled after the VP ISD nodes rather
than the actual zvbb instructions, and I've included a merge operand to be
consistent with the underlying pseudos that were recently refactored.

I've defined the nodes in RISCVInstrInfoVVLpatterns.td as the nodes aren't Zvk
specific, but the patterns are in RISCVInstrInfoZvk.td.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D155229
2023-07-17 09:17:58 +01:00
Luke Lau
20280ea44a [RISCV] Fix predicates on zvbb patterns
The zvbb extension predicate was getting overwritten by the vtype predicates.
There's no change in the tests though because the ISD nodes were getting
expanded before instruction selection.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D155313
2023-07-17 09:17:56 +01:00
Matthias Gehre
0ebb050311 [MLIR] [TOSA]: Move reshape(reshape(x)) -> reshape(x) from canonicalization to fold
reshape(reshape(x)) -> reshape(x) can be directly written as a fold instead of a canonicalization,
to help other passes cleanup while they work.

This initially broke ReshapeConverterExpand/Collapse, which relies on creating foldable reshapes and a carefully crafted
benefit priority of patterns.
I turned this into a single pattern on reshapes, which does expand and/or collapse as needed in one go.

Differential Revision: https://reviews.llvm.org/D155266
2023-07-17 10:14:37 +02:00
David Spickett
fdf36c3d4b [lldb][AArch64] Fix flakiness in TestSVEThreadedDynamic
This test runs to a breakpoint on thread 0. Thread 0 then starts
thread 2 and 3, which both have breakpoints in them.

In https://lab.llvm.org/buildbot/#/builders/96/builds/41674
I think that we managed to do the first check on thread 2 before
thread 3 had started. Therefore "thread continue 3" failed.

So wait for all three to startup before we check their status.

I considered putting a timeout on the while like the wait_for... methods,
but the test itself already has a global timeout. Plus, I'd rather
not be tuning a timeout per piece of hardware this runs on.

99% of the time we will already have 3 threads when the check is done.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D154705
2023-07-17 08:11:15 +00:00
Sergio Afonso
debdfc0ae2
[Flang][OpenMP][MLIR] Filter emitted code depending on declare target and device
This patch adds support for selecting which functions are lowered to LLVM IR
from MLIR depending on declare target information and whether host or device
code is being generated.

The approach proposed by this patch is to perform the filtering in two stages:
  - An MLIR transformation pass, which is added to the Flang translation flow
    after the `OMPEarlyOutliningPass`. The functions that are kept are those
    that match the OpenMP processor (host or device) the compiler invocation
    is targeting, according to the presence of the `-fopenmp-is-target-device`
    compiler option and declare target information. All functions contaning an
    `omp.target` are also kept, regardless of the declare target information of
    the function, due to the need for keeping target regions visible for both
    host and device compilation.
  - A filtering step during translation to LLVM IR, which is peformed for those
    functions that were kept because of the presence of a target region inside.
    If the targeted OpenMP processor does not match the declare target
    information of the function, then it is removed from the LLVM IR after its
    contents have been processed and translated. Since they should only contain
    an omp.target operation which, in turn, should have been outlined into
    another LLVM IR function, the wrapper can be deleted at that point.

Depends on D150328 and D150329.

Differential Revision: https://reviews.llvm.org/D147641
2023-07-17 09:07:54 +01:00
David Sherwood
6a036316b3 [SVE][CodeGen] Add more test cases for zero-extends of masked loads
This patch adds test cases for extending masked loads of illegal
unpacked types into illegal wider types.

Pre-commits tests for D155281
2023-07-17 08:06:15 +00:00
Sylvestre Ledru
b446c6dfcf cmake: set _LARGEFILE_SOURCE=1 to fix a cmake error
```
-- Performing additional configure checks with target flags: -mips32r2;-mabi=32;-D_LARGEFILE_SOURCE;-D_FILE_OFFSET_BITS=64
-- Performing Test COMPILER_RT_HAS_mips_FLOAT16
CMake Error: Parse error in command line argument: _LARGEFILE_SOURCE
 Should be: VAR:type=value
```
See: https://buildd.debian.org/status/fetch.php?pkg=llvm-toolchain-16&arch=mips64el&ver=1%3A16.0.6-4&stamp=1689111818&raw=0

Differential Revision: https://reviews.llvm.org/D155409
2023-07-17 09:59:56 +02:00
Serge Pavlov
cc006acdd6 [clang] Fix delayed template parsing
Commit 98390ccb80569e8fbb20e6c996b4b8cff87fbec6 fixed late template
instantiation by clearing FP pragma stack before instantiation. This
solution was based on the assumptions:

- FP pragma stack is not used anymore and it is safe to clear it,
- Default FP options are determined by command line options.

Both the assumptions are wrong. When compilation produces precompiled
header file, state of the stack is serialized and then restored when the
precompiled header is used. Delayed template parsing occurs at the end
of translation unit but before serialization, so clearing FP pragma
stack effects serialized representation. When the precompiled file is
loaded, some conditions can be broken and clang crashed, it was
described in https://github.com/llvm/llvm-project/issues/63704. The
crash was observed only in few cases, on most buildbots it was absent.

The violation of expected conditions was caused by violation of the
second assumption. FPEvalMethod can be modified by target, so it is not
possible to deduce it from LangOptions only. So default FP state read
from precompiled header was different from the state in the initialized
Sema, and this was the crash reason.

Only two targets do such modification of default FP options, these are
i386 and AIX. so the problem was hard to reproduce.

Delayed template parsing should occur with empty pragma stack, so it
must be cleared before the instantiation, but the stack now is saved
and restored after the instantiation is done.

This change should fix https://github.com/llvm/llvm-project/issues/63704.

Differential Revision: https://reviews.llvm.org/D155380
2023-07-17 14:51:34 +07:00
MarcoFalke
fa8401f9bf
[compiler-rt][NFC] Avoid implicit-integer-sign-change in FuzzedDataProvider::ConsumeIntegralInRange
This makes the implicit conversion that is happening explicit.
Otherwise, each user is forced to suppress this
implicit-integer-sign-change runtime error in their their UBSAN
suppressions file.

For example, the runtime error might look like:

runtime error: implicit conversion from type 'long' of value -9223372036854775808 (64-bit, signed) to type 'uint64_t' (aka 'unsigned long') changed the value to 9223372036854775808 (64-bit, unsigned)
    #0 0x55fe29dea91d in long FuzzedDataProvider::ConsumeIntegralInRange<long>(long, long) src/./test/fuzz/FuzzedDataProvider.h:233:25
    [...]
SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change test/fuzz/FuzzedDataProvider.h:233:25 in

Differential Revision: https://reviews.llvm.org/D155206
2023-07-17 09:32:19 +02:00
Martin Braenne
d17f455a63 [clang][dataflow] Add refreshStructValue().
Besides being a useful abstraction, this function will help insulate existing clients of the framework from upcoming changes to the API of `StructValue` and `AggregateStorageLocation`.

Depends On D155202

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D155204
2023-07-17 07:26:13 +00:00
Martin Braenne
243a79ca01 [clang][dataflow] Simplify implementation of transferStdForwardCall() in optional check.
The argument and return value of `std::forward` is always a reference, so we can simply forward the storage location.

Depends On D155075

Reviewed By: ymandel, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D155202
2023-07-17 07:26:11 +00:00
Martin Braenne
6d768548ec [clang][dataflow] Add DataflowEnvironment::createObject().
This consolidates the code used in various places to initialize objects (usually for variables) into one central location.

It will also help reduce the number of changes needed when we make the upcoming API changes to `AggregateStorageLocation` and `StructValue`.

Depends On D155074

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D155075
2023-07-17 07:26:10 +00:00
Martin Braenne
4782597e3c [clang][dataflow] Add a test for not explicitly initialized fields in aggregate initialization.
Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D155074
2023-07-17 07:26:08 +00:00
Martin Storsjö
c6bd873403 [CMake] Switch the CMP0091 policy (MSVC_RUNTIME_LIBRARY) to the new behaviour
With the new behaviour, the /MD or similar options aren't added to
e.g. CMAKE_CXX_FLAGS_RELEASE, but are added separately by CMake.
They can be changed by the cmake variable
CMAKE_MSVC_RUNTIME_LIBRARY or with the target property
MSVC_RUNTIME_LIBRARY.

LLVM has had its own custom CMake flags, e.g. LLVM_USE_CRT_RELEASE,
which affects which CRT is used for release mode builds. Deprecate
these and direct users to use CMAKE_MSVC_RUNTIME_LIBRARY directly
instead (and do a best effort attempt at setting CMAKE_MSVC_RUNTIME_LIBRARY
based on the existing LLVM_USE_CRT_ flags). This only handles the
simple cases, it doesn't handle multi-config generators with
different LLVM_USE_CRT_* variables for different configs though,
but that's probably fine - we should move over to the new upstream
CMake mechanism anyway, and push users towards that.

Change code in compiler-rt, that previously tried to override the
CRT choice to /MT, to set CMAKE_MSVC_RUNTIME_LIBRARY instead of
meddling in the old variables.

This resolves the policy issue in
https://github.com/llvm/llvm-project/issues/63286, and should
handle the issues that were observed originally when the
minimum CMake version was bumped, in
https://github.com/llvm/llvm-project/issues/62719 and
https://github.com/llvm/llvm-project/issues/62739.

Differential Revision: https://reviews.llvm.org/D155233
2023-07-17 09:59:05 +03:00
Markus Böck
f69a9f3974 [mlir][ODS] Add support for passing properties to ref in custom
This is essentially a follow up to https://reviews.llvm.org/D155072

This adds support for also passing properties as `ref` parameter to `custom`. This requires the property to have been bound previously and will error otherwise. This makes it possible for an implementation of `custom` to take previously parsed data into account, creating nice context-dependent grammars :-)

Differential Revision: https://reviews.llvm.org/D155297
2023-07-17 08:48:41 +02:00
Piotr Zegar
feaf70b3cd [clang-tidy][NFC] Fix syntax in release notes
Add missing : character to links in release notes
so they could shown properly.
2023-07-17 06:20:17 +00:00
Evan Wilde
d7b45945fb
[NFC][clang] Fix format in UnsafeBufferUsage.cpp
There were two whitespaces on an otherwise empty that were causing the
bots to fail due to formatting issues. Deleting extra whitespace now.
2023-07-16 22:45:29 -07:00
LLVM GN Syncbot
9b0d45baa0 [gn build] Port 42179bbf6bcc 2023-07-17 05:11:41 +00:00
Shivam Gupta
42179bbf6b [clang-tidy] Add check for possibly incomplete switch statements
While clang warns about a possibly incomplete switch statement when switching over an enum variable and failing to cover all enum values (either explicitly or with a default case), no such warning is emitted if a plain integer variable is used as switch variable.

Add a clang-tidy check to diagnose these scenarios.

No fixit hint is provided since there are multiple possible solutions.

Differential Revision: https://reviews.llvm.org/D4784
2023-07-17 10:40:11 +05:30
Piyou Chen
7ce4e933ea [RISCV] Implement prefetch locality by NTLH
We add the MemOperand then backend will generate NTLH automatically.

```
__builtin_prefetch(ptr,  0 /* rw==read */, 0 /* locality */); => ntl.all + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 1 /* locality */); => ntl.pall + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 2 /* locality */); => ntl.p1 + prefetch.r (ptr)
__builtin_prefetch(ptr,  0 /* rw==read */, 3 /* locality */); => prefetch.r (ptr)
```

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D154691
2023-07-16 20:32:46 -07:00
Craig Topper
f3b4c266e8 [RISCV] Adjust the Zfhmin handling in RISCVInstrInfo::copyPhysReg.
Instead of checking '!Zfh && Zhfmin' first, handle Zfh. Then assert
that the other case is F+Zfhmin. The F+Zfhmin check will need to be
relaxed for bfloat16 support. As it was written before there would
be now error to catch that. Instead it would just silently create
fsgnj.h instructions.
2023-07-16 20:20:59 -07:00
Lang Hames
199034e8ac [ORC] In defineMaterializing, error out early if tracker is defunct.
An in-flight materialization may try to claim responsibility for new symbols
(via MaterializationResponsibility::defineMaterializing) after the tracker that
is associated with the materialization is removed, leaving the tracker defunct.

Failure to error out early here could leave the JITDylib in an invalid state,
with defineMaterializing associating new symbols with the already-defunct
tracker. Erroring out early prevents this.
2023-07-16 17:37:56 -07:00
Cassie Jones
f7ad7d147b [Driver] Warn about all instances -mios-version-min not just the last
Follow-up to D155123, uniformly handle cases where there are duplicate
-mios-verion-min arguments.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D155407
2023-07-16 16:45:49 -07:00
Lang Hames
1126cffe06 [ORC] Assert that ExecutionSession is still open when JITDylibs are created. 2023-07-16 16:37:09 -07:00
Nuno Lopes
89552f3a38 [InferAddressSpaces] Use poison instead of undef as placeholder [NFC]
This placeholder is only used during the execution of the algorithm, and it's patched with a
concrete value at the end
2023-07-16 22:33:09 +01:00
Nuno Lopes
f32a9c3bc6 [LoopIdiomRecognize] Use poison instead of undef as placeholder [NFC]
It was using undef as placeholder for getting the TTI cost for cttz
While at it, update the comments about cttz's last argument (is_zero_poison)
2023-07-16 22:33:09 +01:00
Craig Topper
ce70578303 [RISCV] Move comments before 'if' instead of after. NFC
This allows us to remove some curly braces around the if body.
The code wasn't consistent about it anyway. Comments before is
used in other places in this file already.

Reviewed By: wangpc, MaskRay

Differential Revision: https://reviews.llvm.org/D155390
2023-07-16 12:57:49 -07:00
Craig Topper
2a33f47912 [RISCV] Make selectSETCC return SDValue instead of bool. NFC
We can use a null SDValue for the 'false' case. This avoids the
need for an output parameter. This is consistent with other
SelectionDAG code.

Reviewed By: wangpc

Differential Revision: https://reviews.llvm.org/D155388
2023-07-16 12:56:32 -07:00
Piotr Zegar
cc4f865621 [clang-tidy] Improve build-in type handling in bugprone-swapped-arguments
Improved detection of argument swaps involving integral and floating-point
types by enhancing handling of implicit conversions. Now implicit casts
from float to double are also considered, same for integers.
Improved documentation.

Fixes: #62926

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D151495
2023-07-16 18:29:29 +00:00