572951 Commits

Author SHA1 Message Date
Lang Hames
c6626f0b70
[orc-rt] Add LockedAccess utility. (#186737)
LockedAccess provides pointer-like access to a value while holding a
lock. All accessors are rvalue-ref-qualified, restricting usage to
temporaries to prevent accidental lock lifetime extension. A with_ref
method is provided for multi-statement critical sections.
2026-03-16 16:40:34 +11:00
Chinmay Deshpande
696e82db33
[clang] Skip dllexport of inherited constructors with unsatisfied constraints (#186497)
When a class is marked `__declspec(dllexport)`, Clang eagerly creates
inherited constructors via `findInheritingConstructor` and propagates
the dllexport attribute to all members. This bypasses overload
resolution, which would normally filter out constructors whose requires
clause is not satisfied. As a result, Clang attempted to instantiate
constructor bodies that should never be available, causing spurious
compilation errors.

Add constraint satisfaction checks in `checkClassLevelDLLAttribute` to
match MSVC behavior:

1. Before eagerly creating inherited constructors, verify that the base
constructor's `requires` clause is satisfied. Skip creation otherwise.

2. Before applying dllexport to non-inherited methods of class template
specializations, verify constraint satisfaction. This handles the case
where `dllexport` propagates to a base template specialization whose own
members have unsatisfied constraints.

Inherited constructors skip the second check since their constraints
were already verified at creation time.

Fixes #185924

Followup to https://github.com/llvm/llvm-project/pull/182706

Assisted by: Cursor // Claude Opus 4.6
2026-03-15 19:35:04 -07:00
wanglei
655d5e7f69
[lld][ELF] Fix crash when relaxation pass encounters synthetic sections
In LoongArch and RISC-V, the relaxation pass iterates over input sections
within executable output sections. When a linker script places a synthetic
section (e.g., .got) into such an output section, the linker would crash
because synthetic sections do not have the relaxAux field initialized.

The relaxAux data structure is only allocated for non-synthetic sections
in initSymbolAnchors. This patch adds the necessary null checks in the
relaxation loops (relaxOnce and finalizeRelax) to skip sections that
do not require relaxation.

A null check is also added to elf::initSymbolAnchors to ensure the
subsequent sorting of anchors is safe.

Fixes: #184757

Reviewers: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/184758
2026-03-16 10:06:34 +08:00
wanglei
f46a515385
[LoongArch] Remove unreachable Value check in fixupLeb128 (#186297)
Value is guaranteed to be zero after the loop:

  for (I = 0; Value; ++I, Value >>= 7)

Therefore the subsequent `if (Value)` condition is always false.
Remove the unreachable code. Reported by PVS-Studio.

Fixed: #170122
2026-03-16 09:16:55 +08:00
Lang Hames
6e6a46b14d
[orc-rt] Add a simple iterator_range class. (#186720)
This will be used to simplify operations on iterator ranges in the ORC
runtime.
2026-03-16 12:00:41 +11:00
Min-Yih Hsu
4c5b1c4e96
[RISCV] Add sifive-x160 and sifive-x180 processor definitions (#186264)
This PR adds new processor definitions for two SiFive cores:
- X160
(https://www.sifive.com/document-file/sifive-intelligence-x160-gen2-product-brief):
A RV32 core with Zve32f
- X180
(https://www.sifive.com/document-file/sifive-intelligence-x180-gen2-product-brief):
A RVV-capable RV64 core

Both of them have VLEN=128.

Scheduling model supports will be added in follow-up patches.
2026-03-15 17:18:08 -07:00
Henry Jiang
8767bdba10
[NFC] Delete MCPseudoProbeDecoder's move constructor (#186698)
`MCPseudoProbeDecoder` cannot be copeied/moved due to its address
dependence on the DummyInlineRoot member address. Explicitly delete the move constructor.
2026-03-15 16:38:17 -07:00
Pedro Lobo
70cd2acbd3
Revert "[IR] Add initial support for the byte type" (#186713)
Reverts llvm/llvm-project#178666 to unblock CI.
`CodeGen/X86/byte-constants.ll` is at fault. 
Will look into it and hopefully fix it by tomorrow.
2026-03-15 23:29:21 +00:00
Lang Hames
b0df9a366a
[orc-rt] Fix unittests after 53a1e056f38. (#186711)
Updates unittests to reflect Service interface changes.
2026-03-16 10:28:39 +11:00
Baranov Victor
7aeb01f01f
[clang-tidy][NFC] Use universal memory mock for smart ptrs (#186649) 2026-03-15 23:09:10 +00:00
Lang Hames
53a1e056f3
[orc-rt] Don't return Error in Service::OnComplete. (#186708)
The Session can't do anything useful with these errors, it can only
report them. It's cleaner if the Service objects just report the error
directly.
2026-03-16 09:01:18 +11:00
Pedro Lobo
80f2ef70f5
[IR] Add initial support for the byte type (#178666)
Following the [byte type RFC](https://discourse.llvm.org/t/rfc-add-a-new-byte-type-to-llvm-ir/89522)
and the discussions within the [LLVM IR Formal Specification WG](https://discourse.llvm.org/t/rfc-forming-a-working-group-on-formal-specification-for-llvm/89056), this PR introduces initial support for the byte type in LLVM. This PR:
- Adds the byte type to LLVM's type system
- Extends the `bitcast` instruction to accept the byte operands
- Adds parsing tests for all new functionality
- Fixes failing regressions tests (IR2Vec and IRNormalizer)

---------

Co-authored-by: George Mitenkov <georgemitenk0v@gmail.com>
2026-03-15 21:56:06 +00:00
Alexis Engelke
36041192cf
[IR] Don't allow successors() over block without terminators (#186646)
There's no point constructing a dominator tree or similar on
known-broken IR. Generally, functions should be able to assume that IR
is valid (i.e., passes the verifier). Users of this "feature" were:

- Verifier, fixed by verifying existence of terminators first.
- FuzzMutate, worked around by temporarily inserting terminators.
- OpenMP to run analyses while building the IR, worked around by
temporarily inserting terminators.
- Polly to work with an empty dominator tree, fixed by temporarily
adding an unreachable inst.
- MergeBlockIntoPredecessor, inadvertently, fixed by adding terminator
before updating MemorySSA.
- Some sloppily written unit tests.
2026-03-15 20:34:38 +00:00
Nico Weber
de81419c31 [gn] port f002fc0ee8734283 2026-03-15 16:22:20 -04:00
Nico Weber
dc1f7c703d [gn] port 629edaf67844c01db37 (CLANG_USE_XCSELECT) 2026-03-15 16:18:55 -04:00
Aiden Grossman
562f519c15
[libc][Github] Bump clang in libc container to v23 (#186697)
Back to HEAD now that apt.llvm.org is working again for ToT.
2026-03-15 19:48:28 +00:00
Kit Dallege
906f2b6cff
[Clang][Docs] Clarify [[unlikely]] example in compound statement (#186590)
The first code example in the "confusing standard behavior" section
had a comment claiming `[[unlikely]]` makes the branch unlikely,
contradicting a later example showing the same placement being ignored.

Rewords the comment to clarify this is the C++ Standard's
recommendation that Clang does not follow, since the attribute is not on
the substatement.

Continues the work from #126372.

Fixes #126362.
2026-03-15 19:31:54 +00:00
Rajveer Singh Bharadwaj
89c331560e
[clang][doc] Improve error handling for LibTooling example code avoiding core dump (#98129)
Resolves #97983
2026-03-15 20:04:17 +01:00
Aiden Grossman
dcbbfb26cb [Utils] Format git-llvm-push
Use single quotes for string arguments inside f-strings or otherwise the
version of black that we use fails to parse. Also reformat the file
given that hasn't been working for a while (wholesale or incrementally)
to the above issue.
2026-03-15 18:51:26 +00:00
Baranov Victor
fee5075b16
[clang-tidy][NFC] Use universal type_traits mock (#186652) 2026-03-15 21:49:57 +03:00
Alexis Engelke
37acbb5b47
[BPF] Use ".L" local prefix label for basic blocks (#95103)
Previously, PrivateLabelPrefix was default-initialized to "L", so basic
block labels were added to the symbol table. This seems like an
oversight, so use ".L" for all private labels.
2026-03-15 19:28:00 +01:00
Mend Renovate
bc5ac5f3eb
Update GitHub Artifact Actions (major) (#184052)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[actions/download-artifact](https://redirect.github.com/actions/download-artifact)
| action | major | `v7.0.0` → `v8.0.1` |
|
[actions/upload-artifact](https://redirect.github.com/actions/upload-artifact)
| action | major | `v6.0.0` → `v7.0.0` |
|
[actions/upload-artifact](https://redirect.github.com/actions/upload-artifact)
| action | major | `6.0.0` → `7.0.0` |
2026-03-15 10:22:07 -07:00
Simon Pilgrim
41d5163a5b
[X86] combineConcatVectorOps - concat(vtruncus(smax(x,0)),vtruncus(smax(y,0))) -> packus(shuffle(x,y),shuffle(x,y)) (#186681)
Followup to vtruncs/packss handling
2026-03-15 17:15:40 +00:00
srcarroll
9e22690671
Revert "Support float8_e3m4 and float8_e4m3 in np_to_memref (#186453)" (#186677)
This reverts commit 57427f84fe5fdda71aef4be257ed28d7b4f55d05.

For some reason mlir-nvidia CI is failing to import `float8_e3m4` from
`ml_dtypes`. See
https://lab.llvm.org/buildbot/#/builders/138/builds/27095.
2026-03-15 11:52:59 -05:00
Aiden Grossman
27dd55b2cb Revert "[CI] Try lowering max parallel link jobs on Windows (#185255)"
This reverts commit af22b50fac2311ff3f859e4e8bdec552c7aa8d5a.

This seems to have had no noticeable effect on the frequency of failures
so likely was not the issue.
2026-03-15 16:49:58 +00:00
Simon Pilgrim
5ccfc9d6b9
[X86] combineConcatVectorOps - concat(vtruncs(x),vtruncs(y)) -> packss(shuffle(x,y),shuffle(x,y)) (#186678)
Although at worst this isn't a reduction in instruction count, the shuffle/packss sequence is much easier for further folds / shuffle combining
2026-03-15 16:41:49 +00:00
Alexis Engelke
211279d11c
[CodeGenPrepare][NFC] Get BPI/BFI from pass/analysis manager (#186651)
BranchProbabilityInfo will compute it's own dominator tree and
post-dominator tree if none is specified; avoid this by using the
analysis manager/pass manager to get the analysis, which will reuse the
previously computed DomTree.
2026-03-15 17:41:22 +01:00
Alexis Engelke
d2ffc11f6b
[CFG][InstCombine][NFC] Use block numbers when finding backedges (#186668)
The functions traverse all basic blocks, so SmallPtrSets use a single
vector indexed by block number.
2026-03-15 16:45:25 +01:00
Alexis Engelke
dab1e30d39
[SimplifyCFG][NFC] Renumber blocks when changing func (#186666)
Keep numbering dense when changing the function. SimplifyCFG is a good
candidate, because it is likely to remove blocks and preserves few
analyses.
2026-03-15 16:45:01 +01:00
Alexis Engelke
926bea91c1
[Transforms/Utils][NFC] Replace SmallPtrSet with vector (#186664)
Typically most blocks in a function are reachable, so use a vector
indexed by block number instead of a SmallPtrSet.
2026-03-15 16:44:52 +01:00
srcarroll
57427f84fe
Support float8_e3m4 and float8_e4m3 in np_to_memref (#186453)
This patch adds support for `float8_e3m4` and `float8_e4m3` in
`np_to_memref.py` by adding the appropriate ctypes structures
2026-03-15 09:35:32 -05:00
Simon Pilgrim
ed6fc49280
[X86] known-never-zero.ll - add vector test coverage for #186335 (#186660) 2026-03-15 12:52:04 +00:00
Berkay Sahin
b751719170
[clang-tidy] Adds do-while support to performance-inefficient-string-concatenation (#186607)
Closes #186362

---------

Co-authored-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
2026-03-15 19:31:44 +08:00
Simon Pilgrim
f8b2bc6501
[X86] Add missing VPSRAQ broadcast-from-mem patterns for non-VLX targets (#186654) 2026-03-15 10:59:06 +00:00
Balázs Benics
cbcfa444c8
[clang][ssaf][NFC] Prefix ssaf-{linker,format} dirs with 'clang-' (#186610)
Addresses:
https://github.com/llvm/llvm-project/pull/185631#issuecomment-4054586633
2026-03-15 10:22:14 +00:00
Tomáš Slanina
a7aebd809d
[clang-format] Add option AllowShortRecordOnASingleLine (#154580)
This patch supersedes PR #151970 by adding the option
``AllowShortRecordOnASingleLine`` that allows the following formatting:
```c++
  struct foo {};
  struct bar { int i; };
  struct baz
  {
    int i;
    int j;
    int k;
  };
```

---------

Co-authored-by: owenca <owenpiano@gmail.com>
2026-03-15 02:52:30 -07:00
Alexis Engelke
92f9df14dd
[Analysis][NFC] Move BranchProbabilityInfo constr to cpp (#186648)
The implementation details of the analysis are irrelevant for users,
therefore move these to the .cpp file.
2026-03-15 10:17:06 +01:00
Alexis Engelke
bd933ccd6f
[CMake] Disable PCH reuse for plugins in non-PIC builds (#186643)
Plugins are always PIC and therefore cannot reuse non-PIC PCH.
2026-03-15 07:52:21 +00:00
Timm Baeder
4743e714c1
[clang][bytecode] Remove unused members from EvalEmitter (#186601)
Remove the DenseMap handling lambda paramter mappings from
`EvalEmitter`. This was always unused. Remove it and use `if constexpr`
to keep things compiling.
2026-03-15 08:23:18 +01:00
Ivan
27e4ef689a
[clang-format] Upgrade ShortFunctionStyle to a struct (#134337)
The current clang-format configuration
option AllowShortFunctionsOnASingleLine uses a single enum
(ShortFunctionStyle) to control when short function definitions can be
merged onto a single line. This enum provides predefined combinations of
conditions
(e.g., None, Empty only, Inline only, Inline including Empty, All).

This approach has limitations:

1. **Lack of Granularity:** Users cannot specify arbitrary combinations
of conditions. For example, a user might want to allow merging
for both empty functions and short top-level functions, but not for
short functions defined within classes. This is not possible with the
current enum options except by choosing All, which might merge more than
desired.

2. **Inflexibility:** Adding new conditions for merging (e.g.,
distinguishing between member functions and constructors, handling
lambdas specifically) would require adding many new combined enum
values, leading to a combinatorial explosion and making the
configuration complex.

3. **Implicit Behavior:** Some options imply others
(e.g., Inline implies Empty), which might not always be intuitive or
desired.

The goal is to replace this single-choice enum with a more flexible
mechanism allowing users to specify a set of conditions that must be met
for a short function to be merged onto a single line.

---------

Co-authored-by: owenca <owenpiano@gmail.com>
2026-03-14 23:01:07 -07:00
Krzysztof Drewniak
16b6af32eb
[mlir] Fix op comparisons in extensible dialects (#186637)
The extensible dialect system defined `compareProperties` to false
because it doesn't use properties. However, this should have been
`true`, as the empty properties are trivially always equal to
themselves. Doing otherwise means that no operations in extensible
dialects that aren't the exact same operation will ever compare equal
for the purposes of operations like CSE.
2026-03-14 22:39:50 -07:00
Lang Hames
98ccac607a
[orc-rt] Return ref from Session::addService, add createService. (#186640)
Session::addService now returns a reference to the added Service. This
allows clients to hold a reference for further direct interaction with
the Service object.

This commit also introduces a new Session::createService convenience
method that creates the service and returns a reference to it.
2026-03-15 15:07:16 +11:00
Lang Hames
96e7fc2c9a
[orc-rt] Rename "ResourceManager" to "Service". NFCI. (#186639)
The name "Service" better reflects the general purpose of this class: It
provides *something* (often resource management) to the Session, is
owned by the Session, and receives notifications from the Session when
the controller detaches / is detached, and when the Session is shut
down.

An example of a non-resource-managing Service (to be added in an
upcoming patch) is a detach / shutdown notification service: Clients can
add this service to register arbitrary callbacks to be run on detach /
shutdown. The advantage of this over the current Session detach /
shutdown callback system is that clients can control both the order of
the callbacks, and their order relative to notification of other
services.
2026-03-15 14:37:48 +11:00
Jake Egan
3fea2f6165
[libc++][test] Use loop with compare_exchange_weak calls (#185953)
On AIX, this test sometimes fails with error `Assertion failed: y ==
true`. The test assumes `compare_exchange_weak` should succeed on a
single call, however according to the standard:

> A weak compare-and-exchange operation may fail spuriously. That is,
even when the contents of memory referred to by expected and ptr are
equal, it may return false and store back to expected the same memory
contents that were originally there.
This spurious failure enables implementation of compare-and-exchange on
a broader class of machines, e.g., load-locked store-conditional
machines. A consequence of spurious failure is that nearly all uses of
weak compare-and-exchange will be in a loop.

[atomics.ref.ops]/27
2026-03-14 22:34:48 -04:00
Twice
044776691a
[MLIR][Python] Refine the behavior of Python-defined dialect reloading (#186128)
This includes several changes:
- `Dialect.load(reload=False)` will fail if the dialect was already
loaded in a different context. To prevent the further program abortion.
- `Dialect.load(reload=True)` implies `replace=True` in
dialect/operation registering.
- `PyGlobals::registerDialectImpl` now has a parameter `replace`.
- `register_dialect` and `register_operation` is no longer exposed in
`mlir.dialects.ext`.

This should solve the registering problem found in writing transform
test cases by @rolfmorel.
2026-03-15 10:25:24 +08:00
Craig Topper
69780be1d4
[AggressiveInstCombine] Recognize table based log2 and replace with ctlz+sub. (#185160)
Recognize table based log2 implementations like

```
unsigned log2(unsigned v) {
  static const unsigned char table[] = {
    0,  9,  1, 10, 13, 21,  2, 29, 11, 14, 16, 18, 22, 25,  3, 30,
    8, 12, 20, 28, 15, 17, 24,  7, 19, 27, 23,  6, 26,  5,  4, 31
  };

  v |= v >> 1;
  v |= v >> 2;
  v |= v >> 4;
  v |= v >> 8;
  v |= v >> 16;

  return table[(unsigned)(v * 0x07C4ACDDU) >> 27];
}
```

and replaces with 31 - llvm.ctlz(v).

Similar for i64 log2. Other sizes can be supported with correct multiply
constant and table values, but I have not found examples yet.

This code is based on the existing tryToRecognizeTableBasedCttz. Like
that function, we support
any combination of multiply constant and table values that produce the
correct result.

It handles the same pattern as #177110, but does not match the outer
subtract from that patch. It is assumed that InstCombine or other
optimizations can combine (sub 31 (sub 31, cttz V)) later.

I have limited this to targets that have a fast ctlz. The backend does
not yet have a table based lowering for ctlz so this reduces the chance
of regressions.
2026-03-14 17:38:56 -07:00
Henrich Lauko
3bc216c29c
[CIR] Split CIR_UnaryOp into individual operations (#185280)
Split the monolithic cir.unary operation (which dispatched on a
UnaryOpKind enum) into four separate operations: cir.inc, cir.dec,
cir.minus, and cir.not.

Changes:
- Add CIR_UnaryOpInterface with getInput()/getResult() methods
- Add CIR_UnaryOp and CIR_UnaryOpWithOverflowFlag base classes
- Define IncOp, DecOp, MinusOp, NotOp with per-op folds
- Add Involution trait to NotOp for not(not(x)) -> x folding
- Replace createUnaryOp() with createInc/Dec/Minus/Not builders
- Split LLVM lowering into four separate patterns
- Split LoweringPrepare complex-type handling per unary op
- Update CIRCanonicalize and CIRSimplify for new op types
- Update all codegen files to use bool params instead of UnaryOpKind
- Remove CIR_UnaryOpKind enum and old CIR_UnaryOp definition

Assembly format change:
  cir.unary(inc, %x) nsw : !s32i, !s32i  ->  cir.inc nsw %x : !s32i
  cir.unary(not, %x) : !u32i, !u32i      ->  cir.not %x : !u32i
2026-03-14 23:50:43 +01:00
Daniil Dudkin
55db533b74
[clang-tidy] Add redundant qualified alias check (#180404)
Introduce `readability-redundant-qualified-alias` to flag identity type
aliases that repeat a qualified name and suggest using-declarations when
safe. The check is conservative: it skips macros, elaborated keywords,
dependent types, and templates. `OnlyNamespaceScope` controls whether
local/class scopes are included (default `false`).

Depends on: #183940 #183941
2026-03-15 01:18:25 +03:00
Carlo Cabrera
629edaf678
[clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (#119670)
This is a scaled down version of https://reviews.llvm.org/D136315.

The intent is largely the same as before[^1], but I've scaled down the
scope to try to avoid the issues that the previous patch caused:
- the changes are now opt-in based on enabling `CLANG_USE_XCSELECT`
- this only works when targeting macOS on a macOS host (this is the only
case supported by `libxcselect`[^2])
- calling `libxcselect` is done only when the target is `*-apple-macos*`
to avoid breaking many tests

Another reason to leave this as opt-in for now is that there are some
bugs in libxcselect that need fixing before it is safe to use by default
for all users. This has been reported to Apple as FB16081077.

[^1]: See also https://reviews.llvm.org/D109460 and #45225.
[^2]: https://developer.apple.com/documentation/xcselect?language=objc
2026-03-14 22:00:56 +00:00
Sharjeel Khan
5f479438dd
[libc++][Android] Update Compiler for Android CI (#186531)
Upgrade Android compiler from r563880 to r584948b because libc++ does
not support LLVM 20 anymore
2026-03-14 14:48:08 -07:00