544916 Commits

Author SHA1 Message Date
Orlando Cazalet-Hyams
c568a207d8 [KeyInstr] Fix verifier check (#149043)
The verifier check was in the wrong place, meaning it wasn't actually
checking many instructions.

Fixing that causes a test failure (coro-dwarf-key-instrs.cpp) because
coros turn off the feature but still annotate instructions with the
metadata (which is a supported situation, but the verifier doesn't like
it, and it's hard to teach the verifier to like it).

Fix that by avoiding emitting any key instruction metadata if the
DISubprogram has opted out of key instructions.

(cherry picked from commit 653872f782e1faaabc1da23769e6b35b10e74bde)
2025-07-24 11:48:40 +02:00
mintsuki
756f489266 LoongArch: Improve detection of valid TripleABI (#147952)
If the environment is considered to be the triple component as a whole,
so, including the object format, if any, and if that is the intended
behaviour, then the loongarch64 function `computeTargetABI()` should be
changed to not rely on `hasEnvironment()`, but, rather, to check if
there is a non-unknown environment set.

Without this change, using a (ideally valid) target of
loongarch64-unknown-none-elf, with a manually specified ABI of lp64s,
will result in a completely superfluous warning:

```
warning: triple-implied ABI conflicts with provided target-abi 'lp64s', using target-abi
```

(cherry picked from commit 9ed8816dc63776259d2190bdc8a7a29698c62749)
2025-07-22 10:44:55 +02:00
Alexandre Ganea
aaaa54269b [LLD][COFF] Follow up comments on pr146610 (#147152)
This is a follow-up PR for post-commit comments in
https://github.com/llvm/llvm-project/pull/146610

- Changed "exporteddllmain" references to "importeddllmain".
- Add support for x86 target and test coverage.
- Changed a comment to better express why we're skipping importing
`DllMain`.

(cherry picked from commit fcacd4e880c9a0b3f2bdaa43603aeddfa1b1cd2e)
2025-07-22 10:44:33 +02:00
Hervé Poussineau
3d520be273 [Mips] Correctly define IntPtrType (#145158)
Mips was the only architecture having PtrDiffType = SignedInt and
IntPtrType = SignedLong

This fixes a problem on mipsel-windows-gnu triple, where uintptr_t was
wrongly defined as unsigned long instead of unsigned int, leading to
problems in compiler-rt.

compiler-rt/lib/interception/interception_type_test.cpp:24:17: error:
static assertion failed due to requirement
'__sanitizer::is_same<unsigned long, unsigned int>::value':
24 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::uptr,
::uintptr_t>::value));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44:
note: expanded from macro 'COMPILER_CHECK'
      369 | #define COMPILER_CHECK(pred) static_assert(pred, "")
          |                                            ^~~~
compiler-rt/lib/interception/interception_type_test.cpp:25:17: error:
static assertion failed due to requirement '__sanitizer::is_same<long,
int>::value':
25 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::sptr,
::intptr_t>::value));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44:
note: expanded from macro 'COMPILER_CHECK'
      369 | #define COMPILER_CHECK(pred) static_assert(pred, "")
          |                                            ^~~~
compiler-rt/lib/interception/interception_type_test.cpp:27:17: error:
static assertion failed due to requirement '__sanitizer::is_same<long,
int>::value':
27 | COMPILER_CHECK((__sanitizer::is_same<::PTRDIFF_T,
::ptrdiff_t>::value));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44:
note: expanded from macro 'COMPILER_CHECK'
      369 | #define COMPILER_CHECK(pred) static_assert(pred, "")

(cherry picked from commit 13906724ff7aa1bc58202faac62690570dfe0dc3)
2025-07-22 10:44:08 +02:00
hev
7fd16eecf8 [LoongArch] Fix failure to widen operand for [X]VMSK{LT,GE,NE}Z (#149442)
Reported-by: tangyan <tangyan01@loongson.cn>
(cherry picked from commit 8a307ae61963a3f967052f7ea3c89aafa56934cf)
2025-07-22 10:43:28 +02:00
Timothy Herchen
25c1d7a357 [clang] Don't warn on zero literals with -std=c2y (#149688)
Fixes #149669; the old check compared with the end of the literal, but
we can just check that after parsing digits, we're pointing to one
character past the token start.

(cherry picked from commit 8366dc207a2e6b50cb8afe2d98fca68bd78bd0fa)
2025-07-22 10:43:04 +02:00
Abinaya Saravanan
17658dbedd [HEXAGON] Add AssertSext in sign-extended mpy (#149061)
The pattern i32xi32->i64, should be matched to the sign-extended
multiply op, instead of explicit sign- extension of the operands
followed by non-widening multiply (this takes 4 operations instead of
one). Currently, if one of the operands of multiply inside a loop is a
constant, the sign-extension of this constant is hoisted out of the loop
by LICM pass and this pattern is not matched by the ISEL.

This change handles multiply operand with Opcode of the type AssertSext
which is seen when the sign-extension is hoisted out-of the loop.
Modifies the DetectUseSxtw() to check for this.

(cherry picked from commit fcabb53f0c349885167ea3d0e53915e6c42271a7)
2025-07-22 10:39:51 +02:00
Sudharsan Veeravalli
cb92bc511e [RISCV] Swap source register operands in QC_SHLADD ISEL patterns (#149697)
The instruction does `rd = (rs1 << shamt) + rs2` but the ISEL patterns
had `rs1` and `rs2` the other way around which is incorrect.

(cherry picked from commit 84e689b1db02be1687c3093d66ace913250780bd)
2025-07-22 10:39:03 +02:00
Koakuma
5c69f70244 [SPARC][Driver] Move feature mode selection to Arch/Sparc.cpp (#149652)
This is so that it's performed also for flang and not just for clang.

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

(cherry picked from commit 38fc453afdb6a4511b7c8e189f12a92559ecc396)
2025-07-22 10:38:31 +02:00
Brian Cain
51245ebda1 [lld] [hexagon] guard allocateAux: only if idx nonzero (#149690)
While building libclang_rt.asan-hexagon.so, lld would assert in
lld:🧝:hexagonTLSSymbolUpdate().

Fixes #132766

(cherry picked from commit 3e9ceae29f39456508eef5b4af4d3c895048706a)
2025-07-22 10:37:04 +02:00
Michał Górny
275fa26b0c Revert "[libclc] Add prepare-<triple> targets (#146700)"
This reverts commit 85d09de5fa19a32bbcc400928d55f9d633077640. This
change caused broken symlinks in the build directory, and the subsequent
commits fixing that introduced other issues.
2025-07-22 10:35:08 +02:00
Michał Górny
7814dca9a8 Revert "[libclc] Make library output directories explicit (#146833)"
This reverts commit 81e6552a3d6835c4e10eb981402febfac9df6156. This
change caused libclc to start installing broken symlinks that contain
absolute paths to the build directory rather than relative paths
within the install directory.
2025-07-22 10:35:07 +02:00
Michał Górny
b475893a15 Revert "[libclc] Fix target dependency"
This reverts commit 222e795347c14afce49df1540926f3a1ae493de4.
2025-07-22 10:35:07 +02:00
Michał Górny
69ee6a0edd Revert "[libclc] Change symlinks to copies on Windows (#147759)"
This reverts commit 9b5959dd9a0eb0fc005b92be7ef7f3a5e3377b81.
2025-07-22 10:35:07 +02:00
Michał Górny
68cae18965 Revert "[libclc] Move CMake for prepare_builtins to a subdirectory (#148815)"
This reverts commit 8a7a64873b13e6fd931b748fbf50b3da26fe7fca.  It broke
standalone builds since the necessary variables are now limited in scope
to `libclc/utils` while they are used in the top-level CMakeLists.
2025-07-22 10:35:07 +02:00
quic-areg
b5043a0940 [Hexagon][llvm-objdump] Improve disassembly of Hexagon bundles (#145807)
Hexagon instructions are VLIW "bundles" of up to four instruction words
encoded as a single MCInst with operands for each sub-instruction.
Previously, the disassembler's getInstruction() returned the full
bundle, which made it difficult to work with llvm-objdump.

For example, since all instructions are bundles, and bundles do not
branch, branch targets could not be printed.

This patch modifies the Hexagon disassembler to return individual
sub-instructions instead of entire bundles, enabling correct printing of
branch targets and relocations. It also introduces
`MCDisassembler::getInstructionBundle` for cases where the full bundle
is still needed.

By default, llvm-objdump separates instructions with newlines. However,
this does not work well for Hexagon syntax:

  { inst1
    inst2
    inst3
    inst4 <branch> } :endloop0

Instructions may be followed by a closing brace, a closing brace with
`:endloop`, or a newline. Branches must appear within the braces.

To address this, `PrettyPrinter::getInstructionSeparator()` is added and
overridden for Hexagon.

(cherry picked from commit ac7ceb3dabfac548caa993e7b77bbadc78af4464)
2025-07-22 10:34:17 +02:00
Jannick Kremer
0da291f8a6 Revert "Move python binding tests to lit framework" (#149012)
This reverts commit f8707f994af2582f6dc58190106946efeb43bf05.

(cherry picked from commit 7a9bef0166951a61bc7094514a20471ae45f6090)
2025-07-22 10:33:35 +02:00
Aiden Grossman
cbe68e5140 [libcxx] Switch to release branch runners
This ensures that if/when we bump the toolchain versions in the main
container that we do not break tests on the release branch.
2025-07-22 10:32:35 +02:00
clubby789
186df07d01 [DSE] Remove uninitialized from allockind when creating dummy zeroed variant function (#149336)
cc https://github.com/llvm/llvm-project/pull/138299

rustc sets `allockind("uninitialized")` - if we copy the attributes
as-is when creating a dummy function, Verify complains about
`allockind("uninitialized,zeroed")` conflicting, so we need to clear the
flag.

Co-authored-by: Jamie Hill-Daniel <jamie@osec.io>
(cherry picked from commit 74c396afb26dec74c0b799e218c63f1a26e90d21)
2025-07-22 10:31:55 +02:00
Owen Pan
607677c861 [clang-format] Fix a regression of annotating PointerOrReference (#149039)
Fixes #149010

(cherry picked from commit a8f5e9ed6b44562938ce07e2790be90be8f0a6b5)
2025-07-22 10:31:35 +02:00
Tomohiro Kashiwada
e36a7daae2 [Support/BLAKE3] quick fix for Cygwin build (#148635)
BLAKE3 1.8.2 ( imported in d2ad63a193216d008c8161879a59c5f42e0125cc )
fails to build for the Cygwin target.

see: https://github.com/BLAKE3-team/BLAKE3/issues/494

As a temporary workaround, add `&& !defined(__CYGWIN__)` to BLAKE3
locally.

resolves https://github.com/llvm/llvm-project/issues/148365

(cherry picked from commit 8de61eb01c9752f0488ed8b52d01fe3d0873ff6c)
2025-07-22 10:30:43 +02:00
Tobias Hieta
f1846e747d Use Parallel xz for test-suite sources. (#149389)
(cherry picked from commit 867ff3001e4e1e68b3f26c5ead281ea2208c4c48)
2025-07-22 10:30:13 +02:00
Peter Collingbourne
728030a452 compiler-rt: test: Use the host instead of the target to select %expect_crash.
When running tests in a cross-compiled build, %expect_crash is
run on the host, not the target, so we need to check the host
OS. config.host_os surprisingly refers to the target OS because it
is derived from CMAKE_SYSTEM_NAME which specifies the target. See:
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html

Another speculative fix for:
https://lab.llvm.org/buildbot/#/builders/193/builds/9070

(cherry picked from commit 968d38d1d7d9de2d5717457876bba2663b36f620)
2025-07-22 10:29:54 +02:00
Raphael Moreira Zinsly
1abeeabd65 [RISCV] Pass the MachineInstr flag as argument to allocateStack (#147531)
When not in the prologue we do not want to set the FrameSetup flag, by
passing the flag as argument we can use allocateStack correctly on those
cases.
This fixes the allocation and probe in eliminateCallFramePseudoInstr.

(cherry picked from commit 1db9eb23209826d9e799e68a9a4090f0328bf70c)
2025-07-21 18:54:42 +02:00
Tobias Hieta
cbcb48a88c Bump version to 21.1.0-rc1 llvmorg-21.1.0-rc1 2025-07-17 21:02:34 +02:00
Corentin Jabot
7ac3c62282 Revert "[Clang] Do not treat Foo -> const Foo conversion sequences as perfect" (#149272)
Reverts llvm/llvm-project#148613

Considering object argument conversion qualifications perfect leads to
situations where we prefer a non-template const qualified function over
a non-qualified template function, which is very wrong indeed.

I explored solutions to work around that, but instead, we might want to
go the GCC road and prefer the friend overload in the #147374 example,
as this seems a lot more consistent and reliable

(cherry picked from commit 28e1e7e1b4b059a2e42f68061475cddb4ad0a6a3)
2025-07-17 18:00:22 +02:00
Sirraide
dd7710b7fd [Clang] Reintroduce obsolete symbols in libclang.map (#149190)
This is a follow-up to #149079. Seems like we forgot about the fact that
the symbols also need to be in `libclang.map`.

(cherry picked from commit 7e0fde0c2f6b0b9d727ce9196956b36e91961ac4)
2025-07-17 17:59:42 +02:00
Yuxuan Chen
ad9051049d [Clang] Fix FE crash during CGCoroutine GRO Alloca Emission (#148962)
Fixes: https://github.com/llvm/llvm-project/issues/148953

Currently when coroutine return object type is const qualified, we don't
do direct emission. The regular emission logic assumed that the auto var
emission will always result in an `AllocaInst`. However, based on my
findings, NRVO var emissions don't result in `AllocaInst`s. Therefore,
this
[assertion](1a940bfff9/clang/lib/CodeGen/CGCoroutine.cpp (L712))
will fail.

Since the NRVOed returned object don't live on the coroutine frame, we
won't have the problem of it outliving the coroutine frame, therefore,
we can safely omit this metadata.

(cherry picked from commit c36156de45a0f5e24e7a4ee2259c3302ea814785)
2025-07-17 17:56:53 +02:00
Eli Friedman
2067574f54 [clang] Fix pointer comparisons between pointers to constexpr-unknown (#147663)
A constexpr-unknown reference can be equal to an arbitrary value, except
values allocated during constant evaluation. Fix the handling.

The standard is unclear exactly which pointer comparisons count as
"unknown" in this context; for example, in some cases we could use
alignment to prove two constexpr-unknown references are not equal. I
decided to ignore all the cases involving variables not allocated during
constant evaluation.

While looking at this, I also spotted that there might be issues with
lifetimes, but I didn't try to address it.

(cherry picked from commit 20c8e3c2a4744524396cc473a370cfb7855850b6)
2025-07-17 17:56:24 +02:00
Jonas Devlieghere
38158a93d8 [lldb] Document MCP tools & resources (#148708)
Add documentation for the tools and resources exposed by LLDB's MCP
server.

(cherry picked from commit e8dc96d9de14c4b2317b11b8bc6e9310113697b3)
2025-07-17 12:40:58 +02:00
Jonas Devlieghere
68e17aec8f [lldb] Add a release note for MCP support 2025-07-17 12:35:56 +02:00
Nikita Popov
194dd6679f [Support][BLAKE3] Restore static on blake3_hash4_neon (#149046)
This was dropped in #147948 and causes symbol conflicts if libblake3 is
also linked.

(cherry picked from commit 1754a7d5733d5305e4ec25ef0945b39d6882bb28)
2025-07-17 12:26:26 +02:00
Matt Arsenault
7c2c20dd9c RuntimeLibcalls: Fix calling conv of win32 div libcalls (#149098)
There's probably an existing test this should be added to,
but our test coverage is really bad that this wasn't caught
by one.

(cherry picked from commit 0110168f6aa5c8a8d02ffd9e62c7929ce6d24d26)
2025-07-17 10:29:47 +02:00
Aiden Grossman
46c566f579 [CI][Github] Switch windows to server 2022 (#148743)
This patch switches the windows testing over to server 2022 by switching
to the recently introduced runner set.

(cherry picked from commit 3248a6d76abccbbe78e853c76bc022b70d594347)
2025-07-17 10:29:31 +02:00
Sirraide
6ee4eedc2a [Clang] Reintroduce obsolete libclang symbols to avoid an ABI break (#149079)
For more context, see
https://github.com/llvm/llvm-project/pull/119269#issuecomment-3075444493,
but briefly, when removing ARCMigrate, I also removed some symbols in
libclang, which constitutes an ABI break that we don’t want, so this pr
reintroduces the removed symbols; the declarations are marked as
deprecated for future removal, and the implementations print an error
and do nothing, which is what we used to do when ARCMigrate was
disabled.

(cherry picked from commit 1600450f9098e5c9cb26840bd53f1be8a2559b7d)
2025-07-17 10:29:12 +02:00
Jordan Rupprecht
adb453c8a6 [Support][BLAKE3] Prefix more blake3 methods (#149007)
Added by #147948, blake3_xof_many and blake3_compress_subtree_wide cause
conflicts when linking llvm and blake3 statically into the same binary.
Similar to #148607.

(cherry picked from commit 60579ec3059b2b6cc9dad90eaac1ed363fc395a7)
2025-07-17 10:28:09 +02:00
Eli Friedman
04d4be501d [libclang] Fix version for symbol clang_visitCXXMethods (#148958)
Happened to spot this while looking at libclang.map for other reasons.
clang_visitCXXMethods was added in LLVM 21, not LLVM 20.

(cherry picked from commit 116110e1a93531a64d82f049b6e36403bc14f278)
2025-07-17 10:27:47 +02:00
Sudharsan Veeravalli
b71c9a4366 [RISCV] Fix issues in ORI to QC.INSBI transformation (#148809)
The transformation done in #147349 was incorrect since we were not
passing the input node of the `OR` instruction to the `QC.INSBI`
instruction leading to the generated instruction doing the wrong thing.
In order to do this we first needed to add the output register to
`QC.INSBI` as being both an input and output.

The code produced after the above fix will need a copy (mv) to preserve
the register input to the OR instruction if it has more than one use
making the transformation net neutral ( `6-byte QC.E.ORI/ORAI` vs
`2-byte C.MV + 4-byte QC.INSB`I). Avoid doing the transformation if
there is more than one use of the input register to the OR instruction.

(cherry picked from commit d67d91a9906366585162cebf292f923a3f28c8a6)
2025-07-17 10:27:16 +02:00
Craig Topper
49722f1df1 [RISCV] Remove incorrect and untested FrameIndex support from SelectAddrRegImm9. (#148779)
To fold a FrameIndex, we need to teach eliminateFrameIndex to respect
the uimm9 range.

(cherry picked from commit 63d099af146a19bc8fd5a791d6184125e6cc42e7)
2025-07-17 10:26:45 +02:00
Krzysztof Parzyszek
a0895b4581 [Frontend][OpenMP] Move isPrivatizingClause to OMP.h, NFC (#148644) 2025-07-16 16:17:00 +02:00
Sjoerd Meijer
7d803c868a [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-16 16:17:00 +02:00
Sander de Smalen
d1517ec622 [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-16 16:17:00 +02:00
Sander de Smalen
588b813079 [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-16 16:17:00 +02:00
Martin Erhart
18624ae54b [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-16 16:16:59 +02:00
Tobias Hieta
6296ebd45d Bump version to 21.1.0-git 2025-07-15 15:59:05 +02: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