544827 Commits

Author SHA1 Message Date
Tobias Hieta
01f36b39bd Bump version to 22.0.0-git llvmorg-22-init 2025-07-15 16:03:12 +02:00
Krzysztof Parzyszek
face93e724
[Frontend][OpenMP] Move isPrivatizingClause to OMP.h, NFC (#148644) 2025-07-15 09:00:15 -05:00
Sjoerd Meijer
d26106dbf0
[AArch64] Set the cache line size to 64 for the V2 and V3. (#148213)
This sets the cache line size to 64 for the Neoverse V2 and V3. I've
tested this with loop-interchange: it doesn't result in extra
compile-times, but it does enable a lot more interchange.
2025-07-15 14:59:18 +01:00
Sander de Smalen
1fbe87b1d0
[AArch64] Ensure bundle expansion of MOVPRFX gets correct implicit ops (#148824)
By finalizing the bundle _after_ copying over the implicit-ops, it also
adds any implicit-defs to the BUNDLE.

Fixes https://github.com/llvm/llvm-project/issues/148645
2025-07-15 14:53:47 +01:00
Sander de Smalen
50e345ef95
[AArch64] Use correct regclass for spills of ZPR2/ZPR4 (#148806)
Commit a6293228fdd5aba8c04c63f02f3d017443feb3f2 forced the register
class of ZPR[24]StridedOrContiguous for spills/fills of ZPR2 and ZPR4,
but this may result in issues when the regclass for the fill is a
ZPR2/ZPR4 which would allow the register allocator to pick `z1_z2`,
which is not a supported register for ZPR2StridedOrContiguous that only
supports tuples of the form (strided) `z0_z8`, `z1_z9` or (contiguous,
start at multiple of 2) `z0_z1`, `z2_z3`. For spills we could add a new
register class that supports any of the tuple forms, but I've decided
to use two pseudos similar to the fills for consistency.

Fixes https://github.com/llvm/llvm-project/issues/148655
2025-07-15 14:53:05 +01:00
Martin Erhart
bda56023c9
[mlir][SliceAnalysis] Fix stack overflow in graph regions (#139694)
This analysis currently just crashes when applied to a graph region that
has a use-def cycle. This PR fixes that by keeping track of the
operations the DFS has already visited when following use-def edges and
stopping once we visit an operation again.
2025-07-15 14:48:05 +01:00
Mohammadreza Ameri Mahabadian
94b15a1ece
[mlir][spirv] Add basic support for SPV_EXT_replicated_composites (#147067)
This patch introduces two new ops to the SPIR-V dialect:
- `spirv.EXT.ConstantCompositeReplicate`
- `spirv.EXT.SpecConstantCompositeReplicate`

These ops represent composite constants and specialization constants,
respectively, constructed by replicating a single splat constant across
all elements. They correspond to `SPV_EXT_replicated_composites`
extension instructions:
- `OpConstantCompositeReplicatedEXT`
- `OpSpecConstantCompositeReplicatedEXT`

No transformation to these new ops has been introduced in this patch.

This approach is chosen as per the discussions on RFC
https://discourse.llvm.org/t/rfc-basic-support-for-spv-ext-replicated-composites-in-mlir-spir-v-compile-time-constant-lowering-only/86987

---------

Signed-off-by: Mohammadreza Ameri Mahabadian <mohammadreza.amerimahabadian@arm.com>
2025-07-15 09:45:13 -04:00
Luke Lau
612afab512 [RISCV] Use MachineInstr::isFullCopy in a few places. NFC
Instead of checking that there's no subregisters.
2025-07-15 21:39:59 +08:00
Orlando Cazalet-Hyams
5977766bf6
[KeyInstr][Clang][NFC] Add test for array cookie store (#146517)
It doesn't need to be a Key Instruction.
2025-07-15 14:21:04 +01:00
Haohai Wen
8226fbee4b
[NFC] Extract pseudo probe using mdconst::extract (#148821)
mdconst::extract is more rigorous than mdconst::dyn_exract in this
context.
2025-07-15 21:05:52 +08:00
Ryotaro Kasuga
b3c293c5b9
[LoopInterchange] Drop nuw/nsw flags from reduction ops when interchanging (#148612)
Before this patch, when a reduction exists in the loop, the legality
check of LoopInterchange only verified if there exists a
non-reassociative floating-point instruction in the reduction
calculation. However, it is insufficient, because reordering integer
reductions can also lead to incorrect transformations. Consider the
following example:

```c
int A[2][2] = {
  { INT_MAX, INT_MAX },
  { INT_MIN, INT_MIN },
};

int sum = 0;
for (int i = 0; i < 2; i++)
  for (int j = 0; j < 2; j++)
    sum += A[j][i];
```

To make this exchange legal, we must drop nuw/nsw flags from the
instructions involved in the reduction operations.

This patch extends the legality check to correctly handle such cases. In
particular, for integer addition and multiplication, it verifies that
the nsw and nuw flags are set on involved instructions, and drop them
when the transformation actually performed. This patch also introduces
explicit checks for the kind of reduction and permits only those that
are known to be safe for interchange. Consequently, some "unknown"
reductions (at the moment, `FindFirst*` and `FindLast*`) are rejected.

Fix #148228
2025-07-15 22:04:16 +09:00
Orlando Cazalet-Hyams
9eb0fc8e57 Fix link in docs after #137991 2025-07-15 13:50:15 +01:00
Hugo Melder
0b784269f1
[CodeGen][ObjC] Include all referenced protocols in protocol list (#148827)
When constructing the protocol list in the class metadata generation
(`GenerateClass`), only the protocols from the base class are added but
not protocols declared in class extensions.

This is fixed by using `all_referenced_protocol_{begin, end}` instead of
`protocol_{begin, end}`, matching the behaviour on Apple platforms.

A unit test is included to check if all protocol metadata was emitted
and that no duplication occurs in the protocol list.

Fixes https://github.com/gnustep/libobjc2/issues/339

CC: @davidchisnall
2025-07-15 13:42:42 +01:00
Orlando Cazalet-Hyams
acffe8324b
[KeyInstr] Add docs (#137991)
This document explains the core ideas and some implementation details
of the Key Instructions project. The LLVM document also outlines the two
main limitations of our approach.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668
2025-07-15 13:38:08 +01:00
David Spickett
17d9f2aee9 [clang][docs] Fix formatting in breaking changes note
Need to use double backticks to get plain text in RST.
2025-07-15 12:35:39 +00:00
Florian Hahn
cfdd5ca2ed
[LV] Add tests for fmin reductions without fast-math flags.
Some of those reductions can be vectorized with extra checks.

Extra tests for https://github.com/llvm/llvm-project/pull/148239 and
follow-ups.
2025-07-15 13:34:12 +01:00
David Spickett
a9cfe84d88 [llvm][docs] Correct formatting in lldb release note
When you use <> in markdown it thinks it's an HTML tag
and does not show anything.
2025-07-15 12:31:05 +00:00
Haojian Wu
a2b3110945
[clang] Reduce the small vector size for DeclTypeInfo. (#148788)
The `Declarator` class is large (4584 bytes) and used as a stack-local
variable during parsing.

This patch reduces the default size of its `DeclTypeInfo` member,
reducing the overall size down to 3880 bytes. This allows clang handle
more deeply nested expressions without exhausting the stack.

Combined with #148726, the nesting threshold for such expressions
increases to `~1100`.

No performance impact being
[observed](https://llvm-compile-time-tracker.com/compare.php?from=d4f5ed6a23464cbe831820cb695aa1d39b11e4aa&to=66ba54b8a295cc2759387ef2a4a162de2ad4946e&stat=instructions:u).
2025-07-15 13:44:24 +02:00
Haojian Wu
2a9afdb793
[clang] Reduce the size of ParsedAttributesView and AttributePool (#148726)
These objects are used as local stack variables during parsing, and they
are not small. This patch reduces their sizes:

* `ParsedAttributesView`: 72 → 40 bytes
* `AttributePool`: 72 → 40 bytes

No negative performance impact has been
[observed](https://llvm-compile-time-tracker.com/compare.php?from=a709621cd545b061782b03136286227867b452a6&to=f50500b3c178e97c0c861301e853e6d5b859040b&stat=instructions:u).

**Context:**
We have some verilator-generated code with extremely deep nesting of
parenthesized expressions, e.g.:

```cpp
bool s = 
(...(bool)(i[0])
 |(bool)(i[1]))
 |(bool)(i[2]))
 | ...
 |(bool)(i[n]));
```

Before this patch, on my local machine, Clang begins emitting
`-Wstack-exhausted` when `n` is 715. After the patch, that threshold
increases to `950`.
2025-07-15 13:43:50 +02:00
Corentin Jabot
57d81c23f4
[Clang] Remove explicit object from non member function. (#148807)
To avoid crashing later (as we assume only member functions can have
explicit object parameters)

Fixes #113185
2025-07-15 13:34:32 +02:00
Vikram Hegde
8cbcaee7fe
[CodeGen][NPM] Register Function Passes (#148109)
same as https://github.com/llvm/llvm-project/pull/138828,

Co-authored-by : Oke, Akshat
<[Akshat.Oke@amd.com](mailto:Akshat.Oke@amd.com)>
2025-07-15 17:01:28 +05:30
Matt Arsenault
2f70e074f2
XCore: Add frexp intrinsic test (#148676) 2025-07-15 20:31:05 +09:00
Fraser Cormack
8a7a64873b
[libclc] Move CMake for prepare_builtins to a subdirectory (#148815)
This simply makes things better self-contained.
2025-07-15 12:26:11 +01:00
Amr Hesham
b3240b4889
[CIR][NFC] Fix LoweringPrepare pass multi lines summary (#148826)
Fix the Lowering Prepare a multi-line summary
2025-07-15 13:15:25 +02:00
Jannick Kremer
ec149d5ef8
[clang][python][test] Move python binding tests to lit framework (#148802)
As discussed in PR #142353, the current testsuite of the `clang` Python
bindings has several issues:

- It `libclang.so` cannot be loaded into `python` to run the testsuite,
the whole `ninja check-all` aborts.
- The result of running the testsuite isn't report like the `lit`-based
tests, rendering them almost invisible.
- The testsuite is disabled in a non-obvious way (`RUN_PYTHON_TESTS`) in
`tests/CMakeLists.txt`, which again doesn't show up in the test results.

All these issues can be avoided by integrating the Python bindings tests
with `lit`, which is what this patch does:

- The actual test lives in `clang/test/bindings/python/bindings.sh` and
is run by `lit`.
- The current `clang/bindings/python/tests` directory (minus the
now-subperfluous `CMakeLists.txt`) is moved into the same directory.
- The check if `libclang` is loadable (originally from PR #142353) is
now handled via a new `lit` feature, `libclang-loadable`.
- The various ways to disable the tests have been turned into `XFAIL`s
as appropriate. This isn't complete and not completely tested yet.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.

Co-authored-by: Rainer Orth <ro@gcc.gnu.org>
2025-07-15 12:48:24 +02:00
William Huynh
0425a5df4d
[libc] Add hooks for extra options in running hermetic tests (#147931)
Part of #145349. These hooks are required downstream in order to run
hermetic tests. See https://github.com/arm/arm-toolchain/pull/420 for
more context on how this PR will be used.
2025-07-15 11:43:51 +01:00
Nikolas Klauser
339a1f2e8f
Revert "[libc++][hardening] Introduce assertion semantics" (#148822)
Reverts llvm/llvm-project#148268

It looks like this was based on #148266, which I reverted in #148787.
2025-07-15 12:43:37 +02:00
Gaëtan Bossu
adb6efeac9
[SLP] Fix cost estimation of external uses with wrong VF (#148185)
It assumed that the VF remains constant throughout the tree. That's not
always true. This meant that we could query the extraction cost for a
lane that is out of bounds.

While experimenting with re-vectorisation for AArch64, we ran into this
issue. We cannot add a proper AArch64 test as more changes would need to
be brought in.

This commit is only fixing the computation of VF and adding an assert.
Some tests were failing after adding the assert:
 - foo() in llvm/test/Transforms/SLPVectorizer/X86/horizontal.ll
- test() in
llvm/test/Transforms/SLPVectorizer/X86/reduction-with-removed-extracts.ll
- test_with_extract() in
llvm/test/Transforms/SLPVectorizer/RISCV/segmented-loads.ll
2025-07-15 11:39:09 +01:00
David Spickett
97d44e3166 [lldb][test] Disable riscv32 disassembly filter test on Windows
Added by https://github.com/llvm/llvm-project/pull/145793

Failing on our Windows on Arm bot:
https://github.com/llvm/llvm-project/pull/145793

Shebang lines don't work on Windows and we can't pass "python script_name"
to the "fdis set" commadn because of the way arguments are parsed currently.

I can fix that but that needs review, disable the test for now.
2025-07-15 10:34:25 +00:00
Amr Hesham
af99f18d91
[CIR] Upstream the basic structure of LoweringPrepare pass (#148545)
Upstream, the basic structure of the LoweringPrepare pass as a
prerequisite for other ComplexType PR's

https://github.com/llvm/llvm-project/issues/141365
2025-07-15 12:33:24 +02:00
Stephen Tozer
c6ac07b95a
[Dexter] Add option to Dexter to name results based on directory (#148611)
As a legacy of Dexter's role as a test runner, it selects a name for
result files based on the relative path from the test root to each
individual test. Since Dexter no longer takes a test directory as an
argument, only the basename for each test is ever used. This patch adds
an optional --test-root-dir argument, allowing for relative paths to be
used for result files again.
2025-07-15 11:16:51 +01:00
Nikolas Klauser
fda3fbee6f
Revert "[libc++][hardening] Introduce a dylib function to log hardening errors." (#148787)
Reverts llvm/llvm-project#148266

I'm reverting this temporarily, since the release branch is today and
this is ABI sensitive. Let's wait until after the branch so that we have
plenty time to discuss the patch.
2025-07-15 12:12:41 +02:00
Florian Hahn
a40dc05898
[VPlan] Mark canonical IV and reduction phis as not writing memory (NFC).
Both recipes do not write to memory. Should be NFC at the moment, as
they cannot be removed currently due to being in a cycle.
2025-07-15 11:08:54 +01:00
Paul Walker
bd4e7f5f5d
[LLVM][DAGCombiner] Fix size calculations in calculateByteProvider. (#148425)
calculateByteProvider only cares about scalars or a single element
within a vector. For the later there is the VectorIndex parameter to
identify the element. All other properties, and specificially Index, are
related to the underyling scalar type and thus when taking the size of a
type it's the scalar size that matters.

Fixes https://github.com/llvm/llvm-project/issues/148387
2025-07-15 11:05:38 +01:00
Matt Arsenault
92501396b4
SafeStack: Emit __safestack_pointer_address call through RuntimeLibcalls (#147916)
Stop using hardcoded function named and check availability. This only fixes
the forced usage via command line in the pass itself; the implementations
inside of TargetLoweringBase hide additional call emission.
2025-07-15 19:01:00 +09:00
David Spickett
a64bfd8a51 [lldb] Fix Disasembler build error on 32-bit systems
After changes in https://github.com/llvm/llvm-project/pull/145793.

/home/david.spickett/llvm-project/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp:1360:49: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned int')
 1360 |   status = m_disasm_up->getInstruction(mc_inst, size, data, pc, llvm::nulls());
      |                                                 ^~~~
/home/david.spickett/llvm-project/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h:135:64: note: passing argument to parameter 'Size' here
  135 |   virtual DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
      |                                                                ^
1 error generated.

The type used in the LLVM method we call is uin64_t so use that instead.
It's overkill for what it is, but that's a separate issue if anyone cares.

Also removed the unused form of GetMCInst.
2025-07-15 09:54:58 +00:00
Matt Arsenault
b2eb7b0701
SPIRV: Define runtime libcalls to be (almost) empty (#148631)
This is a behavior change; previously SPIRV inherited
a default set of calls which seems like a mistake. This
defines a library set with no calls. Add memcpy and memset
as a hack; this avoids PreISelIntrinsicLowering performing
the default expansion. SPIRVPrepareFunctions also calls
the utilities to expand these but the resulting output
is slightly different. The backend specific version
can probably be removed, it for some reason has a larger
output than the default one.
2025-07-15 18:51:09 +09:00
Haohai Wen
148708493a
[NFC] Hoist pseudo probe desc emission code for reuse (#148756)
This PR is part of #123870.
The pseudo probe desc emission code can be reused by other target.
2025-07-15 17:48:04 +08:00
Nikolas Klauser
0c3a2faa85
[libc++] Simplify the implementation of __libcpp_{,de}allocate (#147989)
GCC 15 also supports `__buitin_operator_{new,delete}` now, so the
`#else` cases are dead code. This patch inlines the calls to the wrapper
functions and simplifies some surrounding code.
2025-07-15 11:43:55 +02:00
Matt Arsenault
d7dc5367ed
SafeStack: Emit call to __stack_chk_fail through RuntimeLibcalls (#147915)
Avoid hardcoding the function name, and query if it's really
supported or not.
2025-07-15 18:43:22 +09:00
Matt Arsenault
e68ef116b3
RuntimeLibcalls: Add entries for some exception related functions (#147914)
SjLjEHPrepare and WasmEHPrepare directly emit calls to these by
name, and these are not tracked in RuntimeLibcalls. It will be easier
to fix this when RuntimeLibcalls is turned into an analysis, so just
add the entries for now.
2025-07-15 18:40:45 +09:00
Matt Arsenault
259a11db5e
StackProtector: Use RuntimeLibcalls to query libcall names (#147913)
The compiler should not introduce calls to arbitrary strings
that aren't defined in RuntimeLibcalls. Previously OpenBSD was
disabling the default __stack_chk_fail, but there was no record
of the alternative __stack_smash_handler function it emits instead.

This also avoids a random triple check in the pass.
2025-07-15 18:37:59 +09:00
Tom Eccles
a1c61ac756
[mlir][OpenMP] Allow composite SIMD REDUCTION and IF (#147568)
Reduction support: https://github.com/llvm/llvm-project/pull/146671
If Support is fixed in this PR

The problem for the IF clause in composite constructs was that wsloop
and simd both operate on the same CanonicalLoopInfo structure: with the
SIMD processed first, followed by the wsloop. Previously the IF clause
generated code like
```
if (cond) {
  while (...) {
    simd_loop_body;
  }
} else {
  while (...) {
    nonsimd_loop_body;
  }
}
```
The problem with this is that this invalidates the CanonicalLoopInfo
structure to be processed by the wsloop later. To avoid this, in this
patch I preserve the original loop, moving the IF clause inside of the
loop:
```
while (...) {
  if (cond) {
    simd_loop_body;
  } else {
    non_simd_loop_body;
  }
}
```
On simple examples I tried LLVM was able to hoist the if condition
outside of the loop at -O3.

The disadvantage of this is that we cannot add the
llvm.loop.vectorize.enable attribute on either the SIMD or non-SIMD
loops because they both share a loop back edge. There's no way of
solving this without keeping the old design of having two different
loops: which cannot be represented using only one CanonicalLoopInfo
structure. I don't think the presence or absence of this attribute makes
much difference. In my testing it is the llvm.loop.parallel_access
metadata which makes the difference to vectorization. LLVM will
vectorize if legal whether or not this attribute is there in the TRUE
branch. In the FALSE branch this means the loop might be vectorized even
when the condition is false: but I think this is still standards
compliant: OpenMP 6.0 says that when the if clause is false that should
be treated like the SIMDLEN clause is one. The SIMDLEN clause is defined
as a "hint". For the same reason, SIMDLEN and SAFELEN clauses are
silently ignored when SIMD IF is used.

I think it is better to implement SIMD IF and ignore SIMDLEN and SAFELEN
and some vectorization encouragement metadata when combined with IF than
to ignore IF because IF could have correctness consequences whereas the
rest are optimiztion hints. For example, the user might use the IF
clause to disable SIMD programatically when it is known not safe to
vectorize the loop. In this case it is not at all safe to add the
parallel access or SAFELEN metadata.
2025-07-15 10:30:02 +01:00
David Green
58d79aaba6
[AArch64] Guard against non-simple types in udiv sve costs. (#148580)
The code here probably needs to change to handle types more uniformly,
but this patch prevents it from trying to use a simple type where it does
not exist.

Fixes #148438.
2025-07-15 10:25:08 +01:00
Konstantin Varlamov
7345508c6f
[libc++][hardening] Introduce assertion semantics (#148268)
Assertion semantics closely mimic C++26 Contracts evaluation semantics.
This brings our implementation closer in line with C++26 Library
Hardening (one particular benefit is that using the `observe` semantic
makes adopting hardening easier for projects).
2025-07-15 02:14:30 -07:00
Vikram Hegde
aa0629dabe
[CodeGen][NPM] Read TargetMachine's EnableIPRA option (#148108)
same as https://github.com/llvm/llvm-project/pull/138670,

Co-authored-by : Oke, Akshat
<[Akshat.Oke@amd.com](mailto:Akshat.Oke@amd.com)>
2025-07-15 14:43:07 +05:30
WhatAmISupposedToPutHere
8aeab8faee
[Driver][MinGW] Allow using clang driver to link ARM64X PEs. (#148064)
Similar to how clang-cl driver does it, make it possible to build arm64x
binaries with a mingw-style invocation.

Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
2025-07-15 12:01:36 +03:00
David Sherwood
c363a3f9c8
[LV] Ensure getScaledReductions only matches extends inside the loop (#148264)
In getScaledReductions for the case where we try to match a partial
reduction of the form:

%phi = phi i32 ...
...
%add = add i32 %phi, %zext

where

%zext = i8 %some_val to i32

we should ensure that %zext is actually inside the loop.

Fixes https://github.com/llvm/llvm-project/issues/148260
2025-07-15 09:54:58 +01:00
Keno Fischer
69ea174bf0
llvm-shlib: Fix mingw dll exports (#148772)
In c87d198cd964f37343083848f8fdd58bb0b00156, the `__jit_debug_*` symbols
gained explicit dllexport annotations. Unfortunately, mingw's linkers
have a quirk where the presence of any dllexport symbols at all will
switch off the `-export-all-symbols` flag, so without a full conversion
to dllexport annotations (#109483), the mingw LLVM dll build is broken
in LLVM 20+ when building with GCC (when building with clang,
LLVM_ALWAYS_EXPORT expands to the default visibility attribute,
see extended discussion in #148772).
Fix this by adding the flag explicitly as was done for
clang-shlib earlier in https://reviews.llvm.org/D151620.
2025-07-15 04:54:28 -04:00
Ziqing Luo
29436737ba
[NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (#145626)
Refactor the safe pattern analysis of pointer and size expression pairs
so that the check can be re-used in more places. For example, it can be
used to check whether the following cases are safe:
- `std::span<T>{ptr, size}        // span construction`
- `snprintf(ptr, size, "%s", ...)  // unsafe libc call`
- `printf("%.*s", size, ptr)        // unsafe libc call`
2025-07-15 16:48:20 +08:00