Skip to content

[pull] main from llvm:main - #1710

Merged
pull[bot] merged 43 commits into
MPACT-ORG:mainfrom
llvm:main
Aug 3, 2026
Merged

[pull] main from llvm:main#1710
pull[bot] merged 43 commits into
MPACT-ORG:mainfrom
llvm:main

Conversation

@pull

@pull pull Bot commented Aug 3, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

lenary and others added 30 commits August 2, 2026 23:02
This implements an old FIXME in the AsmMatcherEmitter, which can now
emit a token-specific match error diagnostic id, and potentially a
token-specific error message to go along with the diagnostic id.

For RISC-V, the overall effect is to have fewer "invalid operand for
instruction" diagnostics and have more "expected '<TOKEN>'" diagnostics,
which, with multiple near miss support, gives the user the location that
token was expected (but not found).

The rejig to the order of checks in `validateOperandClass` do not
prevent backends from having custom operand kinds which can accept
tokens, as was available before.

The TableGen parts have been implemented in an opt-in way.

---

This was implemented with the assistance of AI.
…ntries (#210210)

Per OpenMP, when a map/motion clause uses a mapper, any
map-type-modifying modifier on that clause applies to each map the
declared mapper specifies.

This change propagates the `ALWAYS`, `DELETE`, and `CLOSE` bits from the
outer clause's map type into every entry emitted by
emitUserDefinedMapper, except `ATTACH` entries (`ATTACH`|`ALWAYS` is
reserved for `attach(always)`, and the other bits have no meaning for an
`ATTACH` entry).

`PRESENT` is intentionally NOT propagated here: it requires
distinguishing pointee entries from the struct's own storage and is
handled in a follow-up.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
If a kernel gets SPMDized, it doesn't need the wrapper function that is
passed to __kmpc_parallel_60. Keeping the dead wrapper function can lead
to lots of misleading "local memory global used by non-kernel function"
AMDGPU backend warnings.
Let OpenMPOpt null the wrapper argument such that DCE can then remove
the corresponding dead functions.

Claude assisted with this patch.
… items (#211224)

Resolves #211747

Problem
-------
An empty NAMELIST assignment on a scalar item — e.g. `l =` in

    &nml l= i_count=7 r_value=2.72/

— aborted at runtime with

fatal Fortran runtime error: Bad character 'i' in LOGICAL input field

Every EditIntegerInput / EditRealInput / EditLogicalInput /
EditCharacterInput function starts its list-directed arm with

    if (IsNamelistNameOrSlash(io)) return false;   // no value

which peeks ahead (via SavedPosition, no stream consumption) for a
`<name>=` / `<name>%` / `<name>(` shape or one of the terminators `/`
`&` `$`, letting the reader bail cleanly for empty values and
short-array ends. That helper's first line is

    if (!listInput || !listInput->namelistGroup()) return false;

InputNamelist however called ResetForNextNamelistItem with
`useDescriptor->rank() > 0 ? &group : nullptr`, so `namelistGroup_`
stayed null for scalars. The peek was silently disabled and the value
reader consumed the next namelist item's name as a bare token, producing
the abort above. Legacy nvfortran / gfortran accept empty scalar
assignments as "keep current value".

Solution
--------
Pass `&group` unconditionally to `ResetForNextNamelistItem`. Today
`IsNamelistNameOrSlash` uses `namelistGroup_` only as a boolean gate
(never as a lookup table), so widening it is a no-op for arrays and
enables the same empty-value / next-name detection for scalars.
NamelistTests.NanInputAmbiguity (which motivated the original pointer
form) still passes; three new tests cover the empty-scalar case, the
empty-array case, and an empty scalar surrounded by arrays.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
…s not accept MemoryUse (NFC) (#212512)

Outdated comment has been updated to match the implementation, which
asserts on MemoryUse.
Finalize MemorySSA usage in GVNHoist, while transitioning away from
MemoryDependenceAnalysis.
This patch implements Phase 2 of the RFC "Enforce Single-Operand Format
for All .enable Metadata Nodes". Please refer to RFC:

https://discourse.llvm.org/t/rfc-enforce-single-operand-format-for-all-enable-metadata-nodes/90571/

The two-operand boolean form !{!"llvm.loop.vectorize.enable", i1 0/1} is
replaced by a single-operand enable/disable pair:

  !{!"llvm.loop.vectorize.enable"}    ; force vectorization
  !{!"llvm.loop.vectorize.disable"}   ; suppress vectorization

The Verifier rejects the two-operand form, AutoUpgrade rewrites old
bitcode (including the legacy llvm.vectorizer.enable tag), and the
readers and producers across LLVM, Clang, MLIR and Polly are updated.
Fix error: invalid header length in
'CommandGuide/llvm-calc-occupancy.rst' (does not match length of title)
in our downstream Sphinx doc build.
…perty}Decl (#213030)

This overrides `getNameForDiagnostic` to provide a qualified name
representation for Objective-C methods and properties in diagnostics.
When qualified is true, it formats them using the standard Objective-C
syntax, such as `-[Class selector]` or `+[Class property]`. Previously
these would be `Class::selector` or `Class::property`. If qualified is
false, it falls back to printName.

Note that I avoided modifying `NamedDecl::getQualifiedNameAsString()` or
`printQualifiedName()` which will continue to (unfortunately) return
`Class::method`, but this is intentional to attempt to avoid any
breakage downstream due to output changing.
…_frame (#213610)

This provider's identity-forwarding pattern intermittently hits a known
frame-identity-aliasing bug in ScriptedFrameProvider::GetFrameAtIndex,
tracked in #208992.
cppcoreguidelines-pro-type-member-init check has an option IgnoreArrays
for ignoring uninitialized C arrays. This patch adds support for C++
std::array as well.

Co-authored-by: David Siroky <david@siroky.cz>
…ting (#205995)

Introduce LoopSplitUtils, a utility that splits a counted loop into a
chain of per-partition sub-loops covering contiguous slices of the
original iteration space. Given a loop and a list of partition ranges,
it clones the body per partition, guards each with an entry check that
skips empty partitions, clamps each latch to its slice, and rebuilds SSA
for loop-carried and live-out values so the result is
behaviour-preserving.

Key properties:
- Supports ascending (+1) and descending (-1) unit-step inductions, in
both signed and unsigned iteration orderings, with direction-aware
guard/latch predicates and end clamps.
- Reuses the original loop for partition 0 and clones the rest, exposing
per-partition value maps via getPartitionValue()/getPartitionValueMap().
- Lets callers drop the entry guard for a partition proven non-empty via
avoidPartitionGuard(); provably-empty partitions are always skipped.
- Patches the dominator tree and LoopInfo incrementally rather than
rebuilding them.

How to use:

  LoopSplitUtils LSU(L, LI, SE, DT);
if (!LSU.isLegal()) // counted, bottom-tested, LCSSA, unit step
    return false;
  // Tile the iteration space in order; e.g. split [Start, End] at K:
  LSU.addPartition(Start, K - 1);   // partition 0: [Start, K-1]
  LSU.addPartition(K, End);         // partition 1: [K, End]
  LSU.split();
  // After split(), query a cloned value in a given partition:
  Value *V1 = LSU.getPartitionValue(Orig, /*PartitionIndex=*/1);

A new test pass, loop-split-test (opt -passes=loop-split-test with
-loop-split-points=...), drives the utility for testing. Adds lit tests
covering basic/multiple/four-partition splits, descending loops,
reductions, empty-leading partitions, optional guards, and the
per-partition value map.
Remove the llvm_unreachable from getDynamicLinker(). The code path is
reachable. In the case of an unsupported architecture we're not worrying
about trying to actually determine the dynamic linker, and I don't think
it makes sense for the Driver to crash.

Pointed out by bug report #64194

---------

Co-authored-by: Shivam Gupta <shivam98.tkg@gmail.com>
There was previously a doubt about whether the integer variant of the
test should use wrap-flags on the latch exit value, which motivates us
to add coverage for the ptr variant.
InstCombine pull request
#194519 canonicalized the
saturating negation idiom to
an llvm.ssub.sat operation. For the ARM backend we only recognized the
original
select and subtract pattern, causing vector absolute values to expand to
VQSUB
plus a compare and select instead of VQABS.

In this patch we teach the VQABS and VQNEG patterns to recognize this
ssub.sat
form.
…butes (#212483)

`BitcastOp::fold` assumed any non-poison scalar operand attribute is a
`FloatAttr` or `IntegerAttr` and hard-casted it.
Constant attributes from other dialects, e.g. the `LLVM::UndefAttr`
produced by `llvm.mlir.undef`'s fold, hit the cast assertion.
This crashed SCCP on IR where `llvm.mlir.undef` feeds `arith.bitcast`.
Bail out on attributes and result types the fold does not handle.
- Allow the type in struct/classes in very limited circumstances. The
goal is to enable creating trivial wrappers around the named barrier
variable, but ensure we can't get into situations where things would get
awkward. Currently this means we only allow the named barrier in
RecordDecls with exactly 1 field, that have no base class, and are not
inherited.
- Use a `amdgpu_barrier` LangAS for this type that currently maps to the
local AS. This allows easy switching to the barrier AS in a future
patch.
The Swift async prologue pushes the context slot (pushq %r14 / $0) but
doesn't touch the CFA until the later .cfi_def_cfa_register %rbp. So the
CFA still describes the stack from before the push and stays stale all
the way through the leaq and the subq. If something unwinds in that
window (debugger, profiler, signal) it reads the wrong slot. Normal
execution is fine.

FIX: account for the push with .cfi_adjust_cfa_offset 8, then switch to
an %rbp-relative CFA (.cfi_def_cfa %rbp, 16) right after the leaq and
before the subq, so the rule is correct before rsp moves again.

Adds swift-async-cfi-prologue.ll (directives + .eh_frame rows, plus a
locals case for the subq) and updates swift-async.ll.
… constraints (#213605)

This addresses a test failure introduced in
4f6cf2c.

`0x1122334455667788` is a non-canonical address on x86_64 (fails to
write to rsp) and gets its non-addressing bits masked off on read for
pc/lr/sp/fp on Darwin AArch64, so it doesn't round-trip on either. Zero
the top 20 bits to stay clear of both.
…ntOrigins (#213521)

The TimeTraceScope was constructed as a temporary and destroyed
immediately, so the prepass was reported as taking ~0. It actually
accounts for ~14% of LoanPropagation in some cases.

Co-authored-by: Gabor Horvath <gaborh@apple.com>
spirv-val now limits execution scope for GroupNonUniform* ops to
Subgroup, except OpGroupNonUniformRotateKHR which still allows Workgroup
(see KhronosGroup/SPIRV-Tools#6811). Tighten the
ODS trait accordingly and stop lowering GPU non-uniform reductions to a
Workgroup scope op

Follow-up to #212928
…upport (#213611)

It doesn't appear possible to test this independently.

Co-authored-by: Claude (Opus 4.8) <noreply@anthropic.com>
Add linker-level mangling prefix for lookups on Darwin.

These should fix the build failures associated with PR203914 on Darwin,
e.g. https://lab.llvm.org/buildbot/#/builders/23/builds/21523
`return 0` part of `getWCharSize` was added in cc603ee but then
removed in 5a88dff. Update the documentation as it no longer
returns 0 when the size is unknown (instead returns the default).
…mory planner (#209106)

The static memory planner currently skips any allocation that doesn't
have a direct `memref.dealloc` user. This is overly conservative, after
running `ownership-based-buffer-deallocation`, it's common to see
patterns like:

  `%2 = arith.select %c, %0, %1 : memref<1024xf32>`
  `memref.dealloc %2 : memref<1024xf32>`

where both `%0` and `%1` get skipped with `++numSkipNoDealloc` even
though their lifetimes are well-defined.

This patch teaches `collectCandidates` to follow `arith.select` chains
when looking for potential deallocs. We traverse the use-def graph
forward from each alloc, collecting any `memref.dealloc` ops reachable
through select results.

Since a single select-based dealloc can conditionally free one of
several allocs, we enforce a group constraint: all allocs that share a
dealloc via a select must either all go into the arena or all be
skipped. Without this, we could end up with a `memref.view` (an arena
slice) and a raw alloc being fed into the same select, making the
resulting dealloc invalid.

The group constraint is computed with a simple fixpoint iteration , if
any member of a group is ineligible, the whole group is dropped.

The lifetime indices (`timeStart`/`timeEnd`) in `buildAllocInfos` are
also fixed: the old code did one block scan per candidate (O(n×m)). This
replaces it with a single pass upfront using a `DenseMap`, and sets
`timeEnd` conservatively to the latest dealloc index across all
potential deallocs for an alloc.

Tests added for:
- Single alloc freed via a self-select dealloc
- Two allocs sharing one select-based dealloc (group constraint active)
- The two-select two-dealloc pattern from the design discussion
…213584)

This relands #211715 which was reverted because of some failures
in experimental targets and one AMDGPU test `diverged-entry-basic.ll`.

Below is the original commit message.

----

This recommits #119826, which taught `MachineLICM` to use
`RegisterClassInfo` when computing register pressure limits so
reserved registers are accounted for (#118787).

The original change was reverted by eeac0ff because it increased
compile time by causing repeated `RegisterClassInfo` computations.

This PR is based on #210826, in which `MachineRegisterClassInfo`
analysis pass was added. `MachineRegisterClassInfo` is required
by `MachineLICM` now, but the intervening machine passes that do
not affect `RegisterClassInfo` now preserve it, so the analysis
is reused instead of recomputed.

Assisted-by: TRAE CLI (GPT-5.5)
…212813)

GlobalISel cannot select a ballot narrower than the wavefront width,
since it can't represent one bit per lane

Widen the ballot to the wave size and narrow the result afterwards

This is a prerequisite for relanding
#211493 (reverted in
#212628 to unblock buildbot) to
prevent device libs side failures

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
timurgol007 and others added 13 commits August 3, 2026 09:59
Add FP min/max opcodes to the list of operations that can be folded into
write-masked instructions. This allows commuteSelect to recognize these
operations and invert the setcc condition to enable ISel to match fused
vminps/vmaxps {%k} patterns.
Carry the original latch's branch weights onto the clamped latch, and
mark the newly created partition-guard branches as having unknown
weights so profile-tracking passes are not misled.
…point (#208438)

This is a fairly complex function, so this patch implements bare minimum
needed to demonstrate the overall direction. The functionality is
implemented by communicating with the linux kernel over a netlink
socket, and the complexity comes from parsing the messages. In this
patch, parsing stops at the first interface, and we don't handle
multiple messages or deduplication resulting from restarted dumps.

Some notable implementation choices are:
- using a single allocation (including both the interface vector and the
strings it points to). This makes deallocation fast, reduces heap
fragmentation, and doesn't make the final code much more complex since
we still need auxiliary data structures for deduplication.
- using linux kernel headers for all the netlink structures. I think
this is fine as we're not exposing that to the user.
- while this information is available via /sys, that would mean we
require /sys to be mounted, and it wouldn't make the code much simpler.
This also matches other libc implementations.

Testing is a completely separate story, and the main source of
complexity of this patch. To make the code testable without requiring
root or live interfaces, the core function
(`net::if_nameindex<Policy>()`) is templated on a syscall policy class
(`NetworkSyscallPolicy`). The production entrypoint uses
`DefaultNetworkSyscallPolicy` forwarding directly to syscall wrappers
(`socket`, `sendto`, `recvfrom`, `close`), while the unit tests use
`FakeNetworkSyscallPolicy` to feed crafted netlink buffers from memory
and verify `sendto` request formation.

The fake policy is set up such that one can program the mock to return
certain values, and validate arguments. It does not resemble the
googletest functionality (mocks) very closely, but I've tried to put it
in a form where it is possible to morph it into that -- if that's the
direction we desire to go.

While doing this, I ran into the limitations of various container
classes (mainly the inability to handle non-trivial types). To avoid
growing the scope of this even further, I worked around those
limitations locally, and left TODOs which I intend to resolve in
follow-ups. The only thing I couldn't avoid is the addition of
cpp::expected default constructor (which is actually a consequence of
how FixedVector constructs elements). However, this is a simple addition
and it is consistent with the STL class it is emulating.

The patch also add the [AP]F_NETLINK constants needed for creating
netlink sockets.
…le (#211137)

Fixes #211134.

`check_fortran_builtins_available()` probes for Fortran intrinsic
modules without passing the target triple, in both branches: the
`-print-file-name=iso_c_binding.mod` query runs the driver with no
`--target`, and the `check_fortran_source_compiles()` fallback uses
`try_compile()`, which does not inherit `CMAKE_Fortran_COMPILER_TARGET`.

Flang's intrinsic modules are built per-target by flang-rt. When a
runtime is configured for a GPU target without flang-rt in its runtime
list, both probes test the host and succeed, so
`RUNTIMES_FORTRAN_MODULES` is enabled for a target that cannot support
it. `LIBOMP_FORTRAN_MODULES` inherits that and the failure is deferred
to a cascade of BIND(C) diagnostics compiling `omp_lib.F90`, all
stemming from one missing-module error.

Pass the triple to both probes so the existing graceful-degradation path
is reached instead.

Uses `CMAKE_Fortran_COMPILE_OPTIONS_TARGET` rather than a hard-coded
`--target=`. This file is also used with non-Flang compilers (`:229`,
and `openmp/module/CMakeLists.txt:25` special-cases GNU), and the
`check_fortran_source_compiles` branch is the live path for every
compiler on CMake >= 3.24. gfortran rejects `--target=` outright, so
hard-coding it would silently disable Fortran modules for gfortran users
who get them today. `CMAKE_Fortran_COMPILE_OPTIONS_TARGET` is
`--target=` for Flang and empty for GNU.

Tested:

| compiler | target | result |
|---|---|---|
| gfortran | `x86_64-unknown-linux-gnu` | modules ON, unchanged |
| flang | `x86_64-unknown-linux-gnu` | modules ON, unchanged |
| flang | `amdgcn-amd-amdhsa` | modules OFF, correctly disabled |
| flang | `amdgpu-amd-amdhsa` | modules OFF, correctly disabled |

Also built four full configurations: amdgcn with `openmp` unpatched
fails as described; patched, it builds clean and produces
`libompdevice.a` with no workaround; amdgcn with `openmp;flang-rt` (the
`FlangOffload.cmake` recipe) still builds `omp_lib.mod` for the GPU
triple, so the intentional GPU module support is preserved; and the
x86_64 host build is unchanged.

No test: neither `runtimes/` nor `openmp/` has CMake-configuration test
infrastructure, and this is configure-time logic with no lit surface.

This affects performance-critical applications on large AMD GPU
supercomputers, including [MFC](https://github.com/MFlowCode/MFC).

All numbers above come from the validated reproducers included with this
report and are independently reproducible; they stand on their own.

This was found and root-caused with the assistance of AI tools.
…0946)

gdbserver recognises 'x86_64' arch as 'i386:x86-64', this prevents gdb
(binary) from connecting to lldb-server since lldb-server reports
architecture as 'x86_64'. we already do something similar when
connecting a server to lldb.
This does not affect lldb -> lldb-server since we use qHostInfo to get
that information.
This is a follow up to #212753
to convert all the tests to use the `@require` decorator.
Select non-zero s8/s16 GPR constants as 32-bit MOV immediates during
instruction selection.

RegBankSelect already does this, but this gives instruction selection a
direct path instead of falling back which will help enable a simple fast
pure type-based RBS alternative.

Assisted-by: codex
Fold redundant UMIN clamps in logical boolean reduction trees when all
operations use the same predicate.
Fix the following warnings identified by the `llvm-mlir-use-after-erase`
check from #210727:

```cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp:2700:33: warning: operation 'op' is used after it was erased [llvm-mlir-use-after-erase]
 2700 |           curState, std::string(op->getName().getStringRef()) + " folder");
      |                                 ^
mlir/lib/Transforms/Utils/DialectConversion.cpp:2685:12: note: operation erased here
 2685 |   rewriter.replaceOp(op, replacementValues);
      |            ^
mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp:440:29: warning: operation 'newOp' is used after it was erased [llvm-mlir-use-after-erase]
  440 |           Value newMemRef = newOp->getResult(resIndex);
      |                             ^
mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp:459:20: note: operation erased here 
  459 |             newOp->erase();
      |                    ^
mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp:440:29: note: the use happens in a later loop iteration than the erase
  440 |           Value newMemRef = newOp->getResult(resIndex);
      |                             ^
```

The warning at `NormalizeMemRefs.cpp:440` is resolved by breaking the
loop iteration after erasing the operation, similar to what is done at
line 306.
This exposes an underlying bug in wasm.dot-folding, which we fix. The
motivation for this patch is to enable folding of get.active.lane.mask
in VPlan in a follow-up.
This PR depends on the DebugFunction PR:
#211760. This PR implements
support for
[DebugFunctionDefinition](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugFunctionDefinition).

DebugFunctionDefinition must be emitted within the instruction sequence
of its corresponding OpFunction. The current implementation inserts
DebugFunctionDefinition immediately after the last OpVariable, if one
exists, or otherwise immediately after the first OpLabel. The goal is to
satisfy the following
[requirement](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#_binary_form):

> DebugScope, DebugNoScope, DebugDeclare, DebugValue, DebugLine,
DebugNoLine, and DebugFunctionDefinition instructions may interleave
with instructions inside a function, but they must appear at valid
locations within a block as required by SPV_KHR_non_semantic_info. In
particular, they cannot appear before any OpPhi or function-level
variable declarations in a block, and they cannot appear after a merge
instruction.

To support this, I updated SPIRVAsmPrinter to notify the debug handler
whenever an instruction is emitted. The debug handler maintains a small
amount of state so it can detect when the last OpVariable or the first
OpLabel has been emitted and insert DebugFunctionDefinition at the
appropriate location.
…ace lifetime source binding (#207052)

Currently the `UseAfterLifetimeEnd` checker can emit warnings, but those
warnings cannot clearly describe to which annotated parameter the return
value is actually bound. When multiple parameters are annotated, it is
unclear which one the return value is bound to. Using
`BugReporterVisitor` to trace back the nodes and emit a note that
explains where the lifetime of the annotated parameter (the source)
ended can be helpful for users.

***NOTE***: This PR is built on #205951. It should only be merged after
#205951 is merged.

Consider the following case: 

```cpp
#include <stddef.h>

class Arena {
  char buf[128];
  char *buffer = buf;
  size_t offset = 0;

public:
  void *allocate(size_t size) [[clang::lifetimebound]] {
    void *p = buffer + offset;
    offset += size;
    return p;
  }
  void reset() {offset = 0;}
};

void *arena_dangling() {
  Arena arena;
  void *p = arena.allocate(128);
  arena.reset();
  return p; // arena goes out of scope therefore p dangles
}
```

The `UseAfterLifetimeEnd` checker correctly detects this error and emits
path notes that trace where the value was bound and where its lifetime
ends:

```text
temp.cpp:21:3: warning: Returning value bound to 'arena' that will go out of scope [alpha.cplusplus.UseAfterLifetimeEnd]
   21 |   return p;
      |   ^~~~~~~~
temp.cpp:19:13: note: Value bound to 'arena' here
   19 |   void *p = arena.allocate(128);
      |             ^~~~~~~~~~~~~~~~~~~
temp.cpp:21:3: note: Lifetime of 'arena' ended here
   21 |   return p;
      |   ^~~~~~~~
1 warning generated.
```

The motivating example comes from here:
https://discourse.llvm.org/t/clang-static-analyzer-gsoc-2025-teach-the-clang-static-analyzer-to-understand-lifetime-annotations/84487/41?u=bkaibas01
@pull pull Bot locked and limited conversation to collaborators Aug 3, 2026
@pull pull Bot added the ⤵️ pull label Aug 3, 2026
@pull
pull Bot merged commit 6a7f6a0 into MPACT-ORG:main Aug 3, 2026
1 check failed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.