[SandboxVec][LoadStoreVec] Address review on mixed-type loads
Rename getLanesTypeFor to getSameBitWidthType and document that a wider
scalar spans several lanes. Drop the unused LoadInst cast, explain the
test data layout, and cover a reversed vector/scalar chain plus loads
with multiple uses.
Co-authored-by: Cursor <cursoragent at cursor.com>
[SandboxVec][LoadStoreVec] Support mixed-type load vectorization
Remove the restriction that every load in a top-level load chain must have the vector's element type. A chain of mixed types such as {i32, float} or {double, i32, i32} is loaded as a vector of integers (as chosen by VecUtils::getCombinedVectorTypeFor()), each original load is unpacked from the lanes it occupies, and then reinterpreted back to its own type with SameSizeReinterpret::reinterpretValue().
Chains involving a non-integral pointer are left alone, since such a pointer cannot be recovered from an integer lane.
SameSizeReinterpret is also used by createConstantVector() to pack constants of mixed types into a constant vector.
Co-authored-by: Cursor <cursoragent at cursor.com>
[mlir][NVVM] Partition the NVVM dialect ops (#242400)
Including `NVVMDialect.h` is expensive. The header declares all 219 ops
of the dialect regardless of how many ops are being used by an includer.
The dialect library pays the same price: each of its 12 TUs includes all
op declarations through a precompiled `NVVMDialect.h`, including the 8
TUs that each define an eighth of the ops and `NVVMDialect.cpp`, which
implements all of them.
This patch replaces the index sharding with op partitions ("logical
sharding", #239254). The ops are grouped by topic into 10 partitions.
Every partition has its own header, which declares the ops of the
partition, and its own source file, which defines them together with
their hand-written implementations (verifiers, parsers, printers,
builders, intrinsic lowerings, etc.).
`NVVMDialect.h` stays as an umbrella header that includes all partition
headers, but its use is discouraged. Its includers in MLIR and flang now
include what they use instead unless they require the majority of the
[24 lines not shown]
[Sparc] Support 64-bit atomics in 32-bit V8+ code (#242578)
Implement 64-bit atomics for 32-bit SPARC when targeting V9 in V8+
mode, mirroring what GCC does:
- 64-bit atomic loads and stores use ldd/std (GCC's atomic_loaddi_1
and atomic_storedi_1).
- 64-bit compare-and-swap packs the 32-bit halves into %g/%o
registers, issues casx and splits the result back, using the same
sequence as GCC's *atomic_compare_and_swapdi_v8plus. Only %g/%o
registers are used for the 64-bit temporaries since those are the
only registers whose upper halves are preserved under the V8+ ABI
(GCC's "h" constraint / I64_REGS class, minus %o7, which holds the
return address in leaf procedures). The pseudo is expanded after
register allocation so no 64-bit value is spilled via a 32-bit slot.
- Other atomic RMW operations are expanded to cmpxchg loops.
The new %g/%o register class can allocate %o registers before %l0 is
used, which breaks the assumption behind the leaf procedure %i -> %o
[22 lines not shown]
[flang][CodeGen] Fix narrowing conversion in genGEP call (#244972)
Fixes a -Wnarrowing error (unsigned -> int32_t) in the genGEP call using
kRankPosInBox, which breaks GCC -Werror builds (seen on the
flang-s390x-linux bot).
[mlir][ODS] Generate hooks that register the attributes and types of a dialect
Dialects registered their generated attributes and types by expanding
`GET_ATTRDEF_LIST` (or `GET_TYPEDEF_LIST`) into the template arguments
of `addAttributes` (or `addTypes`).
This requires each and every type and attribute and their storage classes' to be defined at the callsite and is generally boilerplate that exists in most dialects.
This PR introduces a single registration hook that is generated by ODS and should be called from dialects' `initialize` method instead. The implementation of the hook now performs the registration.
The motivation and further advantage of this approach is that we can then also change the implementation of the registration method in ODS while keeping API compatibility. This is required for partitioning of attributes and types e.g. (https://github.com/llvm/llvm-project/pull/241935).
Docs have been updated to advise users to use the new registration method. However, no upstream dialect beyond the test dialect has been switched nor is the old method of registration planned to be deprecated as it is still useful in some contexts (e.g., extendible dialects or C++ defined types and attributes).
Co-authored-by: Claude <noreply at anthropic.com>
[APFloat] Support user defined bit conversions (#242370)
[APFloat] Support user provided conversion to/from bits
This change allows users to provide custom functions to convert to/from
bits.
- fltSemantics has function pointers for conversion and user provided
values of it are supported
- built-in semantics also use these instead of chained if, making the
code less repetitive and slightly faster
- APFloat/IEEFloat internals like types and ranges of significand,
mantissa etc. can only be accessed using FloatRepr interface so only
user defined bitcast functions will be affected by changes
Resubmitted https://github.com/llvm/llvm-project/pull/233961 / #240920
with fixes for GCC 7 and MSVC2019
[CodeGen] Honor disabled and reserved CSRs in `getCalleeSavedRegs` (#241593)
Previously, `getCalleeSavedRegs` simply returned the unfiltered TRI CSRs
on its first invocation, even when it had already populated
`UpdatedCSRs`. And calling `disableCalleeSavedRegister` prior to
`getCalleeSavedRegs` initialized `UpdatedCSRs` without filtering out
user-reserved registers.
Additionally, both the prolog/epilog inserter for zeroing call used
registers, and the register usage collector queried
`TRI.getCalleeSavedRegs`, ignoring anything disabled with
`disableCalleeSavedRegister`.
All this led to miscompiles:
https://cpp.compiler-explorer.com/z/rKdcnq7oP
Fixed by correctly returning `UpdatedCSRs` from MRI's
`getCalleeSavedRegs`, filtering user-reserved registers when populating
it, and changing the places to call it rather than TRI.
Assisted-by: Antigravity with Gemini
[clang][Sparc] Define _SOFT_FLOAT instead of SOFT_FLOAT (#245137)
With -msoft-float, Clang defined SOFT_FLOAT to 1. GCC defines
_SOFT_FLOAT, and SOFT_FLOAT is not in the reserved namespace. Do what
GCC does.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Add a split mode to cir-offload-merge
Write each module of an offload container to its own file, named after
the driver's offload files (<stem>-<kind>-<triple>.cir). Combine keeps
the original module name in cir.offload.source_name so split can give
back the modules as they were before combine.
[LoopUnroll] Avoid revisiting shared SCEVs in uniformity checks (#244318)
Checking whether a backedge count is uniform can take exponential time
when its SCEV contains shared subexpressions. Use SCEVExprContains to
visit each node once.
LoopUnroll only checks backedge count uniformity for targets with branch
divergence. The regression test uses AMDGPU to exercise that check.
Assisted-by: OpenAI Codex
[Sparc][MC] Reject out-of-range %rN register names (#245110)
matchRegisterName only parsed the first two digits after "%r", so
"%r100" was accepted as %r10 (%o2), "%r145" as %r14 (%sp) and "%r310"
as %r31 (%i7). Parse the whole number instead.
GNU as rejects these names too.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[mlir][nvgpu] Do not convert transfers masked by vector.mask to async copies (#238721)
`createAsyncGroups` checked the mask operand of a
`vector.transfer_write` but not an enclosing `vector.mask`. A
region-masked write was replaced in place, which dropped the mask and
left non-maskable ops inside the `vector.mask` region, failing
verification.
Reject transfers masked by `vector.mask`.
Found while auditing the `in_bounds` readers for #227821.
Part of #239511.
[orc-rt][ORC] Let controllers create SimpleNativeMemoryMaps (#245113)
Executors previously had to create a SimpleNativeMemoryMap up front and
publish it under an instance symbol. This commit adds a create
entrypoint, orc_rt_ci_sps_SimpleNativeMemoryMap_create, that constructs
a new instance, adds it to the calling Session as a Service, and returns
its address. Executors still decide whether SimpleNativeMemoryMap is
available, but controllers now decide whether to create instances, and
how many.
orc-rt changes:
* SimpleNativeMemoryMap's Create methods are replaced with a public
constructor, and its header no longer depends on the SPS controller
interface.
* sps::ci::addSimpleNativeMemoryMap adds the create entrypoint along
with the memory operations. It is still called from sps::ci::addAll.
* ogre no longer creates an instance, since sps::ci::addAll now
publishes the create entrypoint.
[14 lines not shown]
[mlir][acc] Translate the acc.offload_entry attribute to an offloading entry (#242809)
Add the acc.offload_entry unit attribute, which marks a global host
symbol (either a function or a global variable) that the offload runtime
must be able to associate with its device counterpart. The translation
emits entries that are registered with the OpenACC runtime libacctarget.
Assisted-by: Claude Sonnet 5.5
[clang-repl] Use an in-memory main file and createTarget in CreateCI (#243830)
This PR simplifies how clang-repl sets up its compiler instance.
clang-repl needs an empty starting file, which was previously provided
through a heap-allocated buffer that leaked if nothing used it, so the
unit tests had to free it by hand. That file is now an empty in-memory
input that needs no cleanup, so the manual cleanup in the tests is
removed.
It also replaces the hand-written target setup with clang's existing
`createTarget()` helper.
Assisted by Claude Opus 5.5
[mlir][acc] Translate #acc.offload_packager to LLVM IR (#242808)
Add a translation library for the OpenACC dialect that implements the
offloading translation interface of #acc.offload_packager. Each object
of a gpu.binary is wrapped in an offloading binary of kind OpenACC,
carrying the target triple and architecture, and the images are placed
in the .llvm.offloading section of the host module for the offloading
linker wrapper to extract.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Translate the acc.offload_entry attribute to an offloading entry
Add the acc.offload_entry unit attribute, which marks a global host symbol
(either a function or a global variable) that the offload runtime must be able
to associate with its device counterpart. The translation emits entries that
are registered with the OpenACC runtime libacctarget.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Translate #acc.offload_packager to LLVM IR
Add a translation library for the OpenACC dialect that implements the
offloading translation interface of #acc.offload_packager. Each object
of a gpu.binary is wrapped in an offloading binary of kind OpenACC,
carrying the target triple and architecture, and the images are placed
in the .llvm.offloading section of the host module for the offloading
linker wrapper to extract.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Add the #acc.offload_packager offloading handler (#242807)
Add an offloading handler attribute for gpu.module and gpu.binary that
is meant to embed the device images in the host object as LLVM
offloading binaries of kind OpenACC, for the offloading linker wrapper
to link and register with the OpenACC runtime.
Assisted-by: Claude Sonnet 5.5
[ARM64EC] Fix vararg pointer in entry/exit thunks for 16-byte return value (#237817)
When a function returns a 16-byte structure, in the x86-64 calling
convention it is returned in memory with a hidden pointer, but in the
ARM64EC calling convention it is returned in {X0,X1} so it does not have
a hidden pointer. In this case the x86-64 function has one more
argument, and up to at most three arguments can be passed in register --
X4 now points to the 4th argument, instead of the 5th as the old code
mentioned.
In the exit thunk, the reverse applies: The ARM64EC function does not
pass a hidden pointer, but the x86-64 function expects one, causing the
4th argument (if any) to spill on the stack.
This commit shifts arguments by one, pops one argument from the stack
into an integer register, and adds X4 by 8 so it will point to the 5th
argument as ARM64EC expects.
Assisted-by: DeepSeek V4.1 Flash
[Hexagon] Reserve V30 for v79 QFloat handling (#243763)
For v79, floating point vector operations involving extended qfloat, we
need to use v30 as a scratch register in the post RA Xtended QF handling
pass. We reserve it when we use xqf for v79 for non-legacy mode, ie.
strict-ieee, ieee or lossy mode when xqf instructions are present.
Fixes #237215
Co-authored-by: quic-santdas <quic_santdas at qti.qualcomm.com>
[Driver] Support -rtlib=none (#245001)
This is helpful in situations when linking the runtime library is
undesirable, for example when building the runtime library itself. It
also makes the --rtlib= option consistent with --unwindlib=.
[IPO] Declare sample profile inliner command line options in TableGen (#244670)
SampleProfile.h replaces the exported cl::opts with
SampleProfileInlineOptions, which
SampleProfileLoaderPass::getInlineOptions fills from the options given
over the caller's defaults. llvm-profgen's preinliner reads its
thresholds this way instead of writing the cl::opts, and the loader no
longer writes the global size limits for non-CS profiles.