Commit Graph

538361 Commits

Author SHA1 Message Date
David Green
a2aa88192f [GlobalISel] Add a update_givaluetracking_test_checks.py script (#140296)
As with the other update scripts this takes the output of
-passes=print<gisel-value-tracking> and inserts the results into an
existing mir file. This means that the input is a lot like
update_analysis_test_checks.py, and the output needs to insert into a
mir file similarly to update_mir_test_checks.py. The code used to do the
inserting has been moved to common, to allow it to be reused. Otherwise
it tries to reuse the existing infrastructure, and
update_givaluetracking_test_checks is kept relatively short.
2025-05-22 09:06:37 +01:00
Hans Wennborg
213d0d2233 [pdb] Provide a better error message when overflowing the public/global symbol record stream (#140884)
Before:

lld-link: error: Stream Error: The stream is too short to perform the requested operation.
lld-link: error: failed to write PDB file ./unit_tests.exe.pdb

After:

lld-link: error: the public (2127832912 bytes) and global (2200532960 bytes) symbols
are too large to fit in a PDB file; the maximum total is 4294967295 bytes.
lld-link: error: failed to write PDB file ./unit_tests.exe.pdb
2025-05-22 09:31:35 +02:00
jeanPerier
1f5b6ae89f [flang] optionally add lifetime markers to alloca created in stack-arrays (#140901)
Flang at Ofast usually produces executables that consume more stack that
other Fortran compilers.
This is in part because the alloca created from temporary heap
allocation by the StackArray pass are created at the function scope
level without lifetimes, and LLVM does not/is not able to merge alloca
that do not have overlapping lifetimes.

This patch adds an option to generate LLVM lifetime in the StackArray
pass at the previous heap allocation/free using the LLVM dialect
operation for it.
2025-05-22 09:26:14 +02:00
Michele Scuttari
72a8893689 Revert "[MLIR] Add bufferization state class to OneShotBufferization pass" (#141012)
Reverts llvm/llvm-project#138143

The PR for the BufferizationState is temporarily reverted due to API incompatibilities that have been initially missed during the update and were not catched by PR checks.
2025-05-22 09:25:07 +02:00
David Green
11953c647b [ARM] Remove kill flags in ReplaceConstByVPNOTs. (#140082)
This is similar to #86300. The vpr register on this branch might be
killed before we reuse it.
2025-05-22 08:24:01 +01:00
Fangrui Song
de095230d4 [X86] Improve @gotpcrel on local symbol tests
Test shouldForceRelocation change in 4fdcde56a5
2025-05-22 00:19:45 -07:00
Florian Hahn
95ba5508e5 Reapply "[VPlan] Move predication to VPlanTransform (NFC). (#128420)"
This reverts commit 793bb6b257.

The recommitted version contains a fix to make sure only the original
phis are processed in convertPhisToBlends nu collecting them in a vector
first. This fixes a crash when no mask is needed, because there is only
a single incoming value.

Original message:
This patch moves the logic to predicate and linearize a VPlan to a
dedicated VPlan transform. It mostly ports the existing logic directly.

There are a number of follow-ups planned in the near future to
further improve on the implementation:
* Edge and block masks are cached in VPPredicator, but the block masks
are still made available to VPRecipeBuilder, so they can be accessed
during recipe construction. As a follow-up, this should be replaced by
adding mask operands to all VPInstructions that need them and use that
during recipe construction.
* The mask caching in a map also means that this map needs updating each
time a new recipe replaces a VPInstruction; this would also be handled
by adding mask operands.

PR: https://github.com/llvm/llvm-project/pull/128420
2025-05-22 08:16:15 +01:00
Michele Scuttari
67fc1660d9 [MLIR] Add bufferization state class to OneShotBufferization pass (#138143)
This PR is a follow-up on #138125, and adds a bufferization state class providing information about the IR. The information currently consists of a cached list of symbol tables, which aims to solve the quadratic scaling of the bufferization task with respect to the number of symbols. The PR breaks API compatibility: the `bufferize` method of the `BufferizableOpInterface` has been enriched with a reference to a `BufferizationState` object.

The bufferization state must be kept in a valid state by the interface implementations. For example, if an operation with the `Symbol` trait is inserted or replaced, its parent `SymbolTable` must be updated accordingly (see, for example, the bufferization of `arith::ConstantOp`, where the symbol table of the module gets the new global symbol inserted). Similarly, the invalidation of a symbol table must be performed if an operation with the `SymbolTable` trait is removed (this can be performed using the `invalidateSymbolTable` method, introduced in #138014).
2025-05-22 08:53:38 +02:00
Fangrui Song
4fdcde56a5 [X86] Define shouldForceRelocation
Somehow needed by LTO/X86/cfi_jt_aliases.ll

Fixes: 6f6dc1f239
2025-05-21 23:52:54 -07:00
Jim Lin
04211ba727 [RISCV] Add FeatureVendorXAndesPerf to Andes N45/NX45/A45/AX45 (#141007)
Andes N45/NX45/A45/AX45 also support XAndesPerf.
2025-05-22 14:41:58 +08:00
Pavel Labath
53a5bea0ad [lldb] Call Target::ClearAllLoadedSections even earlier (#140228)
This reapplies https://github.com/llvm/llvm-project/pull/138892, which
was reverted in

5fb9dca14a
due to failures on windows.

Windows loads modules from the Process class, and it does that quite
early, and it kinda makes sense which is why I'm moving the clearing
code even earlier.

The original commit message was:

Minidump files contain explicit information about load addresses of
modules, so it can load them itself. This works on other platforms, but
fails on darwin because DynamicLoaderDarwin nukes the loaded module list
on initialization (which happens after the core file plugin has done its
work).

This used to work until
https://github.com/llvm/llvm-project/pull/109477, which enabled the
dynamic loader
plugins for minidump files in order to get them to provide access to
TLS.

Clearing the load list makes sense, but I think we could do it earlier
in the process, so that both Process and DynamicLoader plugins get a
chance to load modules. This patch does that by calling the function
early in the launch/attach/load core flows.

This fixes TestDynamicValue.py:test_from_core_file on darwin.
2025-05-22 08:32:11 +02:00
Younan Zhang
bf6d24a34d [Clang] Do not defer variable template instantiation for undeduced types (#141009)
The previous approach broke the instantiation convention for templated
substitutions, as we were attempting to instantiate the initializer
even when it was still dependent.

We deferred variable template instantiation until the end of the TU.
However, type deduction requires the initializer immediately,
similar to how constant evaluation does.

Fixes https://github.com/llvm/llvm-project/issues/140773
Fixes #135032
Fixes #134526

Reapplies https://github.com/llvm/llvm-project/pull/138122
2025-05-22 14:05:52 +08:00
Adrian Kuegel
e8ecd2cf94 Revert "[llvm][Bazel] Adjust according to changes in 4cfbe55"
This reverts commit 67f4d841f0.
2025-05-22 05:58:26 +00:00
Fangrui Song
6f6dc1f239 [MC] Restore MCAsmBackend::shouldForceRelocation to false
Revert the Target.getSpecifier implementation
(38c3ad36be) and update SystemZAsmBackend
instead.

Many targets with %lo/%hi style specifiers (SPARC, MIPS, PowerPC,
RISC-V) do not force relocations for these specifiers.

Additionally, with the introduction of the addReloc hook,
shouldForceRelocation is not that necessary and should probably be
phased out.
2025-05-21 22:51:51 -07:00
jeremyd2019
7857543a63 [LLVM][Cygwin] add workaround for blocking connect/accept in AF_UNIX sockets (#140353)
On Cygwin, UNIX sockets involve a handshake between connect and accept
to enable SO_PEERCRED/getpeereid handling. This necessitates accept
being called before connect can return, but at least the tests in
llvm/unittests/Support/raw_socket_stream_test do both on the same thread
(first connect and then accept), resulting in a deadlock. Add a call to
both places sockets are created that turns off the handshake (and
SO_PEERCRED/getpeereid support).

References:
* cec8a6680e/winsup/cygwin/fhandler/socket_local.cc (L1462-L1471)
* https://inbox.sourceware.org/cygwin/Z_UERXFI1g-1v3p2@calimero.vinschen.de/T/#u
2025-05-22 08:15:21 +03:00
jeremyd2019
ba4bd3f46e [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds (#138587)
In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang
standalone against an installed LLVM this definition was not picked up,
resulting in undefined strnlen. Follow the documentation in
https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project and add
the LLVM_DEFINITIONS in standalone projects' cmakes.
2025-05-22 08:14:13 +03:00
Fangrui Song
53edb1a160 [test] Improve linker-relaxable fixups tests
The behavior will change once the assembler improves (#140692)
2025-05-21 22:08:55 -07:00
Jim Lin
8b2c013564 [RISCV] Use print-enabled-extensions to check the extensions of Andes n45/nx45/a45/ax45 cpus. NFC. (#140979)
Similarly to what #137725 did for the SiFive P870.
2025-05-22 13:04:30 +08:00
Mohammad Bashir
bcdce987c0 Fix regression tests with bad FileCheck checks (#140373)
Fixes https://github.com/llvm/llvm-project/issues/140149
2025-05-22 07:59:57 +03:00
Kewen12
851da60304 Revert "[LLVM] Use reportFatalUsageError for LTO usage errors" (#141000)
The PR causes check-lld fail:
>TEST 'lld :: COFF/lto-cache-errors.ll'

Tested on local revert and pass the check. 

Reverts llvm/llvm-project#140955
2025-05-22 00:07:38 -04:00
Kazu Hirata
6074d83664 [mlir] Remove unused local variables (NFC) (#140990) 2025-05-21 20:33:53 -07:00
Kazu Hirata
7ffa49111a [lldb] Remove unused local variables (NFC) (#140989) 2025-05-21 20:33:35 -07:00
Kazu Hirata
bf241e8349 [clang] Avoid creating temporary instances of std::string (NFC) (#140988)
lookupTarget takes StringRef and internally creates an instance of
std::string with the StringRef as part of constructing Triple, so we
don't need to create temporary instances of std::string on our own.
2025-05-21 20:33:06 -07:00
Luke Lau
09c3d1432b [IA] Add support for [de]interleave{3,5,7} (#139373)
This adds support for lowering deinterleave and interleave intrinsics
for factors 3 5 and 7 into target specific memory intrinsics.

Notably this doesn't add support for handling higher factors constructed
from interleaving interleave intrinsics, e.g. factor 6 from interleave3
+ interleave2.

I initially tried this but it became very complex very quickly. For
example, because there's now multiple factors involved
interleaveLeafValues is no longer symmetric between interleaving and
deinterleaving. There's then also two ways of representing a factor 6
deinterleave: It can both be done as either 1 deinterleave3 and 3
deinterleave2s OR 1 deinterleave2 and 3 deinterleave3s.

I'm not sure the complexity of supporting arbitrary factors is warranted
given how we only need to support a small number of factors currently:
SVE only needs factors 2,3,4 whilst RVV only needs 2,3,4,5,6,7,8.

My preference would be to just add a interleave6 and deinterleave6
intrinsic to avoid all this ambiguity, but I'll defer this discussion to
a later patch.
2025-05-22 04:32:47 +01:00
Kazu Hirata
0641ca1cd2 [BOLT] Avoid creating a temporary instance of std::string (NFC) (#140987)
lookupTarget takes StringRef and internally creates an instance of
std::string with the StringRef as part of constructing Triple, so we
don't need to create a temporary instance of std::string on our own.
2025-05-21 20:32:40 -07:00
Kazu Hirata
7e4e33e90e [mlir] Use llvm::is_contained (NFC) (#140986) 2025-05-21 20:32:28 -07:00
Kazu Hirata
7c8b39740b [BOLT] Use llvm::is_contained (NFC) (#140984) 2025-05-21 20:32:09 -07:00
Kazu Hirata
6d2a7b4546 [clang] Use llvm::find_if (NFC) (#140983) 2025-05-21 20:31:52 -07:00
Yingwei Zheng
287294d54d [ConstraintElim] Do not allow overflows in Decomposition (#140541)
Consider the following case:
```
define i1 @pr140481(i32 %x) {
  %cond = icmp slt i32 %x, 0
  call void @llvm.assume(i1 %cond)
  %add = add nsw i32 %x, 5001000
  %mul1 = mul nsw i32 %add, -5001000
  %mul2 = mul nsw i32 %mul1, 5001000
  %cmp2 = icmp sgt i32 %mul2, 0
  ret i1 %cmp2
}
```
Before this patch, `decompose(%mul2)` returns `-25010001000000 * %x +
4052193514966861312`.
Therefore, `%cmp2` will be simplified into true because `%x s< 0 &&
-25010001000000 * %x + 4052193514966861312 s<= 0` is unsat.

It is incorrect since the offset `-25010001000000 * 5001000 ->
4052193514966861312` signed wraps.
This patch treats a decomposition as invalid if overflows occur when
computing coefficients.

Closes https://github.com/llvm/llvm-project/issues/140481.
2025-05-22 11:31:04 +08:00
Sudharsan Veeravalli
f72a8ee489 [RISCV] Add Xqcibi Select_GPR_Using_CC_<Imm> Pseudos to isSelectPseudo (#140698)
Not adding them was leading to a crash when trying to expand these
pseudo instructions.

I've also fixed the register class types for the Xqcibi instructions in
these pseudo instructions which was incorrect and was exposed by the
machine verifier while running the test case added in this patch.

Fixes #140697
2025-05-22 08:57:26 +05:30
Owen Pan
d5d8d8ac76 [clang-format][NFC] Minor efficiency cleanup (#140835) 2025-05-21 20:24:56 -07:00
Matt
94fdeb7686 [clang] Mark some language options as benign. (#131569)
I'm fairly certain that the options in this CL are benign, as I don't
believe they affect the AST.
* RTTI - shouldn't affect the AST, should only affect codegen
* Trivial var init - also should only affect codegen
* Stack protector - also codegen
* Exceptions - Since exceptions do allow new things in the AST, but I'm
pretty sure that they can differ in parent and child safely, I marked it
as compatible instead.

I welcome any input from someone more familiar with this than me, as I
might be wrong.
2025-05-22 11:22:12 +08:00
Pat Doyle
4fd48ac9ae [test] Fix dissassemble-entry-point.s for #140187 (#140978)
similar to #140570

getting this error:

exit status 1
ld.lld: error: section '.text' address (0x8074) is smaller than image
base (0x10000); specify --image-base
2025-05-21 20:21:18 -07:00
Paul Kirth
f0ddadf12c Revert "[Clang] Fix missed initializer instantiation bug for variable templates" (#140930)
Reverts llvm/llvm-project#138122

The patch causes a regression and prevents compiling valid C++ code. 
The code was accepted by earlier versions of clang and GCC. 
See https://github.com/llvm/llvm-project/issues/140773 for details.
2025-05-22 11:01:06 +08:00
Jim Lin
569b6f6dad [RISCV] Add Andes A25/AX25 processor definition (#140681)
Andes A25/AX25 are 32/64bit, 5-stage pipeline, linux-capable CPUs that
implement the RV[32|64]IMAFDC_Zba_Zbb_Zbc_Zbs ISA extensions. They are
developed by Andes Technology https://www.andestech.com, a RISC-V IP
provider.

The overviews for A25/AX25:
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-a25/
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-ax25/

Scheduling model will be implemented in a later PR.
2025-05-22 09:22:32 +08:00
Craig Topper
0a42db682a [SelectionDAG] Simplify creation of getStoreVP in WidenVecOp_STORE. NFC
We can use the offset from the original store instead of creating
a new undef offset.

We didn't check if the offset was undef already so we really shouldn't
drop it if it isn't.
2025-05-21 17:46:08 -07:00
Lucas Ramirez
1b34722302 [AMDGPU] Fix computation of waves/EU maximum (#140921)
This fixes an issue in the waves/EU range calculation wherein, if the
`amdgpu-waves-per-eu` attribute exists and is valid, the entire
attribute may be spuriously and completely ignored if workgroup sizes
and LDS usage restrict the maximum achievable occupancy below the
subtarget maximum. In such cases, we should still honor the requested
minimum number of waves/EU, even if the requested maximum is higher than
the actually achievable maximum (but still within subtarget
specification).

As such, the added unit test `empty_at_least_2_lds_limited`'s waves/EU
range should be [2,4] after this patch, when it is currently [1,4] (i.e,
as if `amdgpu-waves-per-eu` was not specified at all).

Before e377dc4 the default maximum waves/EU was always set to the
subtarget maximum, trivially avoiding the issue.
2025-05-22 02:45:59 +02:00
Craig Topper
6ff7a3ce81 [RISCV] Correct operand names for vmv.s.x and vfmv.s.f pseudos. NFC (#140970) 2025-05-21 17:40:24 -07:00
Snehasish Kumar
066221f98e Revert #140650 and #140505 (#140973)
This reverts commit 90daed32a8 and 4cfbe55781.
These changes exposed cyclic dependencies when LLVM is configured with
modules `-DLLVM_ENABLE_MODULES=ON`.
2025-05-21 17:38:56 -07:00
Jason Molenda
cea82573bb [lldb] Skip TestConsecutiveWatchpoints.py if out of tree debugserver
The GreenDragon CI bots are currently passing because the installed
Xcode is a bit old, and doesn't have the watchpoint handling
bug that was fixed April with this test being added.

But on other CI running newer Xcode debugservers, this test will
fail.  Skip this test if we're using an out of tree debugserver.
2025-05-21 17:38:35 -07:00
Akash Banerjee
fbb11b4c4e [OpenMP][Flang] Fix OOB access for derived type mapping (#140948) 2025-05-22 01:34:40 +01:00
Diego Caballero
d6f394e141 [mlir][Vector] Move vector.mask canonicalization to folder (#140324)
This MR moves the canonicalization that elides empty `vector.mask` ops
to folders.
2025-05-21 17:25:01 -07:00
LLVM GN Syncbot
12c62ebcb2 [gn build] Port c47a5fbb22 2025-05-21 23:31:34 +00:00
Kewen12
c47a5fbb22 Revert "[llvm] add GenericFloatingPointPredicateUtils (#140254)" (#140968)
This reverts commit d00d74bb25. 

The PR breaks our buildbots and blocks downstream merge.
2025-05-21 19:31:14 -04:00
Craig Topper
60ad6e3fa4 [SelectionDAG][RISCV] Use VP_LOAD to widen MLOAD in type legalization when possible. (#140595)
Padding the mask using 0 elements doesn't work for scalable vectors. Use
VP_LOAD and change the VL instead.

This fixes crash for Zve32x. Test file was split since i64 isn't a valid
element type for Zve32x.

Fixes #140198.
2025-05-21 15:52:08 -07:00
bd1976bris
b4d2e502e0 [LLVM] Use reportFatalUsageError for LTO usage errors (#140955)
Usage errors in `LTOBackend.cpp` were previously, misleadingly, reported
as internal crashes.

This PR updates `LTOBackend.cpp` to use `reportFatalUsageError` for
reporting usage-related issues.

LLVM Issue: https://github.com/llvm/llvm-project/issues/140953
Internal Tracker: TOOLCHAIN-17744
2025-05-21 23:21:59 +01:00
Philip Reames
c21416d1f9 [RISCV][TTI] Add test coverage for getPartialReductionCost [nfc]
Adding testing in advance of a change to cost the zvqdotq instructions
such that we emit them from LV.
2025-05-21 15:12:23 -07:00
LLVM GN Syncbot
77549b41f1 [gn build] Port d00d74bb25 2025-05-21 21:53:55 +00:00
Brox Chen
7f62800fb8 [AMDGPU][True16][CodeGen] select vgpr16 for asm inline 16bit vreg (#140946)
select vgpr16 for asm inline 16bit vreg in true16 mode
2025-05-21 17:47:28 -04:00
Tim Gymnich
d00d74bb25 [llvm] add GenericFloatingPointPredicateUtils (#140254)
add `GenericFloatingPointPredicateUtils` in order to generalize
effects of floating point comparisons on `KnownFPClass` for both IR and
MIR.

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-05-21 23:45:31 +02:00