Commit Graph

562654 Commits

Author SHA1 Message Date
David Green
35b23172c5 [AArch64] Support USDOT in performAddDotCombine (#171864)
This function does
// ADD(UDOT(zero, x, y), A) -->  UDOT(A, x, y)

Which can equally apply to USDOT too now that we have a node for it.
2025-12-15 05:46:43 +00:00
Philip Ginsbach-Chen
1d821b0c6b [AArch64] use isTRNMask to calculate shuffle costs (#171524)
This builds on #169858 to fix the divergence in codegen
(https://godbolt.org/z/a9az3h6oq) between two very similar
functions initially observed in #137447 (represented in the diff by test
cases `@transpose_splat_constants` and `@transpose_constants_splat`:
```
int8x16_t f(int8_t x)
{
  return (int8x16_t) { x, 0, x, 1, x, 2, x, 3,
                       x, 4, x, 5, x, 6, x, 7 };
}

int8x16_t g(int8_t x)
{
  return (int8x16_t) { 0, x, 1, x, 2, x, 3, x,
                       4, x, 5, x, 6, x, 7, x };
}
```

The PR uses an additional `isTRNMask` call in
`AArch64TTIImpl::getShuffleCost` to ensure that we treat shuffle masks
as transpose masks even if `isTransposeMask` fails to recognise them
(meaning that `Kind == TTI::SK_Transpose` cannot be relied upon).

Follow-up work could consider modifying `isTransposeMask`, but that
would also impact other backends than AArch64.
2025-12-15 05:34:30 +00:00
Lang Hames
8f51da369e [orc-rt] Add Error / Exception interop. (#172247)
The ORC runtime needs to work in diverse codebases, both with and
without C++ exceptions enabled (e.g. most LLVM projects compile with
exceptions turned off, but regular C++ codebases will typically have
them turned on). This introduces a tension in the ORC runtime: If a C++
exception is thrown (e.g. by a client-supplied callback) it can't be
ignored, but orc_rt::Error values will assert if not handled prior to
destruction. That makes the following pattern fundamentally unsafe in
the ORC runtime:

```
if (auto Err = orc_rt_operation(...)) {
  log("failure, bailing out"); // <- may throw if exceptions enabled
  // Exception unwinds stack before Error is handled, triggers Error-not-checked
  // assertion here.
  return Err;
}
```

We can resolve this tension by preventing any exceptions from unwinding
through ORC runtime stack frames. We can do this while preserving
exception *values* by catching all exceptions (using `catch (...)`) and
capturing their values as a std::exception_ptr into an Error.

This patch adds APIs to simplify conversion between C++ exceptions and
Errors. These APIs are available only when enabled when the ORC runtime
is configured with ORC_RT_ENABLE_EXCEPTIONS=On (the default).

- `ExceptionError` wraps a std::exception_ptr.

- `runCapturingExceptions` takes a T() callback and converts any
exceptions thrown by the body into Errors. If T is Expected or Error
already then runCapturingExceptions returns the same type. If T is void
then runCapturingExceptions returns an Error (returning Error::success()
if no exception is thrown). If T is any other type then
runCapturingExceptions returns an Expected<T>.

- A new Error::throwOnFailure method is added that converts failing
values into thrown exceptions according to the following rules:
1. If the Error is of type ExceptionError then std::rethrow_exception is
called on the contained std::exception_ptr to rethrow the original
exception value.
2. If the Error is of any other type then std::unique_ptr<T> is thrown
where T is the dynamic type of the Error.

These rules allow exceptions to be propagated through the ORC runtime as
Errors, and for ORC runtime errors to be converted to exceptions by
clients.
2025-12-15 16:10:46 +11:00
Brandon Wu
c24f66e33b [llvm][RISCV] Add bf16 vfabs and vfneg intrinsics for zvfbfa. (#172130)
These are pseudoinstruction aliases for vfsgnjx and vfsgnjn.

Co-authored-by: Craig Topper <craig.topper@sifive.com>
2025-12-15 13:04:21 +08:00
Hristo Hristov
9a03a30706 [libc++][unordered_map] Applied [[nodiscard]] (#170423)
[[nodiscard]] should be applied to functions where discarding the return
value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.html
- https://wg21.link/unord.map
2025-12-15 05:56:19 +02:00
Shenghang Tsai
7ac01771c3 [mlir][ExecutionEngine] Remove stderr printing when propagating errors (#171997) 2025-12-14 19:46:13 -08:00
Lang Hames
00b92e3d81 [orc-rt] Add config.h.in (missing from 7ccf968d0b).
This file was accidentally left out of commit 7ccf968d0b.
2025-12-15 14:07:47 +11:00
Hristo Hristov
59fb3bc3e7 [libc++][pair] Applied [[nodiscard]] (#171999)
`[[nodiscard]]` should be applied to functions where discarding the
return value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.html
- https://wg21.link/pairs
2025-12-15 10:42:48 +08:00
Hristo Hristov
b6d940d9bc [libc++][multimap] Applied [[nodiscard]] (#171644)
`[[nodiscard]]` should be applied to functions where discarding the
return value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.html
- https://wg21.link/multimap
2025-12-15 10:37:32 +08:00
Valentin Clement (バレンタイン クレメン)
b9d1432213 [flang-rt][device] Use snprintf result for length (#172239)
The buffer might not be null terminated on the device and result in 1
byte invalid read when trying to get the length.
2025-12-15 01:08:30 +00:00
Maksim Panchenko
adaca1348e [BOLT] Introduce getOutputBinaryFunctions(). NFCI (#172174)
To gain better control over the functions that go into the output file
and their order, introduce `BinaryContext::getOutputBinaryFunctions()`.

The new API returns a modifiable list of functions in output order.

This list is filled by a new `PopulateOutputFunctions` pass and includes
emittable functions from the input file, plus functions added by BOLT
(injected functions).

The new functionality allows to freely intermix input functions with
injected ones in the output, which will be used in new PRs.

The new function replaces `BinaryContext::getSortedFunctions()`, but
unlike its predecessor, it includes injected functions in the returned
list.
2025-12-14 16:29:01 -08:00
Lang Hames
ca81d7c2db [orc-rt] Ensure EH/RTTI=On overrides LLVM opts, applies to unit tests. (#172155)
When -DORC_RT_ENABLE_EXCEPTIONS=On and -DORC_RT_ENABLE_RTTI=On are
passed we need to ensure that the resulting compiler flags (e.g.
-fexceptions, -frtti for clang/GCC) are appended so that we override any
inherited options (e.g. -fno-exceptions, -fno-rtti) from LLVM.

Updates unit tests to ensure that these compiler options are applied to
them too.
2025-12-15 11:06:27 +11:00
Victor Chernyakin
21a25f44af [clang-tidy] Suggest std::views::reverse instead of std::ranges::reverse_view in modernize-use-ranges (#172199)
`std::views::FOO` should in almost all cases be preferred over
`std::ranges::FOO_view`. For a detailed explanation of why that is, see
https://brevzin.github.io/c++/2023/03/14/prefer-views-meow/. The TLDR is
that it's shorter to spell (which is obvious) and can in certain cases
be more efficient (which is less obvious; see the article if curious).
2025-12-14 16:02:36 -08:00
Haojian Wu
ecfdf8cb05 [bazel] One more fix for f785ca0d72 2025-12-14 23:44:23 +01:00
Raul Tambre
14c69497b3 Partially revert "[NFCI][lldb][test][asm] Enable AT&T syntax explicitly (#166770)" (#172233)
Flag changes reverted as those require the X86 target to be enabled.  
Don't have time to test fixes as I need to go to sleep so will revert for now.

Reverts: 423919d31f
2025-12-15 00:26:54 +02:00
Rolf Morel
f12fcf030c [MLIR][Transform][Python] transform.foreach wrapper and .owner OpViews (#172228)
Friendlier wrapper for transform.foreach.

To facilitate that friendliness, makes it so that OpResult.owner returns
the relevant OpView instead of Operation. For good measure, also changes
Value.owner to return OpView instead of Operation, thereby ensuring
consistency. That is, makes it is so that all op-returning .owner
accessors return OpView (and thereby give access to all goodies
available on registered OpViews.)

Reland of #171544 due to fixup for integration test.
2025-12-14 22:10:31 +00:00
Raul Tambre
423919d31f [NFCI][lldb][test][asm] Enable AT&T syntax explicitly (#166770)
Implementation files using the Intel syntax typically explicitly specify it.
Do the same for the few files using AT&T syntax.

This enables building LLVM with `-mllvm -x86-asm-syntax=intel` in one's Clang config files
(i.e. a global preference for Intel syntax).
2025-12-14 23:54:25 +02:00
Haojian Wu
bebc28a0ac [bazel] Port for f785ca0d72 2025-12-14 22:36:46 +01:00
Mehdi Amini
b9fe6532a7 Revert "[MLIR][Transform][Python] transform.foreach wrapper and .owner OpViews" (#172225)
Reverts llvm/llvm-project#171544 ; bots are broken.
2025-12-14 21:27:02 +00:00
Florian Hahn
bcbbe2c2bc [VPlan] Pass backedge value directly to FOR and reduction phis (NFC).
Pass backedge values directly to VPFirstOrderRecurrencePHIRecipe and
VPReductionPHIRecipe directly, as they must be provided and availbale.

Split off from https://github.com/llvm/llvm-project/pull/168291.
2025-12-14 20:59:22 +00:00
Rolf Morel
4cdec92827 [MLIR][Transform][Python] transform.foreach wrapper and .owner OpViews (#171544)
Friendlier wrapper for `transform.foreach`.

To facilitate that friendliness, makes it so that `OpResult.owner`
returns the relevant `OpView` instead of `Operation`. For good measure,
also changes `Value.owner` to return `OpView` instead of `Operation`,
thereby ensuring consistency. That is, makes it is so that all
op-returning `.owner` accessors return `OpView` (and thereby give access
to all goodies available on registered `OpView`s.)
2025-12-14 20:44:15 +00:00
Florian Hahn
53cf22f3a1 [VPlan] Simplify live-ins early using SCEV. (#155304)
Use SCEV to simplify all live-ins during VPlan0 construction. This
enables us to remove special SCEV queries when constructing
VPWidenRecipes and improves results in some cases.

This leads to simplifications in a number of cases in real-world
applications (~250 files changed across LLVM, SPEC, ffmpeg)

PR: https://github.com/llvm/llvm-project/pull/155304
2025-12-14 20:15:05 +00:00
Hristo Hristov
9975cb166e [libc++][expected] Applied [[nodiscard]] (#170245)
[[nodiscard]] should be applied to functions where discarding the return
value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.html
- https://wg21.link/expected.bad.void
- https://wg21.link/expected.bad
- https://wg21.link/expected.expected
- https://wg21.link/expected.void
- https://wg21.link/expected.unexpected

It was already discussed not to mark the type `std::expected` as
`[[nodiscard]]` see:
https://github.com/llvm/llvm-project/pull/139651
https://github.com/llvm/llvm-project/pull/130820
Also:
https://github.com/llvm/llvm-project/pull/154943
2025-12-14 19:11:16 +02:00
Alexey Samsonov
8f93365b19 [tsan] Export __cxa_guard_ interceptors from TSan runtime. (#171921)
These functions from C++ ABI are defined in
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp and are supposed to
replace implementations from libstdc++/libc++abi.

We need to export them similar to why we need to export other
interceptors and TSan runtime functions - e.g. if a dlopen-ed shared
library depends on `__cxa_guard_acquire`, it needs to pick up the
exported definition from the TSan runtime that was linked into the main
executable calling the dlopen()

However, because the `__cxa_guard_` functions don't use traditional
interceptor machinery, they are omitted from the auto-generated
`libclang_rt.tsan.a.syms` files. Fix this by adding them to
tsan.syms.extra file explicitly.

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2025-12-14 08:53:22 -08:00
Asher Mancinelli
4b267d5caa [MLIR][MemRef] Emit error on atomic generic result op defined outside the region (#172190)
While figuring out how to perform an atomic exchange on a memref, I
tried the generic atomic rmw with the yielded value captured from the
enclosing scope (instead of a plain atomic_rmw with
`arith::AtomicRMWKind::assign`). Instead of segfaulting, this PR changes
the pass to produce an error when the result is not found in the
region's IR map.

It might be more useful to give a suggestion to the user, but giving an
error message instead of a crash is at least an imrovement, I think.

See: #172184
2025-12-14 08:31:43 -08:00
Simon Pilgrim
dd33690686 [X86] combineVectorSizedSetCCEquality - convert to mayFoldIntoVector helper (#172215)
Add AssumeSingleUse (default = false) argument to mayFoldIntoVector to
allow us to match combineVectorSizedSetCCEquality behaviour with
AssumeSingleUse=true

Hopefully we can drop the AssumeSingleUse entirely soon, but there are a
number of messy test regressions that need handling first
2025-12-14 16:11:31 +00:00
Sergei Druzhkov
e82edd28f6 [lldb-dap] Migrate locations request to structured types (#171099)
This patch migrates `locations` request into structured types and adds
test for it.
2025-12-14 18:37:24 +03:00
nerix
9de41eef6e [LLDB][NativePDB] Create typedefs in structs (#169248)
Typedef/using declarations in structs and classes were not created with
the native PDB plugin. The following would only create `Foo` and
`Foo::Bar`:
```cpp
struct Foo {
    struct Bar {};
    using Baz = Bar;
    using Int = int;
};
```

With this PR, they're created. One complication is that typedefs and
nested types show up identical. The example from above gives:
```
  0x1006 | LF_FIELDLIST [size = 40, hash = 0x2E844]
           - LF_NESTTYPE [name = `Bar`, parent = 0x1002]
           - LF_NESTTYPE [name = `Baz`, parent = 0x1002]
           - LF_NESTTYPE [name = `Int`, parent = 0x0074 (int)]
```

To distinguish nested types and typedefs, we check if the parent of a
type is equal to the current one (`parent(0x1002) == 0x1006`) and if the
basename matches the nested type name.
2025-12-14 15:42:57 +01:00
Alex Bradbury
8a53c01b67 [XRay][test] Mark fdr-mode.cpp test as unsupported for RISC-V
Commit c6f501d479 fixed an issue where some tests were incorrectly
marked as unsupported for a bootstrapping build. This exposed in our
'slow' full-bootstrap qemu-system CI that the fdr-mode.cpp fails on
RISC-V. We mark it as unsupported. I believe _xray_ArgLoggerEntry needs
to be implemented in xray_trampoline_risc*.S for this to work.
2025-12-14 14:26:48 +00:00
Simon Pilgrim
8d7c3fa6e4 [X86] combineVectorSizedSetCCEquality - ensure the load is a normal load (#172212)
Noticed while trying to replace the IsVectorBitCastCheap helper with
mayFoldIntoVector (still some work to do as we have a number of multiuse
cases) - technically its possible for a extload to reach this point.
2025-12-14 14:18:36 +00:00
David Green
1a1c5df7f9 [ARM] Introduce intrinsics for MVE fp-converts under strict-fp. (#170686)
This is the last of the generic instructions created from MVE
intrinsics. It was a little more awkward than the others due to it
taking a Type as one of the arguments. This creates a new function to
create the intrinsic we need.
2025-12-14 12:12:45 +00:00
David Green
b97d24796c [ARM] Introduce intrinsics for MVE vcmp under strict-fp. (#169798)
Similar to #169156 again, this adds intrinsics for strict-fp compare nodes to
make sure they end up as the original instruction.
2025-12-14 11:27:48 +00:00
David Green
1b93f8b48f [ARM] Introduce intrinsics for MVE vrnd under strict-fp. (#169797)
Similar to #169156 again, this adds intrinsics for strict-fp vrnd nodes to make
sure they end up as the original instruction.
2025-12-14 11:19:53 +00:00
Alexis Engelke
66d92d4cfb [LLVM][Examples] Disable broken JIT + plugin tests (AIX, Sparc)
Plugins appear to be broken on AIX, CI fails. There is logic in
CMakeLists for plugins+AIX, but it was never tested before...
Note: when plugins work, also enable tests in Examples/IRTransforms.

There's no Sparc support for JIT tests, so disable the JIT tests in the
examples (copied from ExecutionEngine/lit.local.cfg).
2025-12-14 11:00:32 +00:00
Artur Bermond Torres
755a693299 [DAG] SDPatternMatch - Replace runtime data structures with lengths known at compile time (#172064)
Following the suggestions in #170061, I replaced `SmallVector<SDValue>`
with `std::array<SDValue, NumPatterns>` and `SmallBitVector` with
`Bitset<NumPatterns>`.

I had to make some changes to the `collectLeaves` and
`reassociatableMatchHelper` functions. In `collectLeaves` specifically,
I changed the return type so I could propagate a failure in case the
number of found leaves is greater than the number of expected patterns.
I also added a new unit test that, together with the one already present
in the previous line, checks if the matching fails in the cases where
the number of patterns is less or more than the number of leaves.

I don't think this is going to completely address the increased compile
time reported in #169644, but hopefully it leads to an improvement.
2025-12-14 10:48:08 +00:00
Ivan Butygin
f785ca0d72 [mlir][nvgpu] Move memref memspace attributes conversion to single place (#172156)
Also, some fixes for AMDGPU part for better naming.
2025-12-14 12:44:47 +03:00
Hui
8680feb913 [libc++] Use native wait in std::barrier instead of sleep loop (#171041)
For some reason, the current `std::barrier`'s wait implementation polls
the underlying atomic in a loop with sleeps instead of using the native
wait.

This change should also indirectly fix the performance issue of
`std::barrier` described in
https://github.com/llvm/llvm-project/issues/123855.

Fixes #123855
2025-12-14 09:34:57 +00:00
Hristo Hristov
86dc131997 [libc++][flat_multiset] Applied [[nodiscard]] (#169984)
`[[nodiscard]]` should be applied to functions where discarding the
return value is most likely a correctness issue.

-  https://libcxx.llvm.org/CodingGuidelines.htm
-  https://wg21.link/flat.multiset
2025-12-14 16:49:55 +08:00
Hristo Hristov
61f4cc7cd2 [libc++][flat_multimap] Applied [[nodiscard]] (#169986)
`[[nodiscard]]` should be applied to functions where discarding the
return value is most likely a correctness issue.

- https://libcxx.llvm.org/CodingGuidelines.htm
- https://wg21.link/flat.multimap
2025-12-14 16:46:58 +08:00
Mythreya Kuricheti
d78e431917 [clangd] Add option to fuzzy-match macros in code-complete (#169880)
Adds `MacroFilterPolicy` 

```yaml
Completion:
  MacroFilter: ExactPrefix (default), FuzzyMatch
```

Fixes clangd/clangd#1480
2025-12-14 03:29:53 -05:00
Dominicentek
4a1b6966ac [clangd] Add a (currently hidden) --strong-workspace-mode flag (#172160)
Its current effect is to use the `rootUri` provided by the client as the
working directory for fallback commands.

Future effects will include other behaviors appropriate for cases
where clangd is being run in the context of editing a single
workspace, such as using the `compile_commands.json` file in the
workspace root for all opened files.

The flag is hidden until other behaviors are implemented and they
constitute a cohesive "mode" for users.

Original PR in #155905, which was reverted due to a UBSan failure
that is fixed in this version.
2025-12-14 03:24:18 -05:00
David Green
7db97696a2 [ARM][AArch64] Replace ".f16(bfloat" with ".bf16(bfloat" in intrinsics. NFC
It looks like these were copied from fp16 tests, and forgot to update the
intrinsic types. Also remove some old definitions that are no longer required.
2025-12-14 04:39:41 +00:00
mitchell
72574b8195 [clang-tidy] Add IgnoreMacro option to bugprone-chained-comparison (#171975)
Closes #171130

---------

Co-authored-by: Baranov Victor <bar.victor.2002@gmail.com>
2025-12-14 12:31:25 +08:00
Phoebe Wang
f0557d8eb7 Revert "[X86][APX] Add pattern for zext(X86setcc ..) -> SETZUCCr (#170806)" (#172192)
This reverts commit 2612dc9b5f but keeps
`Predicates = [HasNDD]` removed.

There are two issues identified related to the change. One is
INSERT_SUBREG cannot guarantee source and dest to be the same register.
It mostly happens on O0. The other one is zero_extend is not a chain
node, as a result, we will lose the chain for SETZUCCr.
2025-12-14 04:21:18 +00:00
Mingjie Xu
1ea9f44f29 [IR] Optimize PHINode::removeIncomingValueIf() using two-pointer (#171961) 2025-12-14 10:27:09 +08:00
int-zjt
fd95803a35 [LoopRotate] Simplify PHINode::removeIncomingValue usage (NFC) (#171958) 2025-12-14 09:43:52 +08:00
Mingjie Xu
1156629f4f [ARM][MVE] Avoid PHINode::removeIncomingValue() with PHINode::setIncomingValue() and PHINode::setIncomingBlock() (NFC) (#171960) 2025-12-14 09:42:06 +08:00
Mingjie Xu
681dbf9941 [WinEH] Use removeIncomingValueIf() in UpdatePHIOnClonedBlock() (NFC) (#171962) 2025-12-14 09:41:13 +08:00
Rolf Morel
b33354f272 [MLIR][Python][Transform] Print diagnostics also upon success (#172188)
If we do not collect the diagnostics from the
CollectDiagnosticsToStringScope, even when the named_sequence applied
successfully, the Scope object's destructor will assert (with a
unhelpful message).
2025-12-14 00:35:52 +00:00
Victor Chernyakin
49ad1e9ea2 [clang-tidy][NFC] Remove obsolete FIXME comment (#172120)
This comment was written 12 years ago. It's no longer correct to say
that diagnostic reporting is under heavy development, and we seem to be
doing just fine without tablegenned IDs, so I think we can simply remove
it.
2025-12-13 16:28:09 -08:00