Commit Graph

540234 Commits

Author SHA1 Message Date
Kazu Hirata
0613f8b9e4 [clang-move] Teach getDeclarationList to return ArrayRef (NFC) (#143278)
getDeclarationList is used only for read-only access to the array.  I
don't think it's actually meant to return by value.
2025-06-08 01:34:02 -07:00
Fangrui Song
38658b54b2 LanaiMCExpr: Migrate to MCSpecifierExpr 2025-06-08 00:26:26 -07:00
Fangrui Song
ef328e97db MipsMCExpr: Migrate to MCSpecifierExpr 2025-06-08 00:20:49 -07:00
Corentin Jabot
5c76ae2894 [Clang] Support constexpr asm at global scope. (#143268)
I previously failed to realize this feature existed...

Fixes #137459
Fixes #143242
2025-06-08 09:16:57 +02:00
Fangrui Song
39064519cb AVRMCExpr: Migrate to MCSpecifierExpr 2025-06-08 00:15:32 -07:00
Fangrui Song
2f1c08215f SystemZMCExpr: Migrate to MCSpecifierExpr 2025-06-08 00:10:15 -07:00
Fangrui Song
ce270b495d MCExpr: Move isSymbolUsedInExpression workaround to AMDGPU
This function was a workaround used to detect cyclic dependency
(properly resolved by 343428c666).
We do not want backends to use it. However, #112251 exposed it to MCExpr
to be reused by AMDGPU. Keep the workaround within AMDGPU to prevent
other backends from accidentally relying on it.
2025-06-08 00:02:27 -07:00
flovent
239c8ac268 [clang-tidy] Fix false positives with deducing this in readability-convert-member-functions-to-static check (#141391)
Add check for `DeclRefExpr` which points to an explicit object
parameter.

Fixes #141381.

---------

Co-authored-by: fubowen <fubowen@protomail.com>
Co-authored-by: flovent <flbven@protomail.com>
2025-06-08 09:58:24 +03:00
Fangrui Song
532facc78e ARMMCExpr: Migrate to MCSpecifierExpr 2025-06-07 23:32:18 -07:00
Fangrui Song
49a706d8ef MCSpecifierExpr: Make dtor defaulted 2025-06-07 23:25:29 -07:00
Fangrui Song
8eac7f5a81 PPCMCExpr: Migrate to MCSpecifierExpr 2025-06-07 23:01:29 -07:00
Fangrui Song
cdd0a6c781 BOLT: Replace MCTargetExpr with MCSpecifierExpr to fix bolt-icf.test on aarch64 host 2025-06-07 22:35:20 -07:00
Fangrui Song
4a6b4d3894 RISCVMCExpr: Migrate to MCSpecifierExpr 2025-06-07 22:14:28 -07:00
Fangrui Song
beaa98bf80 AArch64MCExpr: Migrate to MCSpecifierExpr 2025-06-07 21:53:55 -07:00
Owen Pan
897ccddcc3 [clang-format][NFC] Clean up fillRanges() in ClangFormat.cpp (#143236) 2025-06-07 20:59:53 -07:00
AZero13
7730853fa1 [SelectionDAG] Use DAG.getSelect (NFC) (#143276) 2025-06-08 10:27:10 +09:00
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