[mlir][OpenACC] Keep ThreadY active for inner-combine-fed worker reductions (#211696)
Example:
```fortran
res = 0
!$cuf kernel do(2) <<< *, (32,8) >>> reduce(+:res)
do j2 = 1, n2
do j1 = 1, n1
res = res + a(j1, j2)
end do
end do
```
In this code the reduction accumulator is per-(block_y, thread_y): each
worker row's shared slot is filled by an inner block-scoped combine, so
the rows hold distinct partials. The final combine into the result was
classified as not "worker-private" (block_y+thread_y into a global
dest), so it fell back to the ThreadY row-zero path and dropped every
worker but row 0 — a 2D SUM returned -1 instead of -4.
Fix: keep ThreadY active for a block_y+thread_y accumulator that is fed
[3 lines not shown]
[llvm][AArch64] Fix the location of PAuth_LR AUT CFI (#211702)
Unlike PAC CFI, we do not have the same unwinder constraint on PAuth_LR
CFI occurring before the PAC instruction. For AUT CFI, like other CFI
opcodes, these should always occur after the instruciton that they
reference.
[mlir][affine] Add affine.for verifier and move arguments check earlier (#206685)
Fixes #206628 crash by adding an earlier body argument verifier for
`affine.for`. This crash is caused because `LoopLikeOpInterface`
verifier would call `getRegionIterArgs()` and assumed induction var of
`affine.for` exists.
[VectorCombine] Fix infinite loop in foldShuffleToIdentity (#211717)
PR #211508 ("foldShuffleToIdentity - ensure we push any created
instructions to the WorkList") started re-queueing every instruction
created by generateNewInstTree onto the VectorCombine worklist. When the
regenerated tree contains a bitcast, re-queueing the bitcast's operand
lets foldBitcastShuffle sink the bitcast back into a shuffle(bitcast),
which foldShuffleToIdentity then re-matches as the same superfluous
identity. On a widen/concat shuffle chain feeding a bitcast the two
folds
ping-pong and the pass never reaches a fixed point (observed as an opt
-O3 hang/timeout).
Keep the WorkList threading from PR #211508 (it enables further folds,
e.g. the improved intrinsics_minmax and two_concats cases) but don't
re-queue the operand of a regenerated bitcast, which is the only push
that feeds the foldBitcastShuffle <-> foldShuffleToIdentity loop.
Add an X86 regression test that previously looped and now terminates.
[3 lines not shown]
[AMDGPU] Add synthetic apertures and use them for barriers
Define what a synthetic aperture is, and adjust the barrier AS
to use this new system. This makes the barrier AS even safer to
use as now we can use all 32 bits of it without ever risking
hitting a valid address of any kind (LDS or outside LDS).
[libc++] Consistently install Python and dependencies across macOS CI jobs (#211659)
On the macOS self-hosted runners, we need to install dependencies via
Homebrew and pinning the Xcode version is good for reproducibility. This
applies the guidelines documented in #211622 to libc++'s CI jobs.
[BOLT] Fix pwrite assertion failure via a new safePWrite wrapper (#198569)
Background: Currently, BOLT seems to implicitly assume that the .dynsym
section is located at a low offset within the binary, calling pwrite()
directly to update it.
Issue: In scenarios where the binary has been modified by tools like
patchelf, sections like .dynsym may be moved to a high offset area. This
can lead to a violation of the Offset + Size <= Pos assertion in
pwrite(). A typical scenario is when the previous eh_frame_header update
moves the stream cursor (pos) back to a low
offset([code](https://github.com/llvm/llvm-project/blob/llvmorg-23-init/bolt/lib/Rewrite/RewriteInstance.cpp#L6387)).
Fix: This patch resolves the pwrite assertion failure via a new
safePWrite wrapper, which introduces a defensive check that verifies and
conditionally adjusts the stream position. A corresponding test case has
also been added.
[VPlan] Fix sentinel assertion when broadcasting invoke results (#210464)
VPTransformState::get broadcasts a scalar value by inserting after the
last scalarized instruction using
std::next(BasicBlock::iterator(LastInst)). When LastInst is a terminator
like invoke, std::next advances past the end of the block, hitting the
!isKnownSentinel() assertion.
Use Instruction::getInsertionPointAfterDef which correctly handles PHIs,
invokes, and regular instructions, matching the pattern already used in
VectorCombine.cpp.
Fixes #210342
AMDGPU: Use ProcessorAlias for legacy arch names
Older targets have aliasing names which were previously implemented
by defining a second copy of the processor, identical except for the name
Use the recently improved tablegen mechanism for defining name-only aliases.
This dedupliates some redundant table entries, like the sched model.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
TableGen: Add first class support for processor aliases
Previously isCPUStringValid was virtual so TableGen could emit an
AArch64 specific hack for recognizing cpu aliases. Teach tablegen
about aliases, and insert each alias into the CPU subtype table as its
own entry (sorted by name, carrying the canonical processor's features
and scheduling model).
There is further opportunity for code sharing improvements. AArch64's
aliases are consumed by ARMTargetDefEmitter to emit a custom inc file
in TargetParser which should be universalized.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[OpenMP] Fix build error after 19857baa71 (#211771)
Some builders using older versions of gcc encounter this issue:
```
llvm/include/llvm/Frontend/OpenMP/OMP.h:138:14: error: ‘Base’ has not been declared
138 | assert(Set.Base::test(At));
| ^~~~
```
E.g. https://lab.llvm.org/buildbot/#/builders/10/builds/32524
[MLIR][Python] Make Python-defined dialect loading context-aware (#210501)
Python-defined dialect loading currently relies on
`Dialect._mlir_module` to infer whether a dialect has already been
loaded. This state belongs to the Python dialect class rather than an
MLIR context.
Consequently, loading the same dialect after switching contexts requires
`reload=True`, while reloading it in a context where it is already
present can hit the operation registration assertion reported in
#210053.
This patch adds `mlirContextGetLoadedDialect` (following
https://github.com/llvm/lighthouse/pull/228#discussion_r3589792891) to
the C API and exposes it as `Context.is_dialect_loaded`.
`Dialect.load()` now queries the active context:
- loading a dialect more than once in the same context raises a
`RuntimeError`;
- loading the same Python-defined dialect in another context succeeds
[8 lines not shown]
[LV] Simplify VPCostContext ctor by using VFSelectionContext (NFC). (#211765)
VFSelectionContext provides most fields needed. Pass it directly and
access its fields.
[ExpandMemCmp] Check misaligned access per overlapping/tail load (#210707)
Overlapping loads place a power-of-two load at an offset that need not be
a multiple of its size, so the access can be misaligned even when the base
pointers are aligned. Rather than have each target gate
`AllowOverlappingLoads` on unaligned support, give `MemCmpExpansion`
the target info and check the overlapping load against its actual alignment
`(commonAlignment(baseAlign, offset))` via
`TargetTransformInfo::allowsMisalignedMemoryAccesses`. It is only formed when
the target can access it; otherwise the expansion falls back to the greedy
(naturally aligned) sequence.
Tail expansions are different: they merge already-legal adjacent loads
covering the same bytes, and the backend always legalizes the merged
(possibly non-power-of-two) load into aligned power-of-two pieces, so
they need no alignment gate. The one real constraint is size: a merged load
wider than `MaxLoadSize` can only be emitted when it is the sole load
(`getMemCmpOneBlock`). In a multi-block expansion, `emitLoadCompareBlock`
and the result-block phis are sized to `MaxLoadSize` and assume every
[6 lines not shown]
[AArch64] Add Apple SME compute clustering macro-fusion (#211483)
This patch adds a subtarget feature that controls scheduling SME compute
instructions back to back. Enabled on Apple CPU.
[X86] Match (FM)ADDSUB patterns from target shuffles as well as ISD::VECTOR_SHUFFLE (#211764)
Allows us to match X86ISD::ADDSUB/FMSUBADD/FMADDSUB after shuffle lowering
Reland [OMPIRBuilder] Don't use invalid debug loc in reduction fn. (#211566)
This fixes https://github.com/llvm/llvm-project/issues/211385. This was
initially landed in https://github.com/llvm/llvm-project/pull/148284.
We have this pattern of code in OMPIRBuilder for many functions that are
used in reduction operations.
```
Function *LtGRFunc = Function::Create
BasicBlock *EntryBlock = BasicBlock::Create(Ctx, "entry", LtGRFunc);
Builder.SetInsertPoint(EntryBlock);
```
The insertion point is moved to the new function but the debug location
is not updated. This means that reduction function will use the debug
location that points to another function. This problem gets hidden
because these functions gets inlined but the potential for failure
exists.
[8 lines not shown]
[flang][OpenMP] Switch TableGen generation to use llvm::EnumSet (#211327)
Replace the remaining uses of the common::EnumSet-based OmpClauseSet to
llvm::omp::ClauseSet.
[flang] Provide "clause set" type as parameter to DirectiveStructureChecker (#211326)
This will remove the hardcoded dependence of DirectiveStructureChecker
on
the common::EnumSet class. Both consumers of it will be able to use
their
own type for the clause set.
The only complication was the ClauseSetToString member function, whose
implementation depended on the specifics of common::EnumSet, namely the
IterateOverMembers member function. It was moved out of the class, and
turned into a function template to make it possible to provide different
specializations for common::EnumSet and llvm::EnumSet.
[flang][OpenMP] Use llvm::omp::DirectiveSet instead of common::EnumSet (#211325)
Replace uses of OmpDirectiveSet (defined in terms of common::EnumSet)
with the common llvm::omp::DirectiveSet (defined via llvm::EnumSet).
The llvm::omp::DirectiveSet class will also be used in openmp-parsers,
where OmpDirectiveSet was an instance of llvm::Bitset.
[flang][OpenMP] Use llvm::omp::ClauseSet instead of common::EnumSet (#211324)
Replace uses of OmpClauseSet (defined in terms of common::EnumSet)
with the common llvm::omp::ClauseSet (defined via llvm::EnumSet).