[AMDGPU] Lower uniform uaddsat.i16 to SALU instructions
Promote uniform i16 uadd.sat to i32 in promoteUniformOpToI32 so it
lowers to SALU (s_add_i32 + s_min_u32) instead of VALU + readfirstlane.
The saturating add on zero-extended operands reduces to
umin(add(lhs, rhs), 0xffff).
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU] Add tests for uniform uaddsat.i16 (NFC)
Precommit tests covering uniform (SALU) uadd.sat for i16 and vector
i16 (v2i16, v3i16, v4i16) using the amdgpu_ps calling convention so
results are returned in SGPRs. These currently lower to VALU
(v_add_u16 clamp / v_pk_add_u16 clamp + v_readfirstlane).
Co-authored-by: Cursor <cursoragent at cursor.com>
[CIR] Rewire byref args to the incoming pointer (#210836)
The CallConvLowering body rewrite for Indirect arguments treats byval
and
byref the same way: it inserts a cir.load at function entry and reroutes
body
uses to the loaded value. For byref — a non-trivially-copyable type
passed by
pointer — that entry load is a byte-copy, so the callee works on a local
copy
instead of the caller's storage. That breaks types whose representation
embeds
self-referential pointers: libstdc++'s SSO std::string keeps _M_p
pointing at
its own _M_local_buf, and a byte-copy leaves the copy's _M_p aliasing
the
source's buffer.
This mirrors the sret return fix in insertSRetStores. For byref only,
[15 lines not shown]
[bazel] Add os select for plugin process on Initialization target to add windows (#211276)
Another small piece of windows build support for LLDB in bazel.
Internally at Meta, our buck2 rule for this has a split for mac/linux
with PluginProcessPOSIX and windows with PluginProcessWindowsCommon. So
this should be a no-op for existing linux & mac builds while setting up
a bit more for windows.
I have no bazel build set up locally, so will wait on CI to confirm no
regression.
bazel rule creation assisted with claude
[mlir][OpenACC] Forward dynamic boxed reduction extents (#211318)
Example:
```fortran
subroutine reduce(a, x, n)
integer :: n, i
real :: a(:), x(:)
!$acc parallel loop reduction(+:a)
do i = 1, n
a(:) = a(:) + x(i)
end do
end subroutine
```
`ACCCGToGPU` represents each gang/thread-private array as a dynamically
offset `memref.subview`. Converting this subview directly to a FIR
pointer-like type loses the memref offset, causing different private
copies to alias the same storage.
[34 lines not shown]
[DebugInfo] Avoid duplicate DIGlobalVariableExpression during upgrade (#190616)
During bitcode upgrades, if an old DIGlobalVariable is encountered that
contained a DIExpression, a DIGlobalVariableExpression is created for
it. This could happen multiple times. As described in
https://reviews.llvm.org/D26769, it is valid for a DIGlobalVariable to
have multiple DIGlobalVariableExpressions, but the use case for this is
a location that cannot be represented in a single DIExpression, not a
redundant restatement of the same DIExpression.
RuntimeLibcalls: Drop artificial __aeabi_?cmpeq suffixes (#211251)
Avoid defining synthetic LibcallImpls just to match the use
case of the legalizer. __aeabi_?cmpeq returns a boolean for
ordered-equal and was defined twice with __oeq/__une enum
suffixes so the one symbol could serve both OEQ and UNE.
Replace each pair with a single unsuffixed impl providing only
OEQ. The legalizer can directly invert it without the dummy entry.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[mlir-c] Add TypeConverter materialization; use a status enum for the type conversion callback (#208934)
Continues the buildout of the dialect-conversion C bindings (follows
#206146 and #206161).
- Exposes `TypeConverter::addSourceMaterialization` and
`addTargetMaterialization` through the MLIR C API.
- Introduces `MlirTypeConverterConversionStatus`
(`Success`/`Failure`/`Declined`) and switches
`MlirTypeConverterConversionCallback` to return it, replacing the old
`MlirLogicalResult` + `MlirType{NULL}` dual sentinel. The old convention
could not distinguish the C++ decline (`std::nullopt`, try the next
conversion) and hard-failure (`failure()`, stop) states; the enum maps
cleanly to all three. The Python binding and C API test are updated
accordingly.
Assisted by: Claude
[libunwind][test][AIX] Add C API test for unwinding from AIX VAPI (as signal handler) (#209662)
Further to https://github.com/llvm/llvm-project/pull/209306, test a case
where a signal handler is a Virtual API function triggered synchronously
while the VAPI is not active. Resuming an ancestor context of the signal
frame should call the VAPI return glue.
---------
Assisted-by: IBM Bob
[flang][OpenMP] Switch TableGen generation to use llvm::EnumSet
Replace the remaining uses of the common::EnumSet-based OmpClauseSet to
llvm::omp::ClauseSet.
[flang] Provide "clause set" type as parameter to DirectiveStructureChecker
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
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
Replace uses of OmpClauseSet (defined in terms of common::EnumSet)
with the common llvm::omp::ClauseSet (defined via llvm::EnumSet).
[AMDGPU] Support i16 element types for tbuffer D16 load/store (#201420)
Detect D16 by element bit width rather than matching f16 specifically,
so integer i16 elements take the same packed/unpacked path
[OpenMP] Implement EnumSet container
This is close to flang's common::EnumSet with the difference being that
it provides forward iterators.
The reason for having an implementation that is separate from
common::EnumSet is that this is intended to be shared for all consumers
of llvm/lib/Frontend/OpenMP. This class is also planned to be one of the
core containers for representing auto-generated OpenMP data in the future.
[libunwind][test][AIX] Add C API test for unwinding from AIX VAPI (non-signal-handler case) (#209306)
Test detection, during stepping, of the backchain mutation introduced by
a VAPI call (see https://github.com/llvm/llvm-project/pull/209280).
Further, test resumption of contexts using cursors obtained while a VAPI
is active on the thread.
Testing is done via FileCheck inspection of trace output enabled by
`LIBUNWIND_PRINT_UNWINDING=1`. When Live Library Update is not enabled,
synthetic trace output is generated by the test program itself.
---------
Assisted-by: IBM Bob
[SLP] Vectorize select-addressed loads as masked-load blends
Recognize loads whose address is chosen per lane via
select(cond, A, B) and vectorize them as two masked loads blended
by a select, instead of gathering.
Fixes case 6 from #206367
Reviewers: hiraditya, RKSimon, bababuck
Pull Request: https://github.com/llvm/llvm-project/pull/210455
[flang][Lower] Admit opaque terms to real sum reassociation
First part of follow-ups for generalisations requested in #207377.
The split-sum eligibility check rejected any RHS containing explicit
parentheses or subtraction, even though the Add flattener already
preserves every non-Add subtree as one opaque term.
Remove those blanket guards and their unused predicates. Document the
opaque-term invariant and extend the test to cover parenthesized
additions and subtractions, whole-RHS parentheses, and subtraction
terms.
Assisted-by: Codex
[lldb] Fix Unicode code point formatting to use proper notation (#211131)
- use uppercase hex digits
- only emit "U+" notation for valid code points (<= U+10FFFF),
zero-padded to a minimum of four digits.
rdar://173817553
Assisted-by: claude
[flang][cuda] Fix cuf-alloc-delay for host-associated allocatables (#211103)
`cuf-alloc-delay` sinks a managed descriptor's `cuf.alloc` group
(`{cuf.alloc, fir.store, fir.declare}`) to just before its first use, to
defer the managed allocation. It special-cased the store of the descriptor
into a host-association tuple slot (`fir.store` to a `fir.llvm_ptr`): it did
not count that store (nor the call that consumes the tuple) as a use, and moved
the store along with the group. As a result, when a managed allocatable descriptor
is stored into a host-association tuple and passed to an internal procedure, the group
could be sunk **past** the internal-procedure call that reads the tuple, so the
callee observed an uninitialized descriptor. On more complex tuples, moving the
host-association store also broke SSA dominance, producing
`operand #1 does not dominate this use`.
With this PR, `findDelayTarget` now treats **every** use of the
descriptor as a real use, including the host-association store. The group is only ever sunk to
*before* the first use, and the host-association store is never moved (it reads
its own `fir.coordinate_of` slot). This keeps the descriptor initialized before
the tuple is consumed and is dominance-safe by construction.
[Flang] Return APInt from getIntIfConstant (#211233)
Preserve the full bit width of integer attributes when extracting
constants from FIR values. Return llvm::APInt directly and update
fixed-width consumers to use checked signed extraction.
This avoids truncating or asserting on constants wider than 64 bits
while retaining existing fallback behavior at int64_t boundaries.
This should be NFC everywhere we didn't have a latent overflow bug. I
didn't go so far as updating the interfaces of every function built on
top of getIntIfConstant: this is mostly to make an APInt version
available because it looks useful for another PR. Fixing the builder API
to use APInt would be a larger change - let me know if anyone wants to
see that.
Assisted-by: Codex
[lldb][test] Skip more WebAssembly-unsupported API tests (#211305)
Skip tests that exercise features WebAssembly does not provide:
expression evaluation, registers, an ABI plugin, and unmapped memory
pages.