573837 Commits

Author SHA1 Message Date
Aiden Grossman
ca3d04561b
[llubi][Github] Add llubi labelling support (#187877)
So that one can easily subscribe to llubi PRs which are currently not
labelled at all.
2026-03-22 11:01:45 -07:00
Alexandre Ganea
45039dfac4
[clang] On Windows, silence warning in CFGBackEdgesTest with MSVC (#187939)
This fixes:
```
[5804/7029] Building CXX object tools\clang\unittests\CMakeFiles\AllClangUnitTests.dir\Analysis\CFGBackEdgesTest.cpp.obj
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\xutility(721): warning C4018: '>': signed/unsigned mismatch
...
C:\git\llvm-project\clang\unittests\Analysis\CFGBackEdgesTest.cpp(170): note: see the first reference to 'testing::internal::PredicateFormatterFromMatcher<testing::internal::SizeIsMatcher<testing::internal::GtMatcher<int>>>::operator ()' in 'clang::analysis::`anonymous-namespace'::CFGBackEdgesTest_WhileWithContinueLoop_Test::TestBody'
```
2026-03-22 13:28:39 -04:00
Kavin Gnanapandithan
33a14cbe35
[RISCV] Add guard to prevent GPRPair merge on targets without Zdinx or P (#186600)
Resolves #186527.

The issue points out that GPRPair merge logic in the RISCVMoveMerger
pass was being called on a target without `zdinx` or `experimental-P`,
triggering an unreachable in `getGPRPairCopyOpcode`.

This patch fixes this issue by guarding `isEvenRegisterCopy` and
`isOddRegisterCopy` to return false when neither Zdinx nor P is present.
2026-03-22 10:26:33 -07:00
Alexey Bataev
88f830aed8 [SLP]Do not try to reduced instruction, marked for deletion in previous attempts
Need to skip instructions, which were vectorized and marked for deletion
to prevent a compiler crash
2026-03-22 10:10:48 -07:00
Fangrui Song
34bc5d580b
[MC,clang] Fix -Wa,--noexecstack not emitting .note.GNU-stack (#187880)
AsmPrinter (clang -c a.c) and AsmParser (clang -c a.s, llvm-mc
-filetype=obj a.s) have different ways to emit .note.GNU-stack section.

913c5b4d1fff removed a redundant initSections call from cc1as, but
that was the only place where NoExecStack was consumed for the
assembler path.

Unify the .note.GNU-stack emission in MCELFStreamer::finishImpl,
making the `initSections` parameter redundant.

Add a -filetype=obj test for Solaris (see
https://reviews.llvm.org/D159179), which doesn't use .note.GNU-stack

`initSections` has 20+ uses. The parameter cleanup will be deferred to a
subsequent change.

Fixes https://github.com/llvm/llvm-project/issues/186004
2026-03-22 16:58:31 +00:00
juan.vazquez
2566961cef
[clang-tidy] use-after-move: Support null_after_move annotations (#186903)
Extend the bugprone-use-after-move check to recognize user defined
smart-pointer-like types that make guarantees on the state of a
moved-from object, leaving it in a valid and specified state that
matches the standard smart pointer's moved-from state (nullptr), where
it is safe to use but not dereference.

Following the RFC discussion:

* Use `[[clang::annotate]]` to mark the types.
* Use an schema for the `[[clang::annotate]]` annotation and arguments
to help avoid conflicts with other users of the attribute.
* The annotation will identify the tool ("clang-tidy") and the arguments
the plugin ("bugprone-use-after-move"), and the behavior of the type
("null_after_move"). E.g.:

`[[clang::annotate("clang-tidy", "bugprone-use-after-move",
"null_after_move")]]`

RFC:
https://discourse.llvm.org/t/rfc-add-a-class-attribute-clang-null-after-move-for-use-after-move-analysis/89760
2026-03-22 19:42:24 +03:00
Dominik Steenken
6eb5ac52ca
[SystemZ] Remove custom lowering of f16 IS_FPCLASS (#187532)
As pointed out in #187518 , currently, `__builtin_isnormal` returns
`true` for subnormal half precision floating point numbers on `s390x.

This is because there is a custom lowering defined which lowers an `f16`
`IS_FPCLASS` ISD node by extending the `f16` value to `f32`, and then
using SystemZ's "test data class" instruction to determine whether the
number is subnormal. However, a number that is subnormal in 16 bits of
precision will no longer be subnormal in 32 bits of precision, and so
the test always returns true, i.e. all subnormal numbers are classified
as normal.

This PR addresses this by removing the custom lowering and instead
relying on the generic expansion of `IS_FPCLASS`, which does not have
this error.

Fixes #187518 .
2026-03-22 17:19:24 +01:00
Zihao Wang
b1cf9b0835
[Clang] Support constexpr for AVX512 compress intrinsics (#187656)
Fixes #163732
2026-03-22 14:27:27 +00:00
A. Jiang
26ee552ef5
[libc++] Fix includes in <string> for no-wchar_t modes (#187650)
Since befaa35212dbaac39cd76a8dc748e4df7c90a0d9, the CI stably failed for
the generic-no-wide-characters build, because in no-`wchar_t` modes, the
header for `__remove_cv_t` wasn't properly included.

This PR adds the missing include of `<__type_traits/remove_cv.h>`.

As drive-by, `<__cstddef/size_t.h>` and
`<__type_traits/is_constant_evaluated.h>`, which are included by
`<cwchar>`, are also made included by `<string>` to avoid potential
regression as we're using `size_t` and
`__libcpp_is_constant_evaluated()` in `<string>`.
2026-03-22 20:29:25 +08:00
Devajith
720abd76e7
[clang][AST] Fix assertion in getFullyQualifiedType for DecltypeType (#187725) 2026-03-22 13:19:41 +01:00
Martin Storsjö
4c4925f1a2
[LLD] [ELF] Make {bti,gcs}-report=none silence warnings from force-bti/gcs=always (#186343)
Previously, the implicit warnings from force-bti (or gcs=always) weren't
possible to silence.

The force-ibt/cet-report flags could also be handled the same way, but I
haven't checked with GNU ld how they behave. And there, the force-ibt
flag only produces warnings if the IBT bit is missing, while cet-report
warns if either IBT or SHSTK are missing - but force-ibt probably
shouldn't implicitly start warning for missing SHSTK.

This addresses a discrepancy to GNU ld that was noted in #186173.
2026-03-22 14:17:52 +02:00
Berkay Sahin
b4084bd213
[clang] Detect pointee mutations in placement new expressions (#187508)
Fixes #187012 which is a false positive on clang-tidy end.
2026-03-22 12:22:17 +01:00
SiliconA-Z
a0d5508563
[X86] Prefer branchless code with sbb for abdu (#187783)
We can use the negate if carry trick for abdu, and it works on all legal for sbb
2026-03-22 11:07:41 +00:00
Konrad Kleine
5324c23d6c
[llvm][DebugInfo] Use formatv instead of format in DWARFDebugLoc (#186800)
This relates to #35980.
2026-03-22 11:40:15 +01:00
Adam Siemieniuk
5b71607f38
[mlir][linalg] Specialize transform op - emit category ops (#187506)
Adds optional attribute to allow specialization into category Linalg
ops.

The default behavior of the transform op remains unchanged.
2026-03-22 11:23:57 +01:00
Mir Immad
a5472086ce
[clang-tidy] False negatives readability-redundant-parantheses member of struct (#187054)
Fixes #186749
2026-03-22 17:26:31 +08:00
Bogdan Vetrenko
24546d9644
[clang][CodeGen] Use FieldDecl::getFieldIndex() in VisitOffsetOfExpr (#187826)
Use FieldDecl::getFieldIndex() instead of manually iterating over
fields.
2026-03-21 23:46:03 -07:00
Lang Hames
6f6adfbca4
[orc-rt] Add Session::tryCreateService convenience function. (#187640)
Session::tryCreateService will try to create an instance of ServiceT by
forwarding the given arguments to the ServiceT::Create method, which
must return an Expected<std::unique_ptr<ServiceT>>.

This enables one-line construction and registration of Services with
fallible constructors (which are expected to be common).
2026-03-22 16:58:19 +11:00
James Y Knight
3258d361cb
[Clang] Use stable_sort in VerifyDiagnosticsConsumer. (#187827)
The new code introduced for `-verify-directives` in PR #179835 enforces
that the order of diagnostics matches the order of the directives.
However, before checking this, it sorts the directives by
SourceLocation. Perhaps non-obviously, all directives which appear
inside a single comment are given the same SourceLocation, pointing to
the beginning of the comment. While these are added in order they appear
in the comment, the non-stable std::sort may non-detministically
misorder them. Switching to stable_sort ensures the correct order is
verified.

This was observed as a random test failure on the checks in
clang/test/CXX/drs/cwg25xx.cpp lines 250 and 264, in some builds of
Clang. Note that those lines end in backslashes, and thus, despite
appearances, the directives on the following lines are also within the
same single comment.
2026-03-21 23:11:29 -04:00
Owen Pan
f014202dac [clang-format][NFC] Remove redundant parens enclosing braced list 2026-03-21 17:10:21 -07:00
Björn Schäpers
2bbb4491a6
[clang-format] Merge case alignment into AlignTokens (#187811)
Use (nearly) the same code to align case statements and expression, as
the other alignments do. That way we also fix two things:
- Keep the ColumnLimit intact, without duplicating the calculation.
- Align all the case colons, even for empty cases.
2026-03-22 00:09:40 +01:00
Zorojuro
aa62224a73
[libc][math] Refactor sqrtbf16 function header-only (#187849) 2026-03-22 00:51:40 +02:00
Shilei Tian
1120c971c8
[NFC][AMDGPU] Set output to null for llvm/test/MachineVerifier/AMDGPU/invalid-vop3-source-modifiers.mir (#187888) 2026-03-21 18:22:23 -04:00
Muhammad Bassiouni
eea589f951
[libc][math] Qualify log with constant evaluation support (#184745)
Lay the ground for C++26 `constexpr` math functions:
- Introduce `LIBC_ENABLE_CONSTEXPR` macro switch to specify the desire
of `constexpr`-only code route.
- Introduce `LIBC_HAS_CONSTANT_EVALUATION` to indicate that we are using
`constexpr`-only code in all dependent functions.
- Introduce `LIBC_CONSTEXPR` macro qualifier to aid in altering the
signature of non-`constexpr` functions.

Note that non-`constexpr` qualified functions are caused by the
exploitation of non-`constexpr` compatible utils, resulting in
non-qualified dependent function, but it can be modified to be qualified
using other code routes.

If the function is `constexpr` compatible, then it's prohibited to use
`LIBC_CONSTEXPR` as a function qualifier. We only qualify it with
`constexpr` as usual.

`LIBC_CONSTEXPR` may or may not evaluate to `constexpr` depending on the
environment configurations, thus it's only used to modify the function
signature in constant evaluation context and remove the qualifier if
it's not desired (depending on provided configurations).

Possible side effects:
- Current qualified routes may or may not produce the desired ULP, this
is implementation dependent (function by function basis) and needs
further testing of the chosen code route.
- The shared tests in the current configuration can still compile with
unsupported compiler. I didn't want to raise compilation error with
unsupported compilers now, but we need to push compiler support with
newer versions for this one to work as intended.
2026-03-21 23:55:05 +02:00
owenca
1f1d3167b2
[clang-format] Correctly annotate Java lambda/sychronized blocks (#187842)
Fixes #171841
2026-03-21 14:00:23 -07:00
Aiden Grossman
adcb17b476 [Clang][HLSL] Fix -Wunused-variable
Inline the definition of a variable into an assertion given it has no
other users and no side effects.
2026-03-21 20:50:03 +00:00
Nico Weber
2be28d65fb [gn] "port" 0ec9f7ebbdf72a94
Just use an empty list always.
2026-03-21 16:48:38 -04:00
Takashi Idobe
1075a2fa7e
[Instcombine] Write Instcombine pass to strength reduce lock xadd to lock sub (#184715)
Resolves: https://github.com/llvm/llvm-project/issues/174933

The issue goes into a case where fetch_sub(n) is properly optimized but
fetch_add(neg(n)) is not optimized to the same code.

Although the issue is tagged for x86 I assumed this be best handled
outside of the backends so I put this in InstCombine.
2026-03-21 20:45:29 +00:00
Florian Hahn
d3c7f23d2f
[VPlan] Remove unused VPlan friend declaration from VPValue (NFC)
VPlan only accesses VPValue through public APIs (getUnderlyingValue(),
etc.), so the friend declaration is unnecessary.
2026-03-21 20:37:05 +00:00
Aiden Grossman
2702570686 [Bazel] Port 0ec9f7ebbdf72a94e0e2c0872d4d11fc8d0efa6b 2026-03-21 20:33:28 +00:00
YongKang Zhu
b7d97d9e8d
[BOLT] Remove outdated assertion from local symtab update logic (#187409)
The assert condition (function is not split or split
into less than three fragments) is not always true now
that we will emit more local symbols due to #184074.
2026-03-21 13:15:49 -07:00
Craig Topper
f146677396
[TargetLowering] Refactor expandDIVREMByConstant to share more code. NFC (#187582)
Make the (1 << HBitWidth) % Divisor == 1 path a special case within
the recently added chunk summing algorithm. This allows us to
share the trailing zero shifting code.

While there make some comment improvements and avoid creating
unnecessary nodes.
2026-03-21 11:23:16 -07:00
Craig Topper
34203a53b6
[RISCV][Docs] Removed 'specified in' text from SiFive custom instruction links. NFC (#187817)
The URL isn't printed, the text in the backticks is the link text.
2026-03-21 11:22:28 -07:00
Rana Pratap Reddy
df9eb79970
[Clang][AMDGPU] Lower __amdgpu_texture_t to <8 x i32> instead of ptr adrspace(0) (#187774)
Fix the IR lowering for `__amdgpu_texture_t` to generate a single
256-bit load instead of a double indirection through a flat pointer.

Previously, `__amdgpu_texture_t` was lowered to `ptr addrspace(0)`
(64-bit flat pointer), which caused the double load and indirection.
With the same reproducer like #187697.

```c
#define TSHARP __constant uint *

// Old tsharp handling:
// #define LOAD_TSHARP(I) *(__constant uint8 *)I

#define LOAD_TSHARP(I) *(__constant __amdgpu_texture_t *)I

float4 test_image_load_1D(TSHARP i, int c) {
  return __builtin_amdgcn_image_load_1d_v4f32_i32(15, c, LOAD_TSHARP(i), 0, 0);
}
```
old output: 

```llvm
define hidden <4 x float> @test_image_load_1D(ptr addrspace(4) noundef readonly captures(none) %i, i32 noundef %c) local_unnamed_addr #0 {
entry:
  %0 = load ptr, ptr addrspace(4) %i, align 32, !tbaa !9
  %1 = addrspacecast ptr %0 to ptr addrspace(1)
  %tex.rsrc.val = load <8 x i32>, ptr addrspace(1) %1, align 32
  %2 = tail call <4 x float> @llvm.amdgcn.image.load.1d.v4f32.i32.v8i32(i32 15, i32 %c, <8 x i32> %tex.rsrc.val, i32 0, i32 0)
  ret <4 x float> %2
}
```
This matches the old `__constant uint8 *` behavior. With this fix new
output is
```llvm
define hidden <4 x float> @test_image_load_1D(ptr addrspace(4) noundef readonly captures(none) %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = load <8 x i32>, ptr addrspace(4) %0, align 32, !tbaa !10
  %4 = tail call <4 x float> @llvm.amdgcn.image.load.1d.v4f32.i32.v8i32(i32 15, i32 %1, <8 x i32> %3, i32 0, i32 0)
  ret <4 x float> %4
}
```

Fixes #187697
2026-03-21 22:21:12 +05:30
Twice
d818fa4c55
[MLIR][Python] Make init parameters follow the field definition order (#186574)
Currently, Python-defined operations automatically generate an
`__init__` function to serve as the operation builder. Previously, the
parameters of this `__init__` function followed a fairly complex set of
rules. For example:

* All result fields were moved to the front to align with other op
builders.
* Fields of `Optional` type were automatically moved to the end and
treated as keyword parameters.
* If the types of all result fields could be inferred automatically,
then all result fields were removed from the parameter list.
* Other than that, the parameter order followed the field definition
order.

These rules may seem reasonable, and they have worked well in practice,
but they have one major drawback: users cannot easily tell what the
actual `__init__` parameter list will look like when writing code,
because the rules are simply too complicated. Users can inspect the
signature at runtime via `MyOp.__init__.__signature__`, but this is
clearly poor for the development experience.

After some offline discussion with Rolf, we decided to replace this with
the following rules, which is what this PR implements:

* The parameters of `__init__` now strictly follow the field definition
order.
* By default, all parameters are required. A field becomes a keyword
parameter only if it is declared with `= None`.
* By default, no type inference is performed. A field becomes a keyword
parameter and participates in type inference only if it is declared with
`= infer_type()`.

These new rules give users full control over the `__init__` parameter
list, making it easy to understand the parameter order and explicitly
control optional parameters and type inference. In addition, this makes
it much easier in the future to use `dataclass_transform` so that type
checkers can understand these automatically generated `__init__`
methods, although there are still some issues to resolve at the moment.

NOTE that this is a **breaking change**. Even so, I still believe it is
worth making, mainly for two reasons:
- the current number of users of Python-defined dialects is still quite
limited;
- this change will bring long-term benefits.

Assisted by Copilot.
2026-03-22 00:48:14 +08:00
Nerixyz
93d256b076
[llvm-pdbutil] Hash type records in yaml2pdb (#187593)
The TPI and IPI streams didn't include a hash map for the generated
types, because the types never got hashes. A hash map is necessary to
resolve forward references when dumping the PDB (checks for
`TpiStream::supportsTypeLookup` which checks the hash map).

With this PR, the hashes are generated. There's no good test that we do
this for the IPI stream as well, because it doesn't have forward
references.
2026-03-21 17:38:52 +01:00
Craig Topper
c1df6937ba
[TargetLowering] Use legally typed shifts to split chunks in expandDIVREMByConstant. (#187567)
This replaces LegalVT with HiLoVT and LegalWidth with HBitWidth as
they are the same for all current uses.
    
Then we rewrite the shifts to operate on LL and LH.
    
There's a slight regression on RISC-V due to different node creation
order leading to different DAG combine order. I have other refactoring
I'd like to explore then I may try to fix that.
2026-03-21 09:31:20 -07:00
Zorojuro
7d7cd745af
[libc][math][c23] Add atanbf16 function (#184019)
This PR intends to add atanbf16 higher math function for BFloat16 type
along with the tests.
2026-03-21 11:09:11 -04:00
Jannick Kremer
82eee26ccc
[libclang/python] Fix Type.get_offset annotation (#187841)
As discussed in
https://github.com/llvm/llvm-project/pull/180876#discussion_r2934372753,
`Type.get_offset` can process `bytes` arguments as well. For consistency
with other functions taking `str` arguments, its type annotation is
adapted to reflect this.
2026-03-21 23:51:56 +09:00
Michał Górny
4d058aeb08
[lldb] Fix LLVMSupportHTTP linkage against libLLVM (#187848)
Regression introduced in 39d6bb21804d21abe2fa0ec019919d72104827ac.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2026-03-21 15:40:16 +01:00
Alexey Bataev
616240369e [SLP]Do not consider copyable node with SplitVectorize parent
If the copyables are schedulable and the parent node is plit vectorize,
need to skip the scheduling analysis for such nodes to avoid a compiler
crash
2026-03-21 06:56:59 -07:00
Haohai Wen
acf9eede23
[Object] Fix issues in BBAddrMap.h (#187704) 2026-03-21 21:45:15 +08:00
efferre79
656fce889c
[libclang/python] export libclang version to the bindings (#86931)
It's useful to know which clang library the python bindings are running.

---------

Co-authored-by: Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>
2026-03-21 17:25:29 +04:00
Martin Storsjö
3b9106149c [lldb] Fix linking liblldb in a dylib build after 39d6bb21804d21ab
Referencing libSupportHTTP under LINK_LIBS of add_lldb_library() pulls
in the static archive even in a build configuration with
LLVM_LINK_LLVM_DYLIB=On, where libSupportHTTP is part of libLLVM. This
patch moves it to LINK_COMPONENTS to fix the issue.

This is the same fix as in
036429881f8d3037894042c6268b2a94eac8c950, applied on another
library.
2026-03-21 15:16:43 +02:00
Alexey Bataev
db143fb2b9 [SLP][NFC]Use block number instead of pointer for stable sorting, NFC 2026-03-21 04:30:32 -07:00
Henrich Lauko
2d01df187f
[CIR] Fix reference alignment to use pointee type (#186667)
getNaturalTypeAlignment on a reference type returned pointer alignment
instead of pointee alignment. Pass the pointee type with
forPointeeType=true to match traditional codegen's
getNaturalPointeeTypeAlignment behavior. Fix applies to both argument
and return type attribute construction paths.
2026-03-21 11:14:53 +00:00
Devajith
1f9c54a15a
[clang][AST] Preserve qualifiers in getFullyQualifiedType for AutoType (#187717)
A previous change (86c4e96) did not preserve qualifiers attached to the
AutoType QualType when the type was deduced.

For an AutoType after `getDeducedType()`, qualifiers from the original
QualType were dropped. Preserve and reapply them to the deduced type.
2026-03-21 09:22:20 +01:00
Michael Buch
b3c1098211 [lldb][test] PlatformTest: fix comment 2026-03-21 08:45:53 +01:00
Artem Gindinson
64c4e529a9
[mlir][SPIRV] Add alignment calculation to support PhysicalStorageBuffer with vector types (#187698)
This allows to lower `memref.load`/`store` operations on
`PhysicalStorageBuffer`-typed resources with the underlying type being a
vector type. This improves support for the `PhysicalStorageBuffer`
capability in pipelines that use the Vector dialect for distribution.

Signed-off-by: Artem Gindinson <gindinson@roofline.ai>
2026-03-21 07:15:57 +01:00
Victor Chernyakin
1087db5b1f
[clang-tidy] Speed up bugprone-suspicious-semicolon (#187558)
```txt
                   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
Status quo:        0.4743 (100.0%)   0.3802 (100.0%)   0.8546 (100.0%)   0.8567 (100.0%)  bugprone-suspicious-semicolon
With this change:  0.0103 (100.0%)   0.0027 (100.0%)   0.0130 (100.0%)   0.0133 (100.0%)  bugprone-suspicious-semicolon
```
Continuing the trend of registering one `anyOf` matcher being slower
than registering each of its matchers separately (see #178829 for a
previous example).

(This PR also changes the traversal mode, but I only saw a small speedup
from that. Most of it came from registering the matchers separately.)

This check wasn't super expensive to begin with, but the speedup is
still pretty nice.
2026-03-21 00:29:07 -05:00