Commit Graph

540800 Commits

Author SHA1 Message Date
lntue
d1ca8d891f [libc][math] Refactor expf implementation to header-only in src/__support/math folder. (#143790)
This is a 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-12 13:18:30 -04:00
halbi2
eab1a1d491 [libc++][test] Improve test coverage for flat_set (lack of) SCARY iterators (#139649)
Missing from 5e94e26a7a.
2025-06-12 13:15:41 -04:00
Dave Lee
cbc2ef0e89 [llvm][utils] Add synthetic provider for llvm::DenseSet (#143631)
Add a synthetic child provider for `DenseSet`, which is a wrapper around
`DenseMap`. This provider leverages the existing `DenseMap` provider,
reshaping its dictionary structured children into a set.
2025-06-12 10:13:30 -07:00
lntue
82f19674bf [libc] Update size_t and ssize_t definitions to use __SIZE_TYPE__ and __PTRDIFF_TYPE__ respectively. (#143921)
The current definition of `ssize_t` does not have the same bit width as
`size_t` on 32-bit platforms.
2025-06-12 13:11:42 -04:00
Shafik Yaghmour
53e50472ff [Clang][NFC] Move FatbinFileName instead of copy (#143827)
Static analysis flagged FatbinFileName since we can move it instead of
copying it.
2025-06-12 10:09:02 -07:00
黃國庭
217304a099 [X86] Use X86FixupInstTunings to select between (V)MOVSS/D and (V)BLENDPS/D (#143895)
Fix https://github.com/llvm/llvm-project/issues/142588
Following @RKSimon’s suggestion, the transformation applies only when
the blend mask is exactly 1, indicating that the instruction behaves
like a move. Additionally, the conversion will only be performed when
optimizing for size or when the target prefers MOVSS/D over BLENDPS/D
for performance reasons.

The switch-case instructions were identified with GPT O.O .

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-06-12 18:08:07 +01:00
Chelsea Cassanova
1a4cf1d3ed [lldb][headers] Create Python script to fix up framework headers (#142051)
This commit replaces the shell script that fixes up includes for the
LLDB framework with a Python script. This script will also be used when
fixing up includes for the LLDBRPC.framework.
2025-06-12 10:07:45 -07:00
fairywreath
2c20bc5112 [mlir][spirv] Add definitions for GL FindILsb and FindSMsb (#143916)
Adds SPIRV GL FindILsb and FindSMsb instructions which correspond to GL
instruction numbers 73 and 74.
2025-06-12 12:54:42 -04:00
Fangrui Song
e65131a563 MC,test: Specify explicit triple for include.ll
The output is subject to .set or = difference.
2025-06-12 09:49:06 -07:00
Michael Jones
ae7ea6e3a2 [libc] Fix ioctl errno inclusion (#143928)
Since errno was moved in
https://github.com/llvm/llvm-project/pull/143187 the code including it
in https://github.com/llvm/llvm-project/pull/141393 was rendered
incorrect. This patch fixes the include and the cmake depends.
2025-06-12 09:38:43 -07:00
Amr Hesham
cd8facebab [CIR] Implement folder for VecCreateOp (#143355)
This change adds a folder for the VecCreateOp

Issue https://github.com/llvm/llvm-project/issues/136487
2025-06-12 18:36:03 +02:00
Sudharsan Veeravalli
31daed868d [RISCV] Prefer QC_EXTU to ANDI for certain 12-bit mask immediates (#143838)
`QC_EXTU` can be compressed to `QC_C_EXTU` when the immediate is a `mask
>=63`. We currently only handle masks that don't fit in 12-bits in
`RISCVISelDAGToDAG`.

I have added ISEL patterns in `RISCVInstrInfoXqci.td` instead of
changing code in `RISCVISelDAGToDAG` since the other extract
instructions ( in `XTHeadbb` and `XAndesPerf`) don't have compressed
versions and it is a lot easier to maintain things this way.
2025-06-12 22:01:11 +05:30
Jon Roelofs
56548e1d9b [Matrix] Fix a crash in VisitSelectInst due to iteration length mismatch 2025-06-12 09:27:06 -07:00
long.chen
639c19ddb6 [NFC][mlir] make the assert consistent with the declared behavior (#143874) 2025-06-13 00:26:26 +08:00
Andy Kaylor
77834a40cf [CIR] Upstream support for emitting constructors (#143639)
This change upstreams the code to emit simple constructor defintions.
2025-06-12 09:24:26 -07:00
W. Turner Abney
4039fdb7ba [libc] add ioctl (#141393)
Closes #85275
Closes #90317
Updates #97191

---------

Co-authored-by: Joseph Huber <huberjn@outlook.com>
Co-authored-by: Michael Jones <michaelrj@google.com>
2025-06-12 09:20:32 -07:00
Michael Buch
c6da2c877c [lldb][Commands] Fix memory find for Swift expressions (#143860)
(depends on https://github.com/llvm/llvm-project/pull/143686)

There were two issues previously preventing `memory find -e` expressions
to succeed when stopped in Swift frames:
1. We weren't getting the dynamic type of the result `ValueObject`.
   For Swift this would fail when we tried to produce a scalar value
   out of it because the static VO wasn't sufficient to get to the
integer value. Hence we add a call to
`GetQualifiedRepresentationIfAvailable`
(which is what we do for expressions in `OptionArgParser::ToAddress`
too).
2. We weren't passing an `ExecutionContextScope` to `GetByteSize`, which
   Swift relied on to get the size of the result type.

My plan is to add an API test for this on the Apple
`swiftlang/llvm-project` fork.

I considered an alternative where we use `OptionArgParser::ToAddress`
for `memory find -e` expressions, but it got a bit icky when trying to
figure out how many bytes we should copy out of the result into the
`DataBufferHeap` (currently we rely on the size of the result variable
type). This gets even trickier when we were to pass an expression that
was actually a hex digit or a number into `ToAddress`.

rdar://152113525
2025-06-12 17:14:31 +01:00
Ethan Luis McDonough
daee5eee85 [Offload][PGO] Fix new GPU PGO tests (#143645)
`pgo_atomic_teams.c` and `pgo_atomic_threads.c` currently are set to run
on NVPTX despite the changes for that target not being upstreamed yet.
This patch also replaces instances of `llvm-profdata` with `%profdata`
in those tests.
2025-06-12 11:14:21 -05:00
Nathan Gauër
ef1cb8277a [SPIR-V] Fix ExecutionMode generation (#143888)
PR #141787 added code to emit the Fragment execution model. This
required emitting the OriginUpperLeft ExecutionMode. But this was done
by using the same codepath used for OpEntrypoint.

This has 2 issues:
- the interface variables were added to both OpEntryPoint and
OpExecutionMode.
- the existing OpExecutionMode logic was not used.

This commit fixes this, regrouping OpExecutionMode handling in one
place, and fixing bad codegen issue when interface variiables are added.
2025-06-12 18:13:29 +02:00
Farzon Lotfi
882b58a90a [DirectX] Reland #142853 with Circular GEP fixes (#143747)
This change relands  https://github.com/llvm/llvm-project/pull/142853
It fixes the circular reference issue we were seeing in GEPs
ex `%.flat = getelementptr inbounds [16 x i32], ptr %.flat, i32 0, i32
15`
2025-06-12 12:12:01 -04:00
kotborealis
a53003fe23 [libc++] Update GDB pretty-printer to work with GDB 17 (#142106)
This patch fixes an issue in libcxx/utils/gdb/libcxx/printers.py.

With gdb 17 (binutils 2_44) pretty-printers do not work anymore because
calls to `gdb.printing` requires `import gdb.printing` statement, which
was missing from the `printers.py`.

This was broken after commit https://github.com/bminor/binutils-gdb/commit/fc14343205d3a
and `import gdb.printing` was first referenced in https://github.com/bminor/binutils-gdb/commit/ee06c79b0f.

Co-authored-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
2025-06-12 11:51:22 -04:00
Simon Pilgrim
316f530724 [X86] getTargetConstantBitsFromNode - handle EXTRACT_SUBVECTOR through bitcasts (#143886)
Generalize the extraction index/width to account for any changes in type through bitcasts
2025-06-12 16:51:09 +01:00
Jon Roelofs
2a905dd1eb [Matrix] Use range-for in Visit* Result construction. NFC 2025-06-12 08:50:50 -07:00
Michael Buch
1c1df94d09 [lldb][Commands][NFC] Extract memory find expression evaluation into helpers (#143686)
This patch factors out the `-e` option logic into two helper functions.
The `EvaluateExpression` helper might seem redundant but I'll be adding
to it in a follow-up patch to fix an issue when running `memory find -e`
for Swift targets.

Also adds test coverage for the error cases that were previously
untested.

rdar://152113525
2025-06-12 16:48:57 +01:00
tynasello-google
13fe07d670 [libc++] Expand Android libc++ test config files (#142846)
Parameterize (and rename) existing libc++/libc++abi test configuration
files for the Android NDK to work for both the NDK and platform.

Android LLVM downstream seeks to test libc++ for both the NDK and
platform build (currently only testing the NDK), which will use almost
identical test configuration files. The only difference is the name of
the libc++ shared object used. Because of this we parameterize the
current test files (for both libc++ and libc++abi) with the existing
LIBCXX_SHARED_OUTPUT_NAME cmake variable, and rename the file
accordingly.
2025-06-12 11:39:28 -04:00
Kajetan Puchalski
f12b1ed116 [flang][OpenMP] Add TODOs for target [teams|parallel] private (#143706)
Using the private clause on `target teams` or `target parallel` is not
currently implemented and causes crashes during lowering. Add
appropriate TODOs.

Resolves https://github.com/llvm/llvm-project/issues/116428.

Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
2025-06-12 16:35:36 +01:00
Owen Pan
f6eaa2b00c Reland "[clang-format][NFC] Clean up fillRanges() in ClangFormat.cpp" (#143477)
Reapply https://github.com/llvm/llvm-project/pull/143236 and fix the bug
reported in
https://github.com/llvm/llvm-project/pull/143236#issuecomment-2957102180.
2025-06-12 08:29:49 -07:00
Cyndy Ishida
9b679889b5 [clang][darwin] Fix assertion failure when reporting fatal errors when inferring OS versions (#143817) 2025-06-12 08:24:50 -07:00
Paul Kirth
2e5fb77ce0 [llvm] Make TestData compatible with c++20 (#143801)
The clang-debian-cpp20 buildbot did not like direct initialization
without a matching constructor. This patch adds a new constructor taking
a json::Object that directly initializes the struct fields. We also
update an internal interface for const correctness.

https://lab.llvm.org/buildbot/#/builders/108/builds/13950
2025-06-12 08:22:04 -07:00
Nicolas Vasilache
e4de74ba11 [mlir][Vector] Tighten up application conditions in TransferReadAfter… (#143869)
…WriteToBroadcast

The pattern would previously apply in spurious cases and generate
incorrect IR.

In the process, we disable the application of this pattern in the case
where there is no broadcast; this should be handled separately and may
more easily support masking.

The case {no-broadcast, yes-transpose} was previously caught by this
pattern and arguably could also generate incorrect IR (and was also
untested): this case does not apply anymore.

The last cast {yes-broadcast, yes-transpose} continues to apply but
should arguably be removed from the future because creating transposes
as part of canonicalization feels dangerous.
There are other patterns that move permutation logic:

- either into the transfer, or
- outside of the transfer

Ideally, this would be target-dependent and not a canonicalization (i.e.
does your DMA HW allow transpose on the fly or not) but this is beyond
the scope of this PR.

Co-authored-by: Nicolas Vasilache <nicolasvasilache@users.noreply.github.com>
2025-06-12 17:11:06 +02:00
Igor Wodiany
62b6940900 [mlir][spirv] Add definition for GL Pack/UnpackHalf2x16 (#143889) 2025-06-12 16:10:33 +01:00
Kareem Ergawy
4bd0a0e50b Revert "[flang] Enable delayed localization by default for do concurrent (#142567)" (#143905)
This reverts commit 937be17752.

Resolves https://github.com/llvm/llvm-project/issues/143897 until the
todo is properly handled.
2025-06-12 17:09:55 +02:00
Ross Brunton
4f60321ca1 [Offload] Add ol_dimensions_t and convert ranges from size_t -> uint32_t (#143901)
This is a three element x, y, z size_t vector that can be used any place
where a 3D vector is required. This ensures that all vectors across
liboffload are the same and don't require any resizing/reordering
dances.
2025-06-12 09:59:59 -05:00
Kazu Hirata
5c1a021f7f [libc++] Fix typos in documentation (#143912) 2025-06-12 10:54:36 -04:00
A. Jiang
bba4ded3c2 [libc++] Fix constructing bitset from non-null-terminated arrays (#143691)
Unconditional evaluation of `char_traits<_CharT>::length(__str)` is problematic, because it causes
UB when `__str` points to a non-null-terminated array. We should only call `length` (currently, in
`basic_string_view`'s constructor) when `__n == npos` per [bitset.cons]/8.

Drive-by change: Reduction of conditional compilation, given that
- both `basic_string_view<_CharT>::size_type` and `basic_string<_CharT>::size_type` must be 
  `size_t`, and thus
- both `basic_string_view<_CharT>::npos` and `basic_string<_CharT>::npos` must be `size_t(-1)`.

For the type sameness in the standard wording, see:
- [string.view.template.general]
- [basic.string.general]
- [allocator.traits.types]/6
- [default.allocator.general]/1

Fixes #143684
2025-06-12 10:53:41 -04:00
Jon Roelofs
ca5b71a455 [Matrix] Propagate shape information through Select insts (#141876) 2025-06-12 07:52:25 -07:00
Tobias Stadler
b6a56b8ef2 [llvm-remarkutil] bitstream2yaml: Keep output file (#143220)
Keep the output file on successful exit, otherwise `llvm-remarkutil
bitstream2yaml -o filename.yaml ...` does not produce any output,
because the output file is deleted when the tool exits.
2025-06-12 15:50:31 +01:00
LLVM GN Syncbot
3687815858 [gn build] Port e1e1836bbd 2025-06-12 14:39:15 +00:00
Omair Javaid
e1e1836bbd [CodeGen] Inline stack guard check on Windows (#136290)
This patch optimizes the Windows security cookie check mechanism by
moving the comparison inline and only calling __security_check_cookie
when the check fails. This reduces the overhead of making a DLL call 
for every function return.

Previously, we implemented this optimization through a machine pass
(X86WinFixupBufferSecurityCheckPass) in PR #95904 submitted by
@mahesh-attarde. We have reverted that pass in favor of this new 
approach. Also we have abandoned the AArch64 specific implementation 
of same pass in PR #121938 in favor of this more general solution.

The old machine instruction pass approach:
- Scanned the generated code to find __security_check_cookie calls
- Modified these calls by splitting basic blocks
- Added comparison logic and conditional branching
- Required complex block management and live register computation

The new approach:
- Implements the same optimization during instruction selection
- Directly emits the comparison and conditional branching
- No need for post-processing or basic block manipulation
- Disables optimization at -Oz.

Thanks @tamaspetz, @efriedma-quic and @arsenm for their help.
2025-06-12 19:38:42 +05:00
Jeffrey Byrnes
cc17f68e56 [SLP] NFC: Precommit test for pull/137419 (#137730)
Precommit for https://github.com/llvm/llvm-project/pull/137419
2025-06-12 07:23:07 -07:00
Shamshura Egor
79f4a43839 [X86] VPTERNLOG comments - use "mem" just for full width loads and "m32bcst" / "m64bcst" for broadcast loads (#143721)
Use "mem" just for full width loads and "m32bcst" / "m64bcst" for 32-bit (D) / 64-bit (Q) broadcasts.

Fixes #143679

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-06-12 15:21:05 +01:00
Janek van Oirschot
3100b50f78 [AMDGPU] Flatten recursive register resource info propagation (#142766)
In #112251 I had mentioned I'd follow up with flattening of recursion
for register resource info propagation

Behaviour prior to this patch when a recursive call is used is to take
the module scope worst case function register use (even prior to
AMDGPUMCResourceInfo). With this patch it will, when a cycle is
detected, attempt to do a simple cycle avoidant dfs to find the worst
case constant within the cycle and the cycle's propagates. In other
words, it will attempt to look for the cycle scope worst case rather
than module scope worst case.
2025-06-12 14:35:28 +01:00
Nikita Popov
b8e3e0749f [InstCombine] Export logic for common base pointer (NFC)
Make this available to other parts of InstCombine, to be used for
pointer comparison optimization.
2025-06-12 15:33:45 +02:00
Pavel Labath
622df892b8 [lldb/cmake] Remove EXTRA_CXXFLAGS arg (#143731)
We have one library using this and three libraries directly calling
`target_compile_options`. Might as well standardize on the latter.
2025-06-12 15:27:27 +02:00
Nico Weber
843f256623 [gn] port 20d5d09e99 2025-06-12 09:23:34 -04:00
David Spickett
d49bc5e621 [llvm][MemProf] Correct position of LLVM_ABI macro in computeFrameHistogram
The previous placement resulted in this warning when using g++-13:
/home/david.spickett/llvm-project/llvm/include/llvm/Support/Compiler.h:120:43: warning: attribute ignored [-Wattributes]
  120 | #define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT [[gnu::visibility("default")]]
      |                                           ^
/home/david.spickett/llvm-project/llvm/include/llvm/Support/Compiler.h:213:18: note: in expansion of macro ‘LLVM_ATTRIBUTE_VISIBILITY_DEFAULT’
  213 | #define LLVM_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david.spickett/llvm-project/llvm/lib/ProfileData/MemProfRadixTree.cpp:245:5: note: in expansion of macro ‘LLVM_ABI’
  245 |     LLVM_ABI computeFrameHistogram<FrameId>(
      |     ^~~~~~~~
/home/david.spickett/llvm-project/llvm/include/llvm/Support/Compiler.h:120:43: note: an attribute that appertains to a type-specifier is ignored
  120 | #define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT [[gnu::visibility("default")]]
      |                                           ^

According to the interface guide, that macro should go before the return
type to be effective.

https://llvm.org/docs/InterfaceExportAnnotations.html#specialized-template-functions
2025-06-12 13:17:24 +00:00
Mel Chen
ce747a1632 [LV] Pre-commit test case for support VPWidenCastRecipe in isSingleScalar. nfc (#143498) 2025-06-12 21:06:58 +08:00
Stephen Tozer
a08a831515 [DLCov][NFC] Propagate annotated DebugLocs through transformations (#138047)
Part of the coverage-tracking feature, following #107279.

In order for DebugLoc coverage testing to work, we firstly have to set
annotations for intentionally-empty DebugLocs, and secondly we have to
ensure that we do not drop these annotations as we propagate DebugLocs
throughout compilation. As the annotations exist as part of the DebugLoc
class, and not the underlying DILocation, they will not survive a
DebugLoc->DILocation->DebugLoc roundtrip. Therefore this patch modifies
a number of places in the compiler to propagate DebugLocs directly
rather than via the underlying DILocation. This has no effect on the
output of normal builds; it only ensures that during coverage builds, we
do not drop incorrectly annotations and therefore create false
positives.

The bulk of these changes are in replacing
DILocation::getMergedLocation(s) with a DebugLoc equivalent, and in
changing the IRBuilder to store a DebugLoc directly rather than storing
DILocations in its general Metadata array. We also use a new function,
`DebugLoc::orElse`, which selects the "best" DebugLoc out of a pair
(valid location > annotated > empty), preferring the current DebugLoc on
a tie - this encapsulates the existing behaviour at a few sites where we
_may_ assign a DebugLoc to an existing instruction, while extending the
logic to handle annotation DebugLocs at the same time.
2025-06-12 14:06:27 +01:00
David Spickett
36ac72f4e3 [llvm][MemProf] Fix unused variable warning in release build
g++-13 warned that:
llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp:1645:8: warning: variable ‘PrevIterCreatedNode’ set but not used [-Wunused-but-set-variable]
 1645 |   bool PrevIterCreatedNode = false;
      |        ^~~~~~~~~~~~~~~~~~~

When asserts were not enabled.
2025-06-12 12:52:54 +00:00
woruyu
41c8df147b [DAG] Convert foldMaskedMerge to SDPatternMatch to match (m & x) | (~m & y) (#143855)
This PR resolves https://github.com/llvm/llvm-project/issues/143363

Remove foldMaskedMergeImpl entirely to use SDPatternMatch
2025-06-12 13:46:07 +01:00