Commit Graph

540368 Commits

Author SHA1 Message Date
Fangrui Song
00a1318d9a LoongArchMCExpr: Migrate to MCSpecifierExpr 2025-06-07 17:42:18 -07:00
Fangrui Song
df46140bab XtensaMCExpr: Migrate to MCSpecifierExpr 2025-06-07 17:36:30 -07:00
Fangrui Song
e997eb4c39 VEMCExpr: Migrate to MCSpecifierExpr
Follow-up to 97a32f2ad9
2025-06-07 17:30:42 -07:00
Florian Hahn
24bd4e59b9 [VPlan] Use regular phi printing for resume phis.
As discussed in https://github.com/llvm/llvm-project/pull/140405, remove
custom printing for resume-phis and update tests.
2025-06-07 21:49:54 +01:00
Carlos Galvez
30d8aebbe2 [clang-tidy] Add option to disable bugprone-multi-level-pointer-conversion in C code (#141209)
Sometimes a project may want to enable this check only in C++, and
disable it in C, since the patterns the check warns about are quite
common and idiomatic in C, and there are no better alternatives.
    
Fixes #140659

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
2025-06-07 21:52:23 +02:00
Fangrui Song
97a32f2ad9 MC: Add MCSpecifierExpr to unify target MCExprs
Many targets define MCTargetExpr subclasses just to encode an expression
with a relocation specifier. Create a generic MCSpecifierExpr to be
inherited instead. Migrate M68k and SPARC as examples.
2025-06-07 11:33:40 -07:00
Andrzej Warzyński
b4b86a7a3c [mlir][linalg] Refactor vectorization hooks to improve code reuse (#141244)
This patch refactors two vectorization hooks in Vectorization.cpp:
 * `createWriteOrMaskedWrite` gains a new parameter for write indices,
   aligning it with its counterpart `createReadOrMaskedRead`.
 * `vectorizeAsInsertSliceOp` is updated to reuse both of the above
   hooks, rather than re-implementing similar logic.

CONTEXT
-------
This is effectively a refactoring of the logic for vectorizing
`tensor.insert_slice`. Recent updates added masking support:
  * https://github.com/llvm/llvm-project/pull/122927
  * https://github.com/llvm/llvm-project/pull/123031

At the time, reuse of the shared `create*` hooks wasn't feasible due to
missing parameters and overly rigid assumptions. This patch resolves
that and moves us closer to a more maintainable structure.

CHANGES IN `createWriteOrMaskedWrite`
-------------------------------------
* Introduces a clear distinction between the destination tensor and the
  vector to store, via named variables like `destType`/`vecToStoreType`,
  `destShape`/`vecToStoreShape`, etc.
* Ensures the correct rank and shape are used for attributes like
  `in_bounds`. For example, the size of the `in_bounds` attr now matches
  the source vector rank, not the tensor rank.
* Drops the assumption that `vecToStoreRank == destRank` - this doesn't
  hold in many real examples.
*  Deduces mask dimensions from `vecToStoreShape` (vector) instead of
   `destShape` (tensor). (Eventually we should not require
`inputVecSizesForLeadingDims` at all - mask shape should be inferred.)

NEW HELPER: `isMaskTriviallyFoldable`
-------------------------------------
Adds a utility to detect when masking is unnecessary. This avoids
inserting redundant masks and reduces the burden on canonicalization to
clean them up later.

Example where masking is provably unnecessary:
```mlir
%2 = vector.mask %1 {
  vector.transfer_write %0, %arg1[%c0, %c0, %c0, %c0, %c0, %c0]
    {in_bounds = [true, true, true]}
    : vector<1x2x3xf32>, tensor<9x8x7x1x2x3xf32>
} : vector<1x2x3xi1> -> tensor<9x8x7x1x2x3xf32>
```

Also, without this hook, tests are more complicated and require more
matching.

VECTORIZATION BEHAVIOUR
-----------------------

This patch preserves the current behaviour around masking and the use
of`in_bounds` attribute. Specifically:
* `useInBoundsInsteadOfMasking` is set when no input vector sizes are
  available.
* The vectorizer continues to infer vector sizes where needed.

Note: the computation of the `in_bounds` attribute is not always
correct. That
issue is tracked here:
* https://github.com/llvm/llvm-project/issues/142107

This will be addressed separately.

TEST CHANGES
-----------
Only affects vectorization of:

* `tensor.insert_slice` (now refactored to use shared hooks)

Test diffs involve additional `arith.constant` Ops due to increased
reuse of
shared helpers (which generate their own constants). This will be
cleaned up
via constant caching (see #138265).

NOTE FOR REVIEWERS
------------------
This is a fairly substantial rewrite. You may find it easier to review
`createWriteOrMaskedWrite` as a new method rather than diffing
line-by-line.

TODOs (future PRs)
------------------
Further alignment of `createWriteOrMaskedWrite` and
`createReadOrMaskedRead`:
  * Move `createWriteOrMaskedWrite` next to `createReadOrMaskedRead` (in
    VectorUtils.cpp)
  * Make `createReadOrMaskedRead` leverage `isMaskTriviallyFoldable`.
  * Extend `isMaskTriviallyFoldable` with value-bounds-analysis. See the
     updated test in transform-vector.mlir for an example that would
     benefit from this.
  * Address #142107

(*) This method will eventually be moved out of Vectorization.cpp, which
isn't the right long-term home for it.
2025-06-07 19:25:30 +01:00
Fangrui Song
fe3760eb03 NVPTX: Implement printMCExpr with generic print
3d2a976197 (2015) copied and adapted
the generic printer to reduce parentheses, which is unnecessary after #133674.
2025-06-07 11:02:45 -07:00
Rahul Joshi
7dbae40c94 [NFC][Clang] Adopt simplified getTrailingObjects in ParsedTemplate (#143255) 2025-06-07 09:56:45 -07:00
Rahul Joshi
6615ec6084 [NFC][Clang] Adopt simplified getTrailingObjects in ExprObjC (#143254) 2025-06-07 09:56:24 -07:00
Rahul Joshi
3ebb91d3c8 [NFC][Clang] Adopt simplified getTrailingObjects in ExprConcepts (#143252) 2025-06-07 09:56:05 -07:00
Rahul Joshi
3bf2aece83 [NFC][Clang] Adopt simplified getTrailingObjects in StmtCXX (#143251) 2025-06-07 09:55:44 -07:00
Nick Sarnie
56b98449c8 [clang][AST] Fix spaces in TypePrinter for some calling convs (#143160)
There needs to be a space as the first character, otherwise the printed
function prototype will have the CC attribute attached to the final `)`.

I noticed this looking at the AST for a function with
`__attribute__((device_kernel))`

---------

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-06-07 16:47:28 +00:00
Rahul Joshi
de256ac8fb [NFC][Clang] Adopt simplified getTrailingObjects in StmtObjC (#143256) 2025-06-07 09:36:51 -07:00
Fangrui Song
b4382a2c46 SPARC: Modernize AsmBackend
* Move implementations out-of-line to align with other backends.
* clang-format the class.
2025-06-07 09:35:19 -07:00
Fangrui Song
469d1034dc SPARC,test: Refactor error checking
* Test line/column
* Remove copied source lines from diagnostics
2025-06-07 09:21:02 -07:00
Jesse Huang
893fa06280 [RISC-V] Adjust trampoline code for branch control flow protection (#141949)
Trampoline will use a alternative sequence when branch CFI is on.
The stack of the test is organized as follow
```
   56 $ra
   44 $a0      f
   36 $a1      p
   32 00038067 jalr  t2
   28 010e3e03 ld    t3, 16(t3)
   24 018e3383 ld    t2, 24(t3)
   20 00000e17 auipc t3, 0
sp+16 00000023 lpad  0
```
2025-06-07 23:51:08 +08:00
Samarth Narang
d5704097fc Refactor clang doc comment structure (#142273)
This patch refactors CommentKind handling in clang-doc by introducing a
strongly typed enum class for better type safety and clarity. It updates
all relevant places, including YAML traits and serialization, to work
with the new enum. Additionally, it enhances the Mustache-based HTML
generation by fully supporting all comment kinds, ensuring accurate
structured rendering of comment blocks. The changes simplify future
maintenance, improve robustness by eliminating unchecked defaults, and
ensure consistency between generators.

Fixes https://github.com/llvm/llvm-project/issues/142083
2025-06-07 08:04:56 -07:00
Joseph Huber
0e2103ac5c [libc][NFC] Remove unused CMake for gpu math 2025-06-07 09:25:27 -05:00
Yanzuo Liu
b1d2d7c128 [Clang][Parse][NFC] Use llvm::function_ref<> instead of std::optional<llvm::function_ref<>> (#142906)
There is no need to distinguish between null `optional` and null
`function_ref` in this case.
2025-06-07 15:52:48 +02:00
Jason Eckhardt
bf53a49492 [GISel][NFC] Use ranged-for/enumerate in a few places. (#143185)
Follow-up to https://github.com/llvm/llvm-project/pull/143113.
2025-06-07 08:49:53 -05:00
Michał Górny
23d0c7348a [flang] Fix missing includes in lib/Lower/Support/Utils.cpp (#143196)
Fixes the build failure due to missing includes introduced in
f8dcb059ae.
2025-06-07 15:39:42 +02:00
Amr Hesham
995d74f866 [CIR] Implement folder for VecTernaryOp (#142946)
This change adds a folder for the VecTernaryOp

Issue https://github.com/llvm/llvm-project/issues/136487
2025-06-07 13:58:54 +02:00
Amr Hesham
bf51d583e4 [CIR] Upstream ShuffleOp for VectorType (#142288)
This change adds support for the Shuffle op for VectorType

Issue https://github.com/llvm/llvm-project/issues/136487
2025-06-07 13:56:36 +02:00
Andreas Jonson
5e9527b644 [InstCombine] Add/Update test for #142263 (NFC) 2025-06-07 11:44:05 +02:00
Imad Aldij
bc931318a2 [Clang] Implement CWG2517 Useless restriction on use of parameter in constraint-expression (#132919)
Remove `[expr.prim.req.nested]` check which restrict that local
parameters in constraint-expressions can only appear as unevaluated
operands. This change makes the treatment of examples like `requires`
expressions and other constant expression contexts uniform, consistent
with the adoption of P2280.

References: https://cplusplus.github.io/CWG/issues/2517.html
Fixes  #132825

---------

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2025-06-07 11:31:04 +02:00
Jay Foad
432c5f2c60 [TableGen] Use emplace instead of insert and similar. NFC. (#143164) 2025-06-07 09:32:36 +01:00
Jay Foad
bb9dcb27df [TableGen] Use contains instead of count. NFC. (#143156) 2025-06-07 09:31:42 +01:00
Shamshura Egor
eec9431d37 [Clang] Added explanation why a is trivial copyable evaluated to false. (#142341) 2025-06-07 09:55:40 +02:00
Rainer Orth
3f8827eaba [OpenMP][cmake] Add SPARC support (#142364)
This patch adds SPARC infrastructure to the `openmp` `cmake` files,
matching what is done for other architectures.

Tested on `sparc-sun-solaris2.11`, `sparcv9-sun-solaris2.11`,
`sparc-unknown-linux-gnu`, `sparc64-unknown-linux-gnu`,
`i386-pc-solaris2.11`, `amd64-pc-solaris2.11`, `i686-pc-linux-gnu`, and
`x86_64-pc-linux-gnu`.
2025-06-07 09:55:05 +02:00
Hui
692c5cdb56 [libc++] Do not call reserve in flat containers if underlying container is user defined (#140379)
This is brought up in the LWG reflector. We currently call `reserve` if
the underlying container has one. But the spec does not specify what
`reserve` should do for Sequence Container. So in theory if the
underlying container is user defined type and it can have a function
called `reserve` which does something completely different.

The fix is to just call `reserve` for STL containers if it has one
2025-06-07 08:47:46 +01:00
Weining Lu
90a52f4942 [LoongArch] Pass OptLevel to LoongArchDAGToDAGISel correctly
Like many other targets did. And see RISCV for similar fix.

Fix https://github.com/llvm/llvm-project/issues/143239
2025-06-07 15:33:58 +08:00
Weining Lu
fcc82cfa93 [LoongArch] Precommit test case to show bug in LoongArchISelDagToDag
The optimization level should not be restored into O2.
2025-06-07 15:10:26 +08:00
Acthinks Yang
ca4dfca5c7 [InstCombine] Relax guard against FP min/max in select fold (#143144)
FCmp's commutativity predicates do not work with min/max semantics

Closes #142711
2025-06-07 14:26:43 +08:00
Kazu Hirata
4f304e2e72 [clang] Use llvm::count (NFC) (#143228) 2025-06-06 22:55:42 -07:00
Kazu Hirata
8829503f7a [FuzzMutate] Use llvm::any_of (NFC) (#143227)
Note that llvm::any_of can accommodate std::begin(Range), not just
Range.begin().
2025-06-06 22:55:34 -07:00
Kazu Hirata
0ef1e69f22 [clang] Strip away lambdas (NFC) (#143226)
We don't need lambdas here.
2025-06-06 22:55:26 -07:00
Kazu Hirata
477f9f6d92 [llvm] Call hash_combine_range with ranges (NFC) (#143225)
We can now invoke hash_combine_range with a range.
2025-06-06 22:55:19 -07:00
Kazu Hirata
d953ca5659 [Sema] Drop const from a return type (NFC) (#143224) 2025-06-06 22:55:11 -07:00
Owen Pan
0c495ce9c4 [clang-format] Handle function decls with MS calling conventions (#143083) 2025-06-06 20:43:35 -07:00
erichkeane
eed98e1493 [OpenACC][CIR] 'attach' clause lowering for combined/compute
Attach is identical to 'present', except it generates an acc.attach and
acc.detach.  This patch implements these, just like the preivous handful
of clauses.
2025-06-06 17:06:49 -07:00
Wenju He
8a51fb29b6 Revert "[Clang] Add resource_dir_EQ flag to CC1Option group (#140870)" (#142509)
This reverts commit c7b8d6e1dc.
Fix check-clang CodeGenTest.TestNonAlterTest regression, see
https://github.com/llvm/llvm-project/pull/140870#issuecomment-2931610238
2025-06-07 08:05:13 +08:00
Nuri Amari
6a21dfaac6 [llvm-cgdata] Fix Dangling StringRefs (#143210) 2025-06-06 20:02:40 -04:00
erichkeane
4eb72312e2 [OpenACC][CIR] Implement 'present' lowering for compute/combined
'present' has a data-in operation acc.present, and uses 'delete' for its
data out.  Otherwise it is identical to no_create.
2025-06-06 16:54:58 -07:00
erichkeane
b09b1d65ef [OpenACC][CIR] Implement lowering for 'no_create' clause for comp/comb
no_create has its own 'data-in', plus uses the 'delete' for the data-out
operation.  Additionally, like all data clauses it uses the 'async'
functionality previous implemented.  This patch implements no_create for
combined/compute constructs completely, and ensures that the feature is
tested.
2025-06-06 16:36:11 -07:00
Chenguang Wang
b7ef3e7a85 [bazel] Fix llvm-min-tblgen bazel build (#143213)
Broken by 7b2aa02a. Tested with:

    bazelisk build \
        @llvm-project//llvm:llvm-min-tblgen \
        @llvm-project//llvm:FrontendOpenACC \
        @llvm-project//llvm:FrontendOpenMP \
        @llvm-project//llvm:TableGen
2025-06-06 15:33:23 -07:00
Sam Elliott
65077c7ac7 [RISCV] Remove -riscv-asm-relax-branches flag (#142855)
This flag has been superseded by `.option exact`, as the test updates
show.

Given the flag was always hidden, it makes sense to me to remove it, and
move tests that required it to use `.option exact`.
2025-06-06 15:23:31 -07:00
Changpeng Fang
70e78be7dc AMDGPU: Custom lower fptrunc vectors for f32 -> f16 (#141883)
The latest asics support v_cvt_pk_f16_f32 instruction. However current
implementation of vector fptrunc lowering fully scalarizes the vectors,
and the scalar conversions may not always be combined to generate the
packed one.
We made v2f32 -> v2f16 legal in
https://github.com/llvm/llvm-project/pull/139956. This work is an
extension to handle wider vectors. Instead of fully scalarization, we
split the vector to packs (v2f32 -> v2f16) to ensure the packed
conversion can always been generated.
2025-06-06 15:15:24 -07:00
Krzysztof Parzyszek
7b2aa02a33 [utils][TableGen] Handle versions on clause/directive spellings (#143021)
In "get<lang>DirectiveName(Kind, Version)", return the spelling that
corresponds to Version, and in "get<lang>DirectiveKindAndVersions(Name)"
return the pair {Kind, VersionRange}, where VersionRange contains the
minimum and the maximum versions that allow "Name" as a spelling. This
applies to clauses as well. In general it applies to classes that have
spellings (defined via TableGen class "Spelling").

Given a Kind and a Version, getting the corresponding spelling requires
a runtime search (which can fail in a general case). To avoid generating
the search function inline, a small additional component of
llvm/Frontent was added: LLVMFrontendDirective. The corresponding header
file also defines C++ classes "Spelling" and "VersionRange", which are
used in TableGen/DirectiveEmitter as well.

For background information see

https://discourse.llvm.org/t/rfc-alternative-spellings-of-openmp-directives/85507
2025-06-06 17:07:25 -05:00
Thurston Dang
428afa62b0 [ubsan] Add more -fsanitize-annotate-debug-info checks (#141997)
This extends https://github.com/llvm/llvm-project/pull/138577 to more UBSan checks, by changing SanitizerDebugLocation (formerly SanitizerScope) to add annotations if enabled for the specified ordinals.

Annotations will use the ordinal name if there is exactly one ordinal specified in the SanitizerDebugLocation; otherwise, it will use the handler name.

Updates the tests from https://github.com/llvm/llvm-project/pull/141814.

---------

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2025-06-06 14:59:32 -07:00