570914 Commits

Author SHA1 Message Date
Son Tuan Vu
27d654c4c4
[AMDGPU] Fix piggybacking after commute in AMDGPULowerVGPREncoding (#183778)
After successfully commuting an instruction to be compatible with the
current VGPR MSB mode, update CurrentMode with the commuted
instruction's mode requirements. This locks in the mode bits the
commuted instruction relies on, preventing later instructions from
piggybacking and corrupting those bits.

Without this fix, a subsequent instruction needing a different mode
could piggyback onto the preceding s_set_vgpr_msb and change mode bits
that the commuted instruction depends on. For example, a nullopt src1
position (treated as 0) could be overwritten to a different value,
causing incorrect register encoding for the commuted instruction.

The fix still allows compatible piggybacking - instructions that only
add new mode bits without changing existing ones can still piggyback.
2026-02-27 22:16:14 -08:00
Fangrui Song
bed89970c3
AArch64: Replace @plt/%gotpcrel in data directives with %pltpcrel %gotpcrel (#155776)
Similar to #132569 for RISC-V, replace the unofficial `@plt` and
`@gotpcrel` relocation specifiers, currently only used by clang
-fexperimental-relative-c++-abi-vtables, with %pltpcrel %gotpcrel. The
syntax is not used in humand-written assembly code, and is not supported
by GNU assembler.

Also replace the recent `@funcinit` with `%funcinit(x)`.
2026-02-28 05:37:59 +00:00
Victor Chernyakin
ce6a3d98cc
[clang-tidy] Teach misc-unused-using-decls that exported using-decls aren't unused (#183638)
Fixes #162619.
2026-02-27 21:36:14 -08:00
SharonXSharon
fe76e9004b
[CodeGen] Allow -enable-ext-tsp-block-placement and -apply-ext-tsp-for-size passed together (#183642)
Currently, the asserts fires when both `UseExtTspForPerf` and
`UseExtTspForSize` are true on a given function.

Ideally, we should allow `-enable-ext-tsp-block-placement` and
`-apply-ext-tsp-for-size` passed together, meaning run the block
placement for performance on hot functions, while run the placement for
size on cold functions.

The diff makes `UseExtTspForPerf` and `UseExtTspForSize` mutually
exclusive per-function: functions with the `OptForSize` attribute use
ext-tsp block placement for size, while the others use ext-tsp block
placement for perf.

Co-authored-by: Sharon Xu <sharonxu@fb.com>
2026-02-27 20:12:50 -08:00
Akimasa Watanuki
d72e95bab0
[CIR] Use -verify on clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl (#182817)
Update clang/test/CIR/CodeGenHLSL/matrix-element-expr-load.hlsl to use
`-verify` with expected CIR NYI diagnostics.
2026-02-28 13:12:09 +09:00
David Rivera
0b88ee12dd
[CIR] Infrastructure and MemorySpaceAttrInterface for Address Spaces (#179073)
Related: https://github.com/llvm/llvm-project/issues/175871,
https://github.com/issues/assigned?issue=llvm%7Cllvm-project%7C179278,
https://github.com/issues/assigned?issue=llvm%7Cllvm-project%7C160386

- Introducing the LangAddressSpace enum with offload address space kinds
(offload_private, offload_local, offload_global, offload_constant,
offload_generic) and the LangAddressSpaceAttr attribute.


- Generalizes CIR AS attributes as MemorySpaceAttrInterface and Attaches
it to `PointerType`. Includes test coverage for valid IR roundtrips and
invalid address space parsing.

This starts a series of patches with the purpose of bringing complete
address spaces support features for CIR. Most of the test coverage is
provided in subsequent patches further down the stack. note that most of
these patches are based on: https://github.com/llvm/clangir/pull/1986
2026-02-27 23:08:20 -05:00
Luke Lau
6f9c68d320
[VPlan] Don't adjust trip count for DataAndControlFlowWithoutRuntimeCheck (#183729)
Previously, the canonical IV increment may have overflowed to a non-zero
value due to vscale being a non power-of-two. So we used to emit a
runtime check for this.

If you didn't want the runtime check,
DataAndControlFlowWithoutRuntimeCheck skipped it and instead tweaked the
trip count so it wouldn't overflow.

However #144963 stopped the check from ever being emitted because vscale
is always a power-of-two on AArch64 and RISC-V, so it never overflowed
to a non-zero value. And in #183292 the code to emit the check was
removed. But we never restored the trip count back to normal when the
target's vscale was a power-of-two.

Now that vscale is always a power-of-two, this PR avoids adjusting it. A
follow up NFC can then remove DataAndControlFlowWithoutRuntimeCheck.
2026-02-28 04:01:58 +00:00
YunQiang Su
5f22decefa
Clang: Deprecate float support from __builtin_elementwise_max (#180885)
Now we have
  __builtin_elementwise_maxnum
  __builtin_elementwise_maximum
  __builtin_elementwise_maximumnum
2026-02-28 10:56:02 +08:00
Mohamed Emad
62cfe1659e
[libc][math][c23] implement C23 acospif math function (#183661)
Implementing C23 `acospi` math function for single-precision with the
header-only approach that is followed since #147386
2026-02-28 04:32:45 +02:00
Mohamed Emad
fb6b470cae
[libc][math] Refactor floor family to header-only (#182194)
Refactors the floor math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182193

Target Functions:
  - floor
  - floorbf16
  - floorf
  - floorf128
  - floorf16
  - floorl
2026-02-28 04:32:22 +02:00
Aiden Grossman
8bd8d8e6de
[AMDGPU] Remove extra pipes from load-saddr-offset-imm.ll (#183874)
This test uses opt to run instcombin and then pipes that into llc which
has its output piped into FileCheck. Before this patch, the test also
piped in the source file into llc as well, which caused issues with a
downstream test executor that executes the lines in bash. However, these
extra pipes don't make sense anyways, so remove them.
2026-02-28 01:54:38 +00:00
Demetrius Kanios
5395d26689
Revert "[WebAssembly] Incorporate SCCs into WebAssemblyFixIrreducibleControlFlow (#181755)" (#183872)
This reverts commit c05e323be7caaadff6fdd09a2336be60e3041af1.

Changes failed Emscripten tests.
2026-02-28 01:46:08 +00:00
vporpo
342e44603d
[AMDGPU][SIInsertWaitcnts] Move VCCZ workaround code out of the way (#182619)
This is a cleanup patch that moves the VCCZ specific workaround code
from `SIInsertWaitcnts::insertWaitcntInBlock()` to a separate class and
refactors it a bit to make it easier to read.
The end result is a simpler `insertWaitcntInBlock()`.

Should be NFC.
2026-02-27 17:28:03 -08:00
Ayokunle Amodu
795cfaea9c
[CIR][NFC] Move some builtin tests to the CodeGenBuitins folder (#183607)
This moves a few tests that were created in the wrong location. Also
changes the names of some test files to maintain consistency.
2026-02-27 17:08:40 -08:00
Alexey Bataev
12e1075b64 [SLP]Fix operand reordering when estimating profitability of operands
Need to swap operand for a single instruction, not for the the same lane
of the first and second instruction in the list
2026-02-27 16:16:22 -08:00
Dave Lee
fd9421cccd
[lldb] Fix sys.path manipulation failure in formatter_bytecode.py (#183868)
Fix bug in #183804.
2026-02-28 00:07:41 +00:00
Johannes de Fine Licht
e3c045415a
[CMake] Propagate dependencies to OBJECT libraries in add_llvm_library (#183541)
Previously, transitively inherited calls to
`target_include_directories(foo SYSTEM ...)` were being squashed into a
flat list of includes, effectively stripping off `-isystem` and
unintentionally forwarding warnings from such dependencies.

To correctly propagate `SYSTEM` dependencies, use
`target_link_libraries` to forward the parent target's link dependencies
to the OBJECT library (similar to the `_static` flow below). Unlike a
flat `target_include_directories`, this lets CMake resolve transitive
SYSTEM include directories through the proper dependency chain.

Note that `target_link_libraries` on an OBJECT library propagates all
usage requirements, not just includes. This also brings in transitive
`INTERFACE_COMPILE_DEFINITIONS`, `INTERFACE_COMPILE_OPTIONS`, and
`INTERFACE_COMPILE_FEATURES`. This is arguably more correct, as the
OBJECT library compiles the same sources and should see the same flags.

The existing `target_include_directories` call is retained for include
directories set directly on the target (not through link dependencies).
CMake deduplicates include directories that appear through both paths.
Compile definitions and options may technically appear twice (once via
the OBJECT library, once via the consuming target), but duplicate `-D`
and flag entries should be harmless in practice.

Also fix `clang_target_link_libraries` and `mlir_target_link_libraries`
to forward the link type (PUBLIC/PRIVATE/INTERFACE) to `obj.*` targets.
Previously the type keyword was silently dropped, resulting in
plain-signature `target_link_libraries` calls. This is now required
because the new keyword-signature call in `llvm_add_library` would
otherwise conflict (CMake requires all calls on a target to use the same
signature).
2026-02-28 02:05:38 +02:00
Ankit Aggarwal
136ba6e208
[Hexagon] Define __HVX_IEEE_FP__ when -mhvx-ieee-fp is enabled (#183829)
Add a __HVX_IEEE_FP__ define when the compiler is invoked with
-mhvx-ieee-fp flag
2026-02-27 15:51:03 -08:00
Krzysztof Drewniak
dc520a5f49
[mlir][GPU] Add ValueBoundsOphinterface to gpu.subgroup_broadcast (#183848)
This commit adds an ValueBoundsOpInterface to gpu.subgroup_broadcast,
matching its integer range interface implementation, so that affine
analysis can peek through subgroup broadcast ops.
2026-02-27 15:46:56 -08:00
Andy Kaylor
c78f37fdeb
[CIR] Fix dominance problems with values defined in cleanup scopes (#183810)
We currently encounter dominance verification errors when a value is
defined inside a cleanup scope but used outside the scope. This occurs
when forceCleanup() is used to exit a cleanup scope while a variable is
holding a value that was created in the scope body. Classic codegen
solved this problem by passing a list of values to spill and reload to
forceCleanup(). This change implements that same solution for CIR.

I have also aligned the ScalarExprEmitter::VisitExprWithCleanups
implementation with that of classic codegen, eliminating an extra
lexical scope. This causes temporary allocas to be created at the next
higher existing lexical scope, but I think that's OK since they would be
hoisted there anyway by a later pass.
2026-02-27 15:31:07 -08:00
Eric Christopher
07891ab590
[cmake] Disable -Wdangling-pointer on GCC 12+ (#183593)
GCC 12 started warning on the RAII DAGUpdateListener pattern in
SelectionDAG.h (storing `this` in the constructor). It's a false
positive -- suppress it the same way we handle -Wno-dangling-reference
(GCC 13+) and -Wno-stringop-overread (GCC 11+).
2026-02-27 15:29:34 -08:00
Jonas Devlieghere
329c52c100
[lldb] Change the way the shlib directory helper is set (#183637)
This PR changes the way we set the shlib directory helper. Instead of
setting it while initializing the Host plugin, we register it when
initializing the Python plugin. The motivation is that the current
approach is incompatible with the dynamically linked script
interpreters, as they will not have been loaded at the time the Host
plugin is initialized.

The downside of the new approach is that we set the helper after having
initialized the Host plugin, which theoretically introduces a small
window where someone could query the helper before it has been set.
Fortunately the window is pretty small and limited to when we're
initializing plugins, but it's less "pure" than what we had previously.
That said, I think it balances out with removing the plugin include.
2026-02-27 15:27:02 -08:00
Daniel Paoliello
788625757e
[NFC] Fix use-after-free: track TargetLibraryAnalysis in BasicAAResult invalidation (#183852)
`BasicAAResult` holds a reference to `TargetLibraryInfo` but its
`invalidate()` function did not check `TargetLibraryAnalysis`. When the
pass manager destroyed and re-created `TLI` (e.g. during `CGSCC`
invalidation or `FAM.clear()`), `BasicAAResult` survived with a dangling
`TLI` reference.

This was exposed by #157495 which added `aliasErrno()`, the first code
path that dereferences `TLI` from `BasicAAResult` during the `CGSCC`
pipeline, causing a AV when compiling Rust's core library on Arm64
Windows.

This change adds `TargetLibraryAnalysis` to the invalidation check so
`BasicAAResult` is properly invalidated when its `TLI` reference becomes
stale.
2026-02-27 15:19:14 -08:00
Kaitlin Peng
e35fc30cb8
Fix BuiltinTypeMethodBuilder uninitialized pointer (#183814)
From [this
comment](https://github.com/llvm/llvm-project/pull/176058/changes/BASE..50c5be4bdf19a8a80b7e6e9d3ae46e11ff20a6e0#r2856661750)
on PR #176058, static analysis was flagging `TemplateParams` as not
initialized on all paths. This change fixes it by initializing to
`nullptr` at declaration.
2026-02-27 14:51:14 -08:00
Nikolas Klauser
0a9b5d5218
[libc++] Forward find* algorithms to find_if (#179938)
This propagates any optimizations to the whole family of `find`
functions.
2026-02-27 14:48:58 -08:00
Jason Molenda
c5588becb8 [lldb] Add skip shared build to more API tests
Fixing test failures on my local desktop with incremental
building.
2026-02-27 14:37:54 -08:00
Dave Lee
abbba22f45
[lldb] Add synthetic support to formatter_bytecode.py (#183804)
Updates formatter_bytecode.py to support compilation and disassembly for
synthetic formatters, in other words support for multiple functions
(signatures).

This includes a number of other changes:
* String parsing and encoding have bugs fixed
* CLI args are updated, primarily to support an output file
* Added uleb encoding/decoding support

This work is a prelude the ongoing work of a Python to formatter
bytecode compiler. The python compiler to emit assembly, and this module
(formatter_bytecode) will compile it into binary bytecode.
2026-02-27 14:20:19 -08:00
Erick Ochoa Lopez
7ad2c6db54
[mlir][arith] Add exact to index_cast{,ui} (#183395)
The `exact` flag with the following semantics

> If the `exact` attribute is present, it is assumed that the index type
width
> is such that the conversion does not lose information. When this
assumption
>    is violated, the result is poison.

can be added to index_cast and index_castui operations. This unlocks
the following lowerings:

*   index_cast (signed) exact    -> trunc nsw
*   index_castui (unsigned) exact -> trunc nuw
*   index_castui nneg exact       -> trunc nuw nsw

Changes:

* Adds ArithExactFlagInterface.
* Updates Arith_IntBinaryOpWithExactFlag to use ArithExactFlagInterface
* Update IndexCastOp and IndexCastUIOp to declare
`ArithExactFlagInterface`
* Update canonicalization patterns
* Update roundtrip, lowering, and canonicalization tests.
2026-02-27 17:17:48 -05:00
Florian Hahn
73d655a598
[VPlan] Support unrolling/cloning masked VPInstructions.
Account for masked VPInstruction when verifying the operands in the
constructor. Fixes a crash when trying to unroll VPlans for predicated
early exits.
2026-02-27 22:14:45 +00:00
Hansang Bae
8f268e63e4
[Offload] Remove unused data type (#183840) 2026-02-27 15:46:59 -06:00
Krzysztof Drewniak
cdd4313183
[mlir][LLVM] Let decomposeValue/composeVale pad out larger types (#183825)
Currently, as pointed out in the reviews for #183405, decomposeValues
and composeValues should be able to emit zexts and truncations for cases
like i48 and vector<3xi16> becoming i32s but currently that's an assert.
This commit fixes that limitation.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 13:35:19 -08:00
Florian Hahn
d7e037c838
Revert "[VPlan] Remove manual region removal when simplifying for VF and UF. (#181252)"
This reverts commit 9c53215d213189d1f62e8f6ee7ba73a089ac2269.

Appears to cause crashes with ordered reductions, revert while I
investigate
2026-02-27 21:29:41 +00:00
Florian Mayer
94bd8b9444
[NFC] [MTE] add test for duplicated lifetime end
Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/183808
2026-02-27 13:15:11 -08:00
Florian Mayer
63ab568070
[NFC] [HWASan] add test for duplicated lifetime end
Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/183807
2026-02-27 13:14:20 -08:00
Aiden Grossman
c2f66f2a94 [WebAseembly] Fix -Wunused-variable in #181755
This variable ends up being unused in builds without assertions. Mark it
[[maybe_unused]] per the coding standards.
2026-02-27 21:13:04 +00:00
Alexandros Lamprineas
a71ded3861
[BOLT][AArch64] Add a unittest for compare-and-branch inversion. (#181177)
Checks that isReversibleBranch() returns false
 - when the immediate value is 63 and needs +1 adjustment
 - when the immediate value is 0 and needs -1 adjustment

Checks that reverseBranchCondition() adjusts
 - the opcode
 - the immediate operand if necessary (+/-1)
 - the register operands if necessary (swap)
2026-02-27 21:09:16 +00:00
Mehdi Amini
1073951bdb
[mlir][cf] Fix crash in simplifyBrToBlockWithSinglePred when branch operand is a block argument of its successor (#183797)
When `simplifyBrToBlockWithSinglePred` merges a block into its sole
predecessor, it calls `inlineBlockBefore` which replaces each block
argument with the corresponding value passed by the branch. If one of
those values is itself a block argument of the successor block, the call
`replaceAllUsesWith(arg, arg)` is a no-op. Any uses of that argument
outside the block (e.g. in a downstream block) are therefore not
replaced, and when the successor block is erased the argument is
destroyed while those uses are still live, triggering the assertion
`use_empty() && "Cannot destroy a value that still has uses\!"` in
`IRObjectWithUseList::~IRObjectWithUseList`.

Guard against this by returning early when any branch operand is a block
argument owned by the destination block.

Fixes #126213
2026-02-27 20:29:58 +00:00
Michael Spencer
d0afaeadec
[clang][modulemap] Lazily load module maps by header name (#181916)
After header search has found a header it looks for module maps that
cover that header. This patch uses the parsed representation of module
maps to do this search instead of relying on FileEntryRef lookups after
stating headers in module maps.

This behavior is currently gated behind the
`-fmodules-lazy-load-module-maps` `-cc1` flag.
2026-02-27 12:29:45 -08:00
Serosh
977702ccc4
[clang] fix crash when casting a parenthesized unresolved template-id (#183633)
this fix uses ignoreparens() in checkplaceholderexpr to prevent a crash
when an unresolved template-id is wrapped in parentheses. fixes #183505
2026-02-27 20:27:26 +00:00
Daniel Thornburgh
2c98566900
Revert "[Metal][HLSL] Add support for dumping reflection" (#183818)
Reverts llvm/llvm-project#181258

`env PATH=""` will prevent finding any binary run by `env`.
2026-02-27 20:18:13 +00:00
Vitaly Buka
02ebe23163
[ASan] Document limitations of container overflow checks (#183590)
Mention that partially poisoning stack objects can
lead to false positives and negatives.

See #182720.

---------

Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2026-02-27 12:17:20 -08:00
Jay Foad
fff2f0ba78
[AMDGPU] Handle GFX1250 hazards between WMMA and VOPD (#183573)
Hazards between WMMA and VALU were handled in #149865 but this only
worked for regular VOP* VALU encodings, not for VOPD.

Fixes: #183546
2026-02-27 19:51:53 +00:00
Ryosuke Niwa
fc153b1e25
[alpha.webkit.NoDeleteChecker] Check if each field is trivially destructive (#183711)
This PR fixes the bug that NoDeleteChecker and trivial function analysis
were not detecting any non-trivial destruction of class member
variables.

When evaluating a delete expression or calling a destructor directly for
triviality, check if each field in the class and its base classes is
trivially destructive.
2026-02-27 11:43:39 -08:00
Mohamed Emad
ca04a70891
[libc][math] Refactor bf16sub family to header-only (#182115)
Refactors the bf16sub math family to be header-only.

Closes https://github.com/llvm/llvm-project/issues/182114

Target Functions:
  - bf16sub
  - bf16subf
  - bf16subf128
2026-02-27 21:38:30 +02:00
Matheus Izvekov
6f612cfbd9
[clang] stop error recovery in SFINAE for narrowing in converted constant expressions (#183614)
A narrowing conversion in a converted constant expression should produce
an invalid expression so that [temp.deduct.general]p7 is satisfied, by
stopping substitution at this point.

This regression was introduced in #164703, and this will be backported
to clang-22, so no release notes.

Fixes #167709
2026-02-27 16:32:06 -03:00
Peter Klausler
d1f4f9453c
[flang] Fix explanatory messages for generic resolution error (#183565)
The compiler emits messages to explain why each of a generic procedure's
specific procedures is not a match for a given set of actual arguments.
In the case of specific procedures with PASS arguments in derived type
procedure bindings or procedure components, these explanatory messages
are often bogus, because the re-analysis didn't adjust the actual
arguments to account for the PASS argument. Fix.
2026-02-27 11:31:51 -08:00
Srividya Sundaram
4f05592bc0
[Driver][SYCL] Add tests for -Xarch_<arch> option forwarding to SYCL JIT compilation. (#178025)
This change adds test coverage to verify that options passed via
`-Xarch_<arch> <option>` are correctly forwarded to SYCL JIT
compilations.
2026-02-27 13:30:46 -06:00
Ben Dunkin
3d889c464e
[clang-format] Fix SpaceBeforeParens with explicit template instantiations (#183183)
This fixes explicit template instantiated functions not having spaces
added/removed based on the value of `SpaceBeforeParens`.

Attribution Note - I have been authorized to contribute this change on
behalf of my company: ArenaNet LLC
2026-02-27 20:30:00 +01:00
Andy Kaylor
df5bee6afc
[CIR] Implement TryOp flattening (#183591)
This updates the FlattenCFG pass to add flattening for cir::TryOp in
cases where the TryOp contains catch or unwind handlers.

Substantial amounts of this PR were created using agentic AI tools, but
I have carefully reviewed the code, comments, and tests and made changes
as needed. I've left intermediate commits in the initial PR if you'd
like to see the progression.
2026-02-27 11:20:43 -08:00
Tommy Chiang
8ce2b9cbc2
[Clang][ItaniumMangle] Fix recursive mangling for lambda init-captures (#182667)
[Clang][ItaniumMangle] Fix recursive mangling for lambda init-captures

Mangle computation for lambda signatures can recurse when a call
operator type
references an init-capture (for example via decltype(init-capture)). In
these
cases, mangling can re-enter the init-capture declaration and cycle back
through
operator() mangling.

Make lambda context publication explicit and independent from numbering
state,
then use that context uniformly during mangling:
* Publish lambda `ContextDecl` in `Sema::handleLambdaNumbering()` before
numbering, so dependent type mangling can resolve the lambda context
without
  recursing through the call operator.
* Introduce `CXXRecordDecl::setLambdaContextDecl()` and remove
`ContextDecl`
  from `CXXRecordDecl::LambdaNumbering`.
* Update `ASTImporter` to import/set lambda context separately from
numbering.
* In Itanium mangling, derive init-capture handling from context
computation:
  - map local-lambda init-captures to the enclosing local context in
    `getEffectiveDeclContext()`
  - support init-capture variables in `getClosurePrefix()`
  - keep `mangleLocalName()` generic and rely on the computed context

Add mangling regression coverage in mangle-lambdas.cpp, including:
* local init-captures used through decltype
* non-local variable-template init-captures in decltype
* non-local static inline member init-captures in decltype

* Fixes https://github.com/llvm/llvm-project/issues/63271
* Fixes https://github.com/llvm/llvm-project/issues/86240
* Fixes https://github.com/llvm/llvm-project/issues/139089
2026-02-28 03:18:11 +08:00