[Mips] Fix the MIPS I %lo offset fold for loads and stores (#245716)
On MIPS I a double is loaded or stored with two lwc1 or swc1, and
selectAddrFrameIndexOffset() folds the %lo of the address into both.
That fold had three bugs:
- For a constant pool entry it dropped the %lo but kept the offset, so
the second half of an f64 constant was loaded from %hi(sym) + 4.
- For a global it always used %lo, so a $gp relative address got
%lo(sym+4)($gp) instead of %gp_rel(sym+4)($gp).
- Inline asm memory operands could get a symbolic offset, which hit an
assertion in MipsAsmPrinter::PrintAsmMemoryOperand().
Fold the offset into the constant pool entry or global with its own
relocation, only when the offset is within the alignment of the
symbol, so %hi(sym) is also %hi(sym+offset), as GCC does. Do not fold
jump tables, and only accept an immediate offset for inline asm memory
operands.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[C++20] [Modules] Correct Module Ownership and use canonical decl (#246565)
Close https://github.com/llvm/llvm-project/issues/245967
The root cause of the issue is that we didn't give deduction guide the
correct module ownership and we didn't use canonical decl correctly.
[OFFLOAD][L0] Skip Memcpy3D test in L0 (#246569)
One of the new Memcpy3D tests (SuccessSingleSliceZOffset) is failing in
some of the bulidbots configurations. Mark as skip while we investigate
the issue.
[AMDGPU][GlobalISel] Fix ds_append/ds_consume addressing
This matches the SelectionDAG fix. For LDS, ds_append and ds_consume
address memory only through the 16 bit instruction offset and ignore
M0, but the selector copied the pointer base into M0. Select a constant,
dword aligned LDS address into the offset field and diagnose any other
LDS address as unsupported.
For GDS, the offset field must be zero and the address comes from
M0.base, so build M0 as `(addr << 16) | gds_size`. Using GDS on a
subtarget without GDS is now diagnosed.
```
; call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)), i1 false)
; before
s_mov_b32 m0, 16
ds_append v0
; after
ds_append v0 offset:16
```
[AMDGPU] Fix ds_append/ds_consume addressing in SelectionDAG
For LDS, ds_append and ds_consume address memory only through the 16 bit
instruction offset. M0 is not used, but isel put the pointer (or its
base) into M0, so the counter was read at the wrong address. Select a
constant, dword aligned LDS address into the offset field and diagnose
any other LDS address as unsupported.
For GDS, the ISA requires the offset field to be zero and takes the
address from M0.base, so pack the whole address into M0 as
`(addr << 16) | gds_size`. Using GDS on a subtarget without GDS is now
diagnosed instead of silently encoding a GDS bit.
```
; call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)), i1 false)
; before
s_mov_b32 m0, 16
ds_append v0
; after
[4 lines not shown]
[LoongArch] Force a frame pointer for large call frames (#242625)
A large reserved call frame can push the emergency spill slot out of
reach of SP. Accessing the emergency spill slot can require a scratch
register. If none is free, scavenging fails with "Incomplete scavenging
after 2nd pass".
Adapt the RISC-V fixes from #181302 and #182124.
Compute the maximum call frame size at the end of ISel, before reserved
registers are frozen, and when loading MIR. Force a frame pointer when
the maximum call frame size exceeds the int12 range on LA32 or the int15
range on LA64, so the emergency spill slot can be addressed from FP.
LLM assisted.
[Mips] Use IMPLICIT_DEF and INSERT_SUBREG to insert an FP value into an MSA vector. NFC (#242320)
The lowering of INSERT_FW, INSERT_FD and the floating-point variants of
INSERT_*_VIDX used SUBREG_TO_REG to view the FP register as an MSA
register. SUBREG_TO_REG means that the instruction defining the FP
register also defined the rest of the MSA register, which is not the
case. Only element 0 is used, so the rest is undefined, which is what
IMPLICIT_DEF and INSERT_SUBREG express. This matches the lowering of
FILL_FW and FILL_FD.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
---
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Mips] Use INSERT_SUBREG of IMPLICIT_DEF for the halves of a 64-bit MSA splat. NFC (#242321)
When synthesizing a 64-bit splat value on MIPS64, the high and low
32-bit
halves are computed as i32 values and then combined with dinsu or
dsll32, which do not use the high 32 bits of the halves. Widen the
halves to i64 with INSERT_SUBREG into an IMPLICIT_DEF instead of
SUBREG_TO_REG, since nothing depends on the value of their high bits.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU][GlobalISel] Fix ds_append/ds_consume addressing
This matches the SelectionDAG fix. For LDS, ds_append and ds_consume
address memory only through the 16 bit instruction offset and ignore
M0, but the selector copied the pointer base into M0. Select a constant,
dword aligned LDS address into the offset field and diagnose any other
LDS address as unsupported.
For GDS, the offset field must be zero and the address comes from
M0.base, so build M0 as `(addr << 16) | gds_size`. Using GDS on a
subtarget without GDS is now diagnosed.
```
; call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)), i1 false)
; before
s_mov_b32 m0, 16
ds_append v0
; after
ds_append v0 offset:16
```
[AMDGPU] Fix ds_append/ds_consume addressing in SelectionDAG
For LDS, ds_append and ds_consume address memory only through the 16 bit
instruction offset. M0 is not used, but isel put the pointer (or its
base) into M0, so the counter was read at the wrong address. Select a
constant, dword aligned LDS address into the offset field and diagnose
any other LDS address as unsupported.
For GDS, the ISA requires the offset field to be zero and takes the
address from M0.base, so pack the whole address into M0 as
`(addr << 16) | gds_size`. Using GDS on a subtarget without GDS is now
diagnosed instead of silently encoding a GDS bit.
```
; call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)), i1 false)
; before
s_mov_b32 m0, 16
ds_append v0
; after
[4 lines not shown]
[AMDGPU] Stop sinking addresses into ds_append/ds_consume
ds_append and ds_consume have no address register operand. For LDS the
address comes only from the 16 bit offset field, and M0 is not used. The
register plus immediate DS addressing mode reported through
getAddrModeArguments does not apply, so CodeGenPrepare should not sink
address computations into these intrinsics.
```llvm
entry:
%in.gep = getelementptr i32, ptr addrspace(3) %in, i32 7
br i1 %cond, label %endif, label %if
if:
%val = call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) %in.gep, i1 false)
; before: CodeGenPrepare sinks the address into %if
%sunkaddr = getelementptr i8, ptr addrspace(3) %in, i32 28
%val = call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) %sunkaddr, i1 false)
; after: the call keeps using %in.gep
[5 lines not shown]
[IR] Remove unused PreservedAnalyses::AllAnalysesKey (NFC) (#246512)
The last readers were removed on November 16, 2026 in commit
e46986d56fa367465d141d005eae8a9a4ce1c29a. This patch also removes the
write-only insertion into PreservedIDs in PreservedAnalyses::all.
Assisted-by: Antigravity
[mlir][test] Add <arch>-registered-target lit features (#245526)
Align with LLVM, Clang, and Flang's test suites by defining
"<arch>-registered-target" lit features from the LLVM targets that were
built, so tests can require a specific backend. This replaces the
currently manually defined host-supports-* features.
Assisted-by: Claude Sonnet 5.5
[RISCV] Add Codegen support for ACLIC (#238325)
This commit adds support for the `preemptible` and `push-pop` interrupt
kinds from the RISC-V Advanced Core-Local Interrupt Controller (ACLIC)
fast interrupt extensions.
AI Usage: GPT 5.6 Sol/6/6.2 Astra, Opus 5/5.5, Fable 5.1/5.2 and Gemini
Neon were used for pre-commit self-reviewing.
[SandboxVec][LoadStoreVec] Vectorize store chains whose loads have external uses
Loads that feed a store chain used to block vectorization whenever they
had more than one use. The store chain can now be vectorized even if the
loads have external uses. Once the scalar stores are erased, each
original load is rebuilt from the lanes it occupies in the new vector
load, and reinterpreted back to its original type if needed.
The legality check, canUnpack(), runs before any IR is created, so a load
whose lanes cannot be reinterpreted (for example, a non-integral pointer)
rejects the whole chain instead of leaving a partially rewritten block.
The unpacking itself is done by unpackIfNeeded() after the scalar stores
have been removed.
Update the store_seeds.ll and mixed_types.ll checks to match the new
output.
Co-authored-by: Cursor <cursoragent at cursor.com>
[Clang][OpenMP] Allow array shaping as the base of array sections in target update (#244591)
Fixes #136294
`target update from((([nx][ny+2])a)[0:nx][1])`, the array shaping
example from the OpenMP Examples, fails with "array shaping operation is
not allowed here": the shaped expression only has a placeholder type, so
there is no array to take a section of.
The shaping expression now carries the array type the spec gives it, and
sections use it like a declared array's type, so the existing checks and
non-contiguous codegen apply as they are. The example also needs two
sections of one variable in a motion clause not to hit the 4.5 map rule,
and `target update` to treat a section it cannot prove contiguous as
non-contiguous.
Two neighbouring bugs surfaced on the way and are fixed here as well:
the size of a `depend` or `affinity` section whose elements are variable
length arrays stopped one element into the last row, and a shaping
[2 lines not shown]
[libc++] Fix discrete_distribution probability rounding
discrete_distribution::probabilities() computes the final probability as
one minus the last cumulative probability,
producing a negative value when rounding pushes that cumulative probability
above one.
The standard specifies p_k = w_k / S in
[rand.dist.samp.discrete]/2
and requires probabilities() to return p_k in
[rand.dist.samp.discrete]/12,
so a zero weight must have zero probability.
Accumulate the original weights before normalizing the cumulative sums to
keep them in [0, 1] and preserve trailing zero probabilities.
Since each cumulative weight is bounded by the total computed in the same
order, dividing by that total keeps the last cumulative probability at most
one, so subtracting it from one cannot produce a negative probability.
Assisted By: GPT-6.1 Sol
[clang][Sema] Add regression test for GH114174 (#233663)
PR #143423 fixed the assertion failure reported in #114174, but did not
add coverage for the original reproducer
Add a SemaTemplate regression test that verifies the invalid program
emits the expected diagnostics without crashing
Fixes #114174
[libc++] Fix discrete_distribution probability rounding
Normalizing weights before accumulating them could make discrete_distribution::probabilities() return a negative probability for a trailing zero weight. [rand.dist.samp.discrete] requires probabilities() to return p_k = w_k / S, so a zero weight must have zero probability. Accumulate the original weights before normalizing the cumulative sums to keep them in [0, 1] and preserve trailing zero probabilities.
[llvm-size] Refactor output formatting into SizePrinter classes (NFC) (#243385)
Introduce a class-based SizePrinter abstraction (SummarySizePrinter,
BerkeleySizePrinter, SysVSizePrinter, DarwinSizePrinter) to encapsulate
format-specific state and output logic instead of branching on
OutputFormat across printObject and printObjectSectionSizes.
Move per-run state (HeaderPrinted and totals) from file-scope globals
into printer instances, preparing llvm-size for cleanly adding
additional output formats such as GNU (-G / --format=gnu) and JSON.
Assisted-by: Gemini
[flang][OpenACC] Remove unused members in AccAttributeVisitor (NFC) (#246530)
dataMappingAttributeFlags was added on July 26, 2020 in commit
ff25b2da2ab9049e154cc8b9af06a24f79a74209 without any readers.
accDataMvtFlags was added on June 28, 2023 in commit
eeba037e0bb6bf0686eca73f4b4cf5eaf573499b without any readers.
Assisted-by: Antigravity
[flang] Reject interface name declared by a later PROCEDURE statement (#232928)
C1515 requires that a name used as a procedure interface, when it is
itself declared by a procedure declaration statement, be declared before
that use. Name resolution creates a placeholder symbol for a forward
reference and only checks it after the whole specification part, by
which point the later PROCEDURE statement has given it an explicit
interface, so the program was accepted.
In the deferred check, report an error when the interface name resolves
to a procedure entity whose declaration comes after the use. Forward
references to interface bodies and module procedures are still accepted.
Fixes #229229