Commit Graph

540700 Commits

Author SHA1 Message Date
Khem Raj
b46f34452e libunwind: Do not use __attribute__((target("gcs"))) with non-clang compilers (#138077)
This attribute is unsupported in GCC, so far it worked because before
GCC15 did not define this macros in _CHKFEAT_GCS in arm_acle.h [1]

With gcc15 compiler libunwind's check for this macros is succeeding and
it ends up enabling 'gcs' by using function attribute, this works with
clang but not with gcc.

We can see this in rust compiler bootstrap for aarch64/musl when system
uses gcc15, it ends up with these errors

Building libunwind.a for aarch64-poky-linux-musl
```
cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:191:1: error: arch extension 'gcs' should be prefixed by '+' cargo:warning=  191 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
cargo:warning=      | ^~~~~~~~~~~~~
cargo:warning=/mnt/b/yoe/master/sources/poky/build/tmp/work/cortexa57-poky-linux-musl/rust/1.85.1/rustc-1.85.1-src/src/llvm-project/libunwind/src/UnwindLevel1.c:337:22: error: arch extension 'gcs' should be prefixed by '+'
cargo:warning=  337 |                      _Unwind_Stop_Fn stop, void *stop_parameter) {
cargo:warning=      |                      ^~~~~~~~~~~~~~~
```

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5a6af707f0af

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2025-06-11 20:22:08 -07:00
Fangrui Song
d8118ed6db [ELF,test] Improve weak-undef-rw.s 2025-06-11 20:00:45 -07:00
LLVM GN Syncbot
faa49d6662 [gn build] Port de51b2dd3c 2025-06-12 02:53:03 +00:00
Jonas Devlieghere
de51b2dd3c [lldb] Move Transport class into lldb_private (NFC) (#143806)
Move lldb-dap's Transport class into lldb_private so the code can be
shared between the "JSON with header" protocol used by DAP and the JSON
RPC protocol used by MCP (see [1]).

[1]: https://discourse.llvm.org/t/rfc-adding-mcp-support-to-lldb/86798
2025-06-11 19:51:05 -07:00
Chuanqi Xu
bb3b8306dc [NFC] [C++20] [Modules] Add a test module local declaration lookup
From
https://github.com/llvm/llvm-project/issues/143734, but it looks good on
trunk. Add it as tests are always good.
2025-06-12 10:48:34 +08:00
Jameson Nash
082251bba4 [AArch64] fix trampoline implementation: use X15 (#126743)
AAPCS64 reserves any of X9-X15 for a compiler to choose to use for this
purpose, and says not to use X16 or X18 like GCC (and the previous
implementation) chose to use. The X18 register may need to get used by
the kernel in some circumstances, as specified by the platform ABI, so
it is generally an unwise choice. Simply choosing a different register
fixes the problem of this being broken on any platform that actually
follows the platform ABI (which is all of them except EABI, if I am
reading this linux kernel bug correctly
https://lkml2.uits.iu.edu/hypermail/linux/kernel/2001.2/01502.html). As
a side benefit, also generate slightly better code and avoids needing
the compiler-rt to be present. I did that by following the XCore
implementation instead of PPC (although in hindsight, following the
RISCV might have been slightly more readable). That X18 is wrong to use
for this purpose has been known for many years (e.g.
https://www.mail-archive.com/gcc@gcc.gnu.org/msg76934.html) and also
known that fixing this to use one of the correct registers is not an ABI
break, since this only appears inside of a translation unit. Some of the
other temporary registers (e.g. X9) are already reserved inside llvm for
internal use as a generic temporary register in the prologue before
saving registers, while X15 was already used in rare cases as a scratch
register in the prologue as well, so I felt that seemed the most logical
choice to choose here.
2025-06-11 21:49:01 -04:00
Longsheng Mou
52360d195b [NFC] Use llvm::includes instead of std::includes (#143542)
This PR follows up #143297.
2025-06-12 09:27:27 +08:00
Shunsuke Watanabe
c431618041 [Clang][Driver] Override complex number calculation method by -fno-fast-math (#132680)
This patch fixes a bug where -fno-fast-math doesn't revert the complex
number calculation method to the default. The priority of overriding
options related to complex number calculations differs slightly from
GCC, as discussed in:


https://discourse.llvm.org/t/the-priority-of-fno-fast-math-regarding-complex-number-calculations/84679
2025-06-12 10:19:26 +09:00
Jeffrey Byrnes
7034014d08 [InstCombine] Combine or-disjoint (and->mul), (and->mul) to and->mul (#136013)
The canonical pattern for bitmasked mul is currently

```
%val = and %x, %bitMask // where %bitMask is some constant
%cmp = icmp eq %val, 0
%sel = select %cmp, 0, %C // where %C is some constant = C' * %bitMask
```

In certain cases, where we are combining multiple of these bitmasked
muls with common factors, we are able to optimize into and->mul (see
https://github.com/llvm/llvm-project/pull/135274 )

This optimization lends itself to further optimizations. This PR
addresses one of such optimizations.

In cases where we have

`or-disjoint ( mul(and (X, C1), D) , mul (and (X, C2), D))`

we can combine into

`mul( and (X, (C1 + C2)), D) `

provided C1 and C2 are disjoint.

Generalized proof: https://alive2.llvm.org/ce/z/MQYMui
2025-06-11 18:07:00 -07:00
Jim Lin
7a3bcf9f71 [RISCV] Add missing predicate for PseudoTHVdotVMAQA family instructions 2025-06-12 08:43:06 +08:00
Jake Egan
d7c6cad744 [sanitizer_common] Implement interception on AIX (#138606)
Adjust AIX interceptor support in sanitizer_common. 

Issue: https://github.com/llvm/llvm-project/issues/138916
2025-06-11 20:22:15 -04:00
Jameson Nash
bc7ea63e9c [MemCpyOpt] handle memcpy from memset for non-constant sizes (#143727)
Allows forwarding memset to memcpy for mismatching unknown sizes if
overread has undef contents. In that case we can refine the undef bytes
to the memset value.

Refs #140954 which laid some of the groundwork for this.
2025-06-11 20:04:27 -04:00
Jorge Gorbe Moya
6c72084a57 [bazel] port 1ecd108cb7 2025-06-11 16:57:14 -07:00
Michael Jones
3c7af175e5 [libc] Fix stdio tests after #143802 (#143810)
In #143802 the stdio test cleanup missed a few places where errno was
being set to a failing value, and one where the framework needed to
included.
2025-06-11 16:52:21 -07:00
Alexey Samsonov
1ecd108cb7 [libc] Migrate stdio tests to ErrnoCheckingTest. (#143802)
Reduce the direct use of libc_errno in stdio unit tests by adopting
ErrnoCheckingTest where appropriate.

Also removes the libc_errno.h inclusions from stdlib.h tests that were
accidentally added in d87eea35fa
2025-06-11 16:22:17 -07:00
Joseph Huber
dc4335a2bf [libc] Perform bitfield zero initialization wave-parallel (#143607)
Summary:
We need to set the bitfield memory to zero because the system does not
guarantee zeroed out memory. Even if fresh pages are zero, the system
allows re-use so we would need a `kfd` level API to skip this step.

Because we can't this patch updates the logic to perform the zero
initialization wave-parallel. This reduces the amount of time it takes
to allocate a fresh by up to a tenth.

This has the unfortunate side effect that the control flow is more
convoluted and we waste some extra registers, but it's worth it to
reduce the slab allocation latency.
2025-06-11 18:22:05 -05:00
Nikolay Panchenko
ee35e34294 [ConstantFolding] Add folding for [de]interleave2, insert and extract (#141301)
The change adds folding for 4 vector intrinsics: `interleave2`,
`deinterleave2`, `vector_extract` and `vector_insert`. For the last 2
intrinsics the change does not use `ShuffleVector` fold mechanism as
it's much simpler to construct result vector explicitly.
2025-06-11 19:00:29 -04:00
Michael Maitland
0e457315f5 [mlir][generate-test-checks] Emit attributes with rest of CHECK lines (#143759)
Prior to this patch, generating test checks in place put the ATTR
definitions at the very top of the file, above the RUN lines and
autogenerated note. All CHECK lines should below the RUN lines and
autogenerated note.

This change ensures that the attribute definitions are emitted with the
rest of the CHECK lines.

---------

Co-authored-by: Michael Maitland <michaelmaitland@meta.com>
2025-06-11 18:19:15 -04:00
Michael Maitland
74172add65 [mlir][generate-test-checks] Do not emit the autogenerated note if it exists (#143750)
Prior to this PR, the script removed the already existing autogenerated
note if we came across a line that was equal to the note. But the
default note is multiple lines, so there would never be a match.
Instead, check to see if the current line is a substring of the
autogenerated note.

Co-authored-by: Michael Maitland <michaelmaitland@meta.com>
2025-06-11 18:18:22 -04:00
Ellis Hoag
9c9a4a284e [LOH] Don't emit AdrpAddStr when register could be clobbered (#142849)
b783aa8979
added a check to ensure an `AdrpAddLdr` LOH isn't created when there is
an instruction between the `add` and `ldr`


50c5704dc0/llvm/lib/Target/AArch64/AArch64CollectLOH.cpp (L419-L431)

We need a similar check for `AdrpAddStr`. Although this technically
isn't implemented in LLD, it could be in the future.


50c5704dc0/lld/MachO/Arch/ARM64.cpp (L699-L702)
2025-06-11 14:54:30 -07:00
Ian Wood
6f2ba4712f [mlir] Fix ComposeExpandOfCollapseOp for dynamic case (#142663)
Changes `findCollapsingReassociation` to return nullopt in all cases
where source shape has `>=2` dynamic dims. `expand(collapse)` can
reshape to in any valid output shape but a collapse can only collapse
contiguous dimensions. When there are `>=2` dynamic dimensions it is
impossible to determine if it can be simplified to a collapse or if it
is preforming a more advanced reassociation.


This problem was uncovered by
https://github.com/llvm/llvm-project/pull/137963

---------

Signed-off-by: Ian Wood <ianwood2024@u.northwestern.edu>
2025-06-11 14:34:02 -07:00
Sirraide
7838fc0cd3 [Clang] [NFC] Move diagnostics emitting code from DiagnosticIDs into DiagnosticsEngine (#143517)
It makes more sense for this functionality to be all in one place rather
than split up across two files—at least it caused me a bit of a headache
to try and find all places where we were actually forwarding the
diagnostic to the `DiagnosticConsumer`. Moreover, moving these functions
into `DiagnosticsEngine` simplifies the code quite a bit since we access
members of `DiagnosticsEngine` more frequently than those of
`DiagnosticIDs`. There was also a duplicated code snippet that I’ve
moved out into a new function.
2025-06-11 23:24:33 +02:00
Jiachen Yuan
625bfb7179 Workaround MSVC Linker Issue when Cross-Compiling for ARM64EC (#143659)
This MR presents a temporary workaround for the issue described at
https://github.com/llvm/llvm-project/issues/143575. While an [upstream
MSVC
bug](https://developercommunity.visualstudio.com/t/MSVC-Linker-Issue-When-Cross-Compiling-L/10920141)
is reported, it makes sense to apply a workaround in LLVM code to
quickly unblock anyone affected.
2025-06-11 14:23:41 -07:00
Oleksandr T.
d7e7f22626 [Clang] fix missing source location for errors in macro-expanded (#143460)
Fixes #143216

--- 

This patch fixes diagnostic locations for tokens from macro expansions.
2025-06-11 14:19:25 -07:00
Shafik Yaghmour
f39f53e569 [Clang][NFC] Move HeadingAndSpellings to avoid copying (#143611)
Static analysis flagged that we could move HeadingAndSpellings and avoid
a copy of a large object.
2025-06-11 14:11:19 -07:00
Florian Hahn
c0c0f60ca1 [GlobalOpt] Bail out on non-ConstExprs in isSimpleEnoughtToCommit. (#143400)
Bail out for non ConstantExpr constants in
isSimpleEnoughValueToCommitHelper to prevent crash for non-ConstantExpr
constants

PR: https://github.com/llvm/llvm-project/pull/143400
2025-06-11 22:09:55 +01:00
sribee8
79108da325 [libc][obvious] Changed incorrect type (#143780)
After changing mbstate_t to mbstate we forgot to change the
character_converter files to reflect it.

Co-authored-by: Sriya Pratipati <sriyap@google.com>
2025-06-11 13:28:55 -07:00
lntue
d87eea35fa [libc] Move libc_errno.h to libc/src/__support and make LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187)
This is the first step in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-06-11 16:25:27 -04:00
Rolf Morel
fb761aa38b [MLIR][Transform] apply_registered_op fixes: arg order & python options auto-conversion (#143779) 2025-06-11 21:19:52 +01:00
Uzair Nawaz
e389a0e7bb [libc] Switched calls to inline_memcpy to __builtin_memcpy for wide char utilities (#143011)
Switched calls to inline_memcpy to __builtin_memcpy for wide char
utilities
Removed unnecessary wctype_utils dependencies from the cmake file
2025-06-11 13:17:35 -07:00
Peter Klausler
b42aef5e6f [flang] Don't duplicate hermetic module file dependencies (#143605)
When emitting the modules on which a module depends under the
-fhermetic-module-files options, eliminate duplicates by name rather
than by symbol addresses. This way, when a dependent module is in the
symbol table more than once due to the use of a nested hermetic module,
it doesn't get emitted multiple times to the new module file.
2025-06-11 13:12:59 -07:00
Chelsea Cassanova
a2d2941830 [lldb][RPC] Upstream LLDB to RPC converstion Python script (#138028)
As part of upstreaming LLDB RPC, this commit adds a python script that
is used by LLDB RPC to modify the public lldb header files for use with
RPC.

https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804
2025-06-11 13:12:37 -07:00
Uzair Nawaz
52583b3ed7 [libc] Character converter skeleton class (#143619)
Made CharacterConverter class skeleton
2025-06-11 13:11:31 -07:00
Jorge Gorbe Moya
c70658e32d [bazel] port 5dafe9dca8 2025-06-11 13:09:11 -07:00
Florian Hahn
5623b7f2d5 [LV] Use GeneratedRTChecks to check if safety checks were added (NFC).
Directly check via GeneratedRTChecks if any checks have been added,
instead of needing to go through ILV. This simplifies the code and
enables further refactoring in follow-up patches.
2025-06-11 21:08:36 +01:00
Craig Topper
e7e491f6ee [SelectionDAG] Add ISD::VSELECT to SelectionDAG::canCreateUndefOrPoison. (#143760) 2025-06-11 13:06:22 -07:00
Paul Kirth
ad2a2b8eed [llvm] Add a tool to check mustache compliance against the public spec (#142813)
This is a cli tool to that tests the conformance of LLVM's mustache
implementation against the public Mustache spec, hosted at
https://github.com/mustache/spec. This is a revised version of the
patches in #111487.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
2025-06-11 13:05:21 -07:00
Kazu Hirata
43c35e858c [mlir] Simplify calls to *Map::{insert,try_emplace} (NFC) (#143729)
This patch simplifies code by removing the values from
insert/try_emplace.  Note that default values inserted by try_emplace
are immediately overrideen in all these cases.
2025-06-11 12:50:35 -07:00
Kazu Hirata
8da1ac98ef [llvm] Use std::tie to implement operator< (NFC) (#143728)
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator<.
2025-06-11 12:50:27 -07:00
Kazu Hirata
c1d21f4434 [lld] Use std::tie to implement comparison operators (NFC) (#143726)
std::tie facilitates lexicographical comparisons through std::tuple's
built-in operator< and operator>.
2025-06-11 12:50:19 -07:00
Kazu Hirata
e266d6a5da [Format] Use llvm::min_element (NFC) (#143725)
llvm::min_elements allows us to pass a range.
2025-06-11 12:50:11 -07:00
Kazu Hirata
ebc90d50b8 [SandboxVectorizer] Use llvm::find (NFC) (#143724)
llvm::find allows us to pass a range.
2025-06-11 12:50:03 -07:00
Florian Hahn
ace356bc97 [VPlan] Always verify VPCanonicalIVPHIRecipe placement (NFC).
Loop regions are dissolved since dcef154b5c, remove the
check for VerifyLate and corresponding TODO.
2025-06-11 20:45:48 +01:00
Alex MacLean
02161c635f [NVPTX] Misc table-gen cleanup (NFC) (#142877) 2025-06-11 12:44:51 -07:00
Razvan Lupusoru
34a1b8ce25 [acc] acc.loop verifier now requires parallelism determination flag (#143720)
The OpenACC specification for `acc loop` describe that a loop's
parallelism determination mode is either auto, independent, or seq. The
rules are as follows.
- As per OpenACC 3.3 standard section 2.9.6 independent clause: A loop
construct with no auto or seq clause is treated as if it has the
independent clause when it is an orphaned loop construct or its parent
compute construct is a parallel construct.
- As per OpenACC 3.3 standard section 2.9.7 auto clause: When the parent
compute construct is a kernels construct, a loop construct with no
independent or seq clause is treated as if it has the auto clause.
- Additionally, loops marked with gang, worker, or vector are not
guaranteed to be parallel. Specifically noted in 2.9.7 auto clause: If
not, or if it is unable to make a determination, it must treat the auto
clause as if it is a seq clause, and it must ignore any gang, worker, or
vector clauses on the loop construct.

The verifier for `acc.loop` was updated to enforce this marking because
the context in which a loop appears is not trivially determined once IR
transformations begin. For example, orphaned loops are implicitly
`independent`, but after inlining into an `acc.kernels` region they
would be implicitly considered `auto`. Thus now the verifier requires
that a frontend specifically generates acc dialect with this marking
since it knows the context.
2025-06-11 12:37:08 -07:00
Abhina Sree
22fd11fe66 [SystemZ][z/OS] Refactor AutoConvert.h to remove large MVS guard (#143174)
This AutoConvert.h header frequently gets mislabeled as an unused
include because it is guarded by MVS internally and every usage is also
guarded. This refactors the change to remove this guard and instead make
these functions a noop on other non-z/OS platforms.
2025-06-11 15:26:49 -04:00
Alexey Samsonov
5dafe9dca8 [libc] Reduce direct use of errno in src/stdlib and src/__support tests. (#143767)
* Get rid of libc_errno assignments in str_to_* __support tests, since
those API have been migrated to return error in a struct instead.
* Migrate tests for atof and to strto* functions from <stdlib.h> and for
strdup from <string.h> to use ErrnoCheckingTest harness.
2025-06-11 12:23:17 -07:00
Jorge Gorbe Moya
d5f68cb145 [bazel] Port fe7bf4b90b 2025-06-11 12:10:09 -07:00
Erich Keane
574f77a1ee [OpenACC][CIR] Add parallelism determ. to all acc.loops (#143751)
PR #143720 adds a requirement to the ACC dialect that every acc.loop
must have a seq, independent, or auto attribute for the 'default'
device_type. The standard has rules for how this can be intuited:

orphan/parallel/parallel loop: independent
kernels/kernels loop: auto
serial/serial loop: seq, unless there is a gang/worker/vector, at which
point it should be 'auto'.

This patch implements all of this rule as a 'cleanup' step on the IR
generation for combined/loop operations. Note that the test impact is
much less since I inadvertently have my 'operation' terminating curley
matching the end curley from 'attribute' instead of the front of the
line, so I've added sufficient tests to ensure I captured the above.
2025-06-11 12:04:26 -07:00
Abhinav Gaba
02b6849cf1 [Clang][OpenMP] Fix mapping of arrays of structs with members with mappers (#142511)
This builds upon #101101 from @jyu2-git, which used compiler-generated
mappers when mapping an array-section of structs with members that have
user-defined default mappers.

Now we do the same when mapping arrays of structs.
2025-06-11 19:03:55 +00:00