Commit Graph

542294 Commits

Author SHA1 Message Date
Larry Meadows
20f56d1409 [libc++abi] Fix C++ demangling for _BitInt type (#143466)
The front-end expects _BitInt to be available for substitution; ensure DB<n> is
added to Subs in ItaniumDemangle.h. Also add a test case to libc++abi and
sync the files to llvm/include/llvm.
2025-06-25 15:06:11 -04:00
MaheshRavishankar
c873e5f87d [mlir][TilingInterface] Handle multi operand consumer fusion. (#145193)
For consumer fusion cases of this form

```
%0:2 = scf.forall .. shared_outs(%arg0 = ..., %arg0 = ...) {

  tensor.parallel_insert_slice ... into %arg0
  tensor.parallel_insert_slice ... into %arg1
}
%1 = linalg.generic ... ins(%0#0, %0#1)
```

the current consumer fusion that handles one slice at a time cannot fuse
the consumer into the loop, since fusing along one slice will create and
SSA violation on the other use from the `scf.forall`. The solution is to
allow consumer fusion to allow considering multiple slices at once. This
PR changes the `TilingInterface` methods related to consumer fusion,
i.e.

- `getTiledImplementationFromOperandTile`
- `getIterationDomainFromOperandTile`

to allow fusion while considering multiple operands. It is upto the
`TilingInterface` implementation to return an error if a list of tiles
of the operands cannot result in a consistent implementation of the
tiled operation.

The Linalg operation implementation of `TilingInterface` has been
modified to account for these changes and allow cases where operand
tiles that can result in a consistent tiling implementation are handled.

---------

Signed-off-by: MaheshRavishankar <mahesh.ravishankar@gmail.com>
2025-06-25 11:54:38 -07:00
Kazu Hirata
28f6f87061 [mlir] Migrate away from std::nullopt (NFC) (#145523)
ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch migrates away from std::nullopt in favor of ArrayRef<T>()
where we use perfect forwarding.  Note that {} would be ambiguous for
perfect forwarding to work.
2025-06-25 11:49:22 -07:00
Samarth Narang
d760f97387 [Clang] Implement diagnostics for why std::is_standard_layout is false (#144161) 2025-06-25 14:49:15 -04:00
Alex MacLean
70333de6cf [NVPTX] Consolidate and cleanup various NVPTXISD nodes (NFC) (#145581)
This change consolidates and cleans up various NVPTXISD target-specific
nodes in order to simplify SDAG ISel. While there are some whitespace
changes in the emitted PTX it is otherwise a non-functional change.

NVPTXISD::Wrapper - This node was used to wrap external-symbol and
global-address nodes. It is redundant and has been removed. Instead we
use the non-target versions of these nodes and convert them
appropriately during ISel.

NVPTXISD::CALL - Much of the family of nodes used to represent a PTX
call instruction have been replaced by this new single node. It
corresponds to a single instruction and is therefore much simpler to
create and lower.
2025-06-25 11:42:21 -07:00
Andrzej Warzyński
5f8e7ed5a3 [mlir][linalg][nfc] Split hoisting tests into dedicated test functions (#145234)
Refactors the `@hoist_vector_transfer_pairs` test function in
`hoisting.mlir` into smaller, focused test functions - each covering a
specific `vector.transfer_read`/`vector.transfer_write` pair.

This makes it easier to identify which edge cases are tested, spot
duplication, and write more targeted and readable check lines, with less
surrounding noise.

This refactor also helped identify some issues with the original
`@hoist_vector_transfer_pairs` test:
  * Input variables `%val` and `%cmp` were unused.
  * There were no check lines for reads from `memref5`.

**Note for reviewers (current and future):**

This PR is split into small, incremental, and self-contained commits. It
should be easier to follow the changes by reviewing those commits
individually, rather than reading the full squashed diff. However, this
will be merged as a single commit to avoid adding unnecessary history
noise in-tree.
2025-06-25 19:32:38 +01:00
Andrew Rogers
369cbcc1a2 [lldb] include LLVMTargetParser in LINK_COMPONENTS (#145606)
## Purpose
Fix duplicate symbol definition errors when building LLDB `HostTests`
against a LLVM Windows DLL.

## Background 
When building LLDB `HostTests` against LLVM built as a Windows DLL,
compilation fails due to multiple duplicate symbol definition errors.
This is because symbols are both exported by the LLVM Windows DLL and
the `LLVMTargetParser` library.

## Overview
The issue is resolved by adding `LLVMTargetParser` (e.g. `TargetParser`)
to `LINK_COMPONENTS`, which adds it to `LLVM_LINK_COMPONENTS`, rather
than `LINK_LIBS`, which links directly against the library. This change
makes it behave correctly when linking against a static or dynamic LLVM.
2025-06-25 19:30:50 +01:00
Ivan Tadeu Ferreira Antunes Filho
626be98c35 [mlir] Remove dependency on LinalgTransformOps.h from #144657 (#145749)
https://github.com/llvm/llvm-project/pull/144657 added #include
"mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.h" to
mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp, though it is not
in use
2025-06-25 14:21:26 -04:00
Tom Tromey
3b90597c2c Non constant size and offset in DWARF (#141106)
In Ada, a record type can have a non-constant size, and a field can
appear at a non-constant bit offset in a record.

To support this, this patch changes DIType to record the size and offset
using metadata, rather than plain integers. In addition to a constant
offset, both DIVariable and DIExpression are now supported here.

One thing of note in this patch is the choice of how exactly to
represent a non-constant bit offset, with the difficulty being that
DWARF 5 does not support this. DWARF 3 did have a way to support a
non-constant byte offset, combined with a constant bit offset within the
byte, but this was deprecated in DWARF 4 and removed from DWARF 5.

This patch takes a simple approach: a DWARF extension allowing the use
of an expression with DW_AT_data_bit_offset. There is a corresponding
DWARF issue, see https://dwarfstd.org/issues/250501.1.html. The main
reason for this approach is that it keeps API simplicity: just a single
value is needed, rather than having separate data describing the byte
offset and the bit within the byte.
2025-06-25 11:20:35 -07:00
Charles Zablit
487581b826 [lldb][darwin] force BuiltinHeadersInSystemModules to be always false (#144913)
`SDKSupportsBuiltinModules` always returns true on newer versions of
Darwin based OS. The only way for this call to return `false` would be
to have a version mismatch between lldb and the SDK (recent lldb
manually installed on macOS 14 for instance).

This patch removes this check and hardcodes the value of
`BuiltinHeadersInSystemModules` to `false`.
2025-06-25 11:18:07 -07:00
Benjamin Kramer
357297c0f2 [bolt] Fix the build after 0556a2aa18
StringRef now implictly converts into ArrayRef<char>.
2025-06-25 20:16:19 +02:00
Andy Kaylor
1e45ea12db [CIR] Add support for function linkage and visibility (#145600)
This change adds support for function linkage and visibility and related
attributes. Most of the test changes are generalizations to allow
'dso_local' to be accepted where we aren't specifically testing for it.
Some tests based on CIR inputs have been updated to add 'private' to
function declarations where required by newly supported interfaces.

The dso-local.c test has been updated to add specific tests for
dso_local being set correctly, and a new test, func-linkage.cpp tests
other linkage settings.

This change sets `comdat` correctly in CIR, but it is not yet applied to
functions when lowering to LLVM IR. That will be handled in a later
change.
2025-06-25 10:59:30 -07:00
Amr Hesham
1276a5b368 [CIR] Upstream support for builtin_vectorelements (#144877)
Add support for `__builtin_vectorelements`

Issue https://github.com/llvm/llvm-project/issues/136487
2025-06-25 19:40:21 +02:00
Amr Hesham
e4da49f018 [CIR] Upstream __imag__ for ComplexType (#144262)
This change adds support for `__imag__` for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-25 19:39:34 +02:00
yronglin
585ed213a8 [NFC][Clang][Preprocessor] Refine the implementation of isNextPPTokenOneOf (#145546)
This PR follow the
suggestion(https://github.com/llvm/llvm-project/pull/143898#discussion_r2164253141)
to refine the implementation of `Preprocessor::isNextPPToken`, also use
C++ fold expression to refine `Token::isOneOf`. We don't need `bool
isOneOf(tok::TokenKind K1, tok::TokenKind K2) const` anymore.

In order to reduce the impact, specificed `TokenKind` is still passed to
`Token::isOneOf` and `Preprocessor::isNextPPTokenOneOf` as function
parameters.

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-26 01:38:37 +08:00
Benjamin Kramer
0556a2aa18 [ArrayRef] Provide constructors from any type with a data() member (#145735)
The assumption here is that if data() returns a pointer and size()
exists it's something representing contiguous storage.

Modeled after the behavior of C++20 std::span and enables two-way
conversion between std::span (or really any span-like type) and
ArrayRef. Add a unit test that verifies this if std::span is around.

This also means we can get rid of specific conversions for std::vector
and SmallVector.
2025-06-25 19:33:34 +02:00
Kazu Hirata
df79c40c98 [clang-tidy Fix a warning
This patch fixes:

  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp:371:26:
  error: variable 'E' set but not used
  [-Werror,-Wunused-but-set-variable]
2025-06-25 10:14:34 -07:00
Kazu Hirata
2a35414e98 [Transforms] Use range-based for loops (NFC) (#145252)
Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-06-25 10:08:26 -07:00
Malavika Samak
86026ee623 [clang-tidy] Warn about misuse of sizeof operator in loops. (#143205)
The sizeof operator misuses in loop conditionals can be a source of
bugs. The common misuse is attempting to retrieve the number of elements
in the array by using the sizeof expression and forgetting to divide the
value by the sizeof the array elements. This results in an incorrect
computation of the array length and requires a warning from the sizeof
checker.

Example:
```
 int array[20];

void test_for_loop() {
  // Needs warning.
  for(int i = 0; i < sizeof(array); i++) {
    array[i] = i;
  }
}

void test_while_loop() {

  int count = 0;
  // Needs warning. 
  while(count < sizeof(array)) {
    array[count] = 0;
    count = count + 2;
  }
}
```
rdar://151403083

---------

Co-authored-by: MalavikaSamak <malavika2@apple.com>
2025-06-25 10:04:10 -07:00
Spenser Bauman
532c15a718 [mlir][linalg] Fix module dependency issue due to unused import (#145727)
This include introduces a dependency for LinalgTransforms on
LinalgTransformOps, which is unspecified in the module dependencies, and
would produce a cyclic dependency if it were specified.

The include is unused in WinogradConv2D.cpp, so this change removes it.
2025-06-25 12:54:49 -04:00
Krzysztof Parzyszek
b4f4af7ebb [flang][OpenMP] Verify that N in -fopenmp-version=N is valid (#145725)
For historical versions that are unsupported, emit a warning and assume
the currently default version.
For values of N that are not integers or that don't correspond to any
OpenMP version (old or newer), emit an error.
2025-06-25 11:54:14 -05:00
Thurston Dang
5a194c1fd9 [msan] Sharpen instrumentation of Intrinsic::{ctlz,cttz} (#145609)
The current instrumentation of Intrinsic::{ctlz,cttz} has false positives. For example, consider `ctlz(0001 11??)` whereby `0` and `1` denotes initialized bits (with concrete values of 0 and 1 respectively) and `?` denotes an uninitialized bit. The result (of 3) is well-defined and the shadow ought to be fully initialized, but the current instrumentation marks it as fully uninitialized.

This patch improves the fidelity of the instrumentation by comparing the number of leading (for ctlz; trailing for cttz) zeros in the concrete value and the shadow.

This patch also renames the function from 'handleCountZeroes' to 'handleLeadingTrailingCountZeros', to clarify that the intrinsics handled do not count all the zeros (unlike `llvm.ctpop`, which counts all the 1s).
2025-06-25 09:29:59 -07:00
Ivan Tadeu Ferreira Antunes Filho
9b307ebdd0 [bazel] Update deps from #144657 (#145726)
https://github.com/llvm/llvm-project/pull/144657 added #include
"mlir/Dialect/Linalg/IR/LinalgEnums.td" to
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td, so
we update the deps
2025-06-25 12:27:40 -04:00
Naveen Seth Hanig
dd47b845a6 [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (#145243)
Fixes #145226.

Implement
[P2223R2](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2223r2.pdf)
in clang-format to correctly handle cases where a backslash '\\' is
followed by trailing whitespace before the newline.
Previously, `clang-format` failed to properly detect and handle such
cases, leading to misformatted code.

With this, `clang-format` matches the behavior already implemented in
Clang's lexer and `DependencyDirectivesScanner.cpp`, which allow
trailing whitespace after a line continuation in any C++ standard.
2025-06-25 18:13:00 +02:00
Amr Hesham
9a7720ad2f [CIR] Upstream __real__ for ComplexType (#144261)
This change adds support for __real__ for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-06-25 18:06:57 +02:00
Ross Brunton
3e337bc308 [Offload] Add a stub unloadBinaryImpl for host device (#145716) 2025-06-25 17:06:17 +01:00
Joseph Huber
029823a84d [Clang][NFC] Clean up OpenMP offload toolchain generation (#145549)
Summary:
Small cleanup prior to some larger changes in this area. I want to move
the offload arch detection to be done solely here.

This might change the order the targets show up in but shouldn't affect
anything else. Will look into that.
2025-06-25 11:04:06 -05:00
Corentin Jabot
a76448c27d [Clang] Fix replaceability/relocatability computation (#145655)
for eligible classes with user provided constructor or `operator=`

Fixes #144232
2025-06-25 17:49:15 +02:00
Andrzej Warzyński
c92b580d63 [mlir][ArmSME] Remove ConvertIllegalShapeCastOpsToTransposes (#139706)
As a follow-up to PR #135841 (see discussion for background), this patch
removes the `ConvertIllegalShapeCastOpsToTransposes` pattern from the SME
legalization pass. This change unblocks folding for ShapeCastOp involving
scalable vectors.

Originally, the `ConvertIllegalShapeCastOpsToTransposes` pattern was introduced
to rewrite certain `vector.shape_cast` ops that could not be lowered otherwise.
Based on local end-to-end testing, this workaround is no longer required, and
the pattern can now be safely removed.

This patch also removes a special case from `ShapeCastOp::fold`, simplifying
the fold logic.

As a side effect of removing `ConvertIllegalShapeCastOpsToTransposes`, we lose
the mechanism that enabled lowering of certain ops like:

```mlir
%res = vector.transfer_read %mem[%a, %b] (...) :
       memref<?x?xf32>, vector<[4]x1xf32>
```
Previously, such cases were handled by:
* Rewriting a nearby `vector.shape_cast` to a `vector.transpose` (via
  `ConvertIllegalShapeCastOpsToTransposes`)
* Then lowering the result with `LiftIllegalVectorTransposeToMemory`.

This patch introduces a new dedicated pattern,
`LowerColumnTransferReadToLoops`, that directly handles illegal
`vector.transfer_read` ops involving leading scalable dimensions.
2025-06-25 16:40:14 +01:00
Rolf Morel
c08502defe [MLIR][Transform] expose transform.debug extension in Python (#145550)
Removes the Debug... prefix on the ops in tablegen, in line with pretty
much all other Transform-dialect extension ops. This means that the ops
in Python look like
`debug.EmitParamAsRemarkOp`/`debug.emit_param_as_remark` instead of
`debug.DebugEmitParamAsRemarkOp`/`debug.debug_emit_param_as_remark`.
2025-06-25 16:39:01 +01:00
Harald van Dijk
46ee7f1908 [libclc] Avoid out-of-range float-to-int. (#145698)
For a kernel such as

    kernel void foo(__global double3 *z) {
      double3 x = {0.6631661088,0.6612268107,0.1513627528};
      int3 y = {-1980459213,-660855407,615708204};
      *z = pown(x, y);
    }

we were not storing anything to z, because the implementation of pown
relied on an floating-point-to-integer conversion where the
floating-point value was outside of the integer's range. Although in
LLVM IR we permit that operation so long as we end up ignoring its
result -- that is the general rule for poison -- one thing we are not
permitted to do is have conditional branches that depend on it, and
through the call to __clc_ldexp, we did have that.

To fix this, rather than changing expv at the end to INFINITY/0, we can
change v at the start to values that we know will produce INFINITY/0
without performing such out-of-range conversions.

Tested with

    clang --target=nvptx64 -S -O3 -o - test.cl \
      -Xclang -mlink-builtin-bitcode \
      -Xclang runtimes/runtimes-bins/libclc/nvptx64--.bc

A grep showed that this exact same code existed in three more places, so
I changed it there too, though I did not do a broader search for other
similar code that potentially has the same problem.
2025-06-25 16:37:06 +01:00
Simon Pilgrim
8202c94cec [CostModel][X86] getMaskedMemoryOpCost - widening masks must compute the cost of the full width insert_subvector across multiple legal vectors (#145693)
The memory value and mask value types might legalise differently - e.g. a v64i32 might split into 4 x v16i32 / 8 x v8i32 but the mask might legalize as 1 x v64i8 / 2 x v32i8 etc.

If the legalised value type has been split, then we must ensure we compute the cost for the entire mask value type and let getShuffleCost handle any legalisation, not assume that only a single trailing split mask will require widening.
2025-06-25 16:30:35 +01:00
Sameer Sahasrabuddhe
81e07996aa [AMDGPU][SIInsertWaitcnts] don't crash when printing messages at end of block (#145694) 2025-06-25 20:59:55 +05:30
Jake Egan
60285d98ef [asan] Implement address sanitizer on AIX: build configuration (#139583)
Update asan build configuration for AIX:
- Adds import lists
- Guards shared library code

Issue: #138916

---------

Co-authored-by: Hubert Tong <hubert.reinterpretcast@gmail.com>
2025-06-25 11:26:39 -04:00
Craig Topper
c3b160bcaa [RISCV] Remove -mattr=+no-rvc-hints (#145138)
As far as I know binutils does not have a similar option and I don't
know of a reason we shouldn't accept the RVC hint instructions.

The wording in the spec in the past suggested that maybe these
weren't valid instruction names, but that's been modified recently.
2025-06-25 08:24:24 -07:00
David Green
2dfcc30e38 [AArch64] Add tests for inefficient LD1lanePost. NFC 2025-06-25 16:21:34 +01:00
Krzysztof Parzyszek
77a3ae5845 [flang][OpenMP] Remove recognition of versions 3.0 and older (#145708)
The oldest supported version is now 3.1. In terms of semantic analysis
the compiler treats all versions <= 4.5 identically, and there is no
plan to add version-specific checks for older versions.

See discourse thread:

https://discourse.llvm.org/t/rfc-remove-openmp-versions-prior-to-3-1/86901
2025-06-25 10:20:52 -05:00
Jake Egan
287b24e189 [asan] Implement address sanitizer on AIX: address descriptions (#138891)
Adapt address description logic for AIX. 

Issue: https://github.com/llvm/llvm-project/issues/138916
2025-06-25 11:18:15 -04:00
Momchil Velikov
ea1e181571 [MLIR][AArch64] Lower vector.contract with mixed signed/unsigned arguments to Neon FEAT_I8MM (#144698) 2025-06-25 16:10:02 +01:00
Alexis Engelke
36819eaed1 [llvm-objdump] Support --symbolize-operand on AArch64
Similar to the existing implementations for X86 and PPC, support
symbolizing branch targets for AArch64. Do not omit the address for ADRP
as the target is typically not at an intended location.

Pull Request: https://github.com/llvm/llvm-project/pull/145009
2025-06-25 17:09:25 +02:00
Ming Yan
10edc3df99 [RISCV] Try to optimize vp.splice to vslide1up. (#144871)
Fold (vp.splice (insert_elt poison, scalar, 0), vec, 0, mask, 1, vl)
to (vslide1up vec, scalar, mask, vl).

Fold (vp.splice (splat_vector scalar), vec, 0, mask, 1, vl)
to (vslide1up vec, scalar, mask, vl).
2025-06-25 23:03:20 +08:00
Matt Arsenault
020fefb6af AMDGPU: Avoid report_fatal_error in image intrinsic lowering (#145201) 2025-06-26 00:00:36 +09:00
Kazu Hirata
75de95ddd2 [Option] Use llvm::interlaved (NFC) (#145642)
Note that llvm::interleaved constructs a string with the elements from
a given range with a given separator.
2025-06-25 07:58:40 -07:00
Kazu Hirata
817c097887 [Analysis] Drop const from a return type (NFC) (#145641)
We do not need const on a return type.
2025-06-25 07:58:33 -07:00
Kazu Hirata
050f6283ee [AMDGPU] Drop const from return types (NFC) (#145640)
We don't need const on these return types.
2025-06-25 07:58:25 -07:00
Matt Arsenault
fb6882719a Triple: Remove workaround for gcc 4.0.3 (#145660)
Use the Twine version instead of manually building a string
2025-06-25 23:57:56 +09:00
Scott Linder
c9910d5ef8 [LangRef] Clarify definition of fragments (#145582)
Try to give a more complete description of what we call a "fragment",
and how debug records interact when fragments are involved.
2025-06-25 10:54:51 -04:00
Kazu Hirata
096cad59df [Serialization] Fix a warning
This patch fixes:

  clang/unittests/Serialization/SourceLocationEncodingTest.cpp:39:34:
  error: unused variable 'Biggest' [-Werror,-Wunused-const-variable]
2025-06-25 07:53:24 -07:00
Samarth Narang
b8e8ff3dd6 [Clang] Implement diagnostics for why is_empty is false (#145044)
Expands on https://github.com/llvm/llvm-project/issues/141911
2025-06-25 10:34:51 -04:00
Haojian Wu
a945fb1481 [clang] NFC, move the SourceLocationEncoding.h header guard to the begining of the file 2025-06-25 16:26:40 +02:00