[LoongArch] Select LDPTR.W for any-extending i32 loads (#237883)
On LA64, an i32 load that does not require sign extension may be
represented as extloadi32 in SelectionDAG.
The existing LDPTR.W pattern only matches sextloadi32. This prevents
some constant-offset i32 loads from using LDPTR.W, resulting in
unnecessary address materialization and register-indexed loads.
Add an extloadi32 pattern for LDPTR.W, preserving the existing
zero-extension semantics and immediate-range constraints.
Assisted-by: Codex (cloud)
[mlir][affine] avoid folding affine expressions that overflow int64_t (#231085)
AffineExprConstantFolder used plain int64_t math for add/mul, so folding
something like (d0 + 1) with d0 = INT64_MAX overflowed. floordiv/ceildiv
of INT64_MIN by -1 had the same problem and hit an assert. Now we check
for overflow and just skip the fold when it happens.
Added tests for add, mul, and div overflow in canonicalize.mlir.
fixes #229706
---------
Co-authored-by: Mahmoud <mahmoud at Mahmouds-MacBook-Pro.local>
[mlir][ODS] Include headers required by generated enum declarations and definitions (#239223)
Generated enum declarations and definitions use C++ constructs that are
not declared by any header they include. They therefore relied on the
surrounding source file to include these headers first.
The enum declarations and definitions now include the headers declaring
these constructs, depending on the features of the enums.
The declarations still only forward declare `AsmParser` and
`FieldParser` to keep the generated headers cheap to include.
Similar to #236155 and #238735 but for the enum generator.
Co-authored-by: Claude <noreply at anthropic.com>
[Support] Use [[gnu::warn_unused]] for LLVM_ATTRIBUTE_WARN_UNUSED (NFC) (#239486)
This patch updates LLVM_ATTRIBUTE_WARN_UNUSED in Compiler.h to use the
C++11 attribute syntax [[gnu::warn_unused]] via LLVM_HAS_CPP_ATTRIBUTE
instead of __attribute__((warn_unused)).
GCC 12 and earlier reject:
class __attribute__((warn_unused)) [[nodiscard]] Foo { ... };
class [[nodiscard]] __attribute__((warn_unused)) Bar { ... };
This is exactly what happened in #237802. Specifically, it added
LLVM_ATTRIBUTE_WARN_UNUSED to APInt, which already had [[nodiscard]],
and broke GCC 12 buildbots, leading to a revert in #239152:
https://lab.llvm.org/buildbot/#/builders/181/builds/53859
This patch drops the __attribute__((warn_unused)) fallback because an
older compiler like Clang 5.0 would select it and fail when a class
also has [[nodiscard]]. It's always safe to expand this optional
[2 lines not shown]
[mlir][ODS] Include headers required by generated enum declarations and definitions
Generated enum declarations and definitions use C++ constructs that are
not declared by any header they include. They therefore relied on the
surrounding source file to include these headers first.
The enum declarations and definitions now include the headers declaring
these constructs, depending on the features of the enums.
The declarations still only forward declare `AsmParser` and `FieldParser`
to keep the generated headers cheap to include.
Similar to #236155 and #238735 but for the enum generator.
Co-authored-by: Claude <noreply at anthropic.com>
[DSE] Extend same ptr operand check to must-aliasing pointers in `storeIsNoop` (#238722)
We have observed a few DSE missed opportunities with a handful of CUDA
APIs that merely annotate a pointer with a cache hint and return it
(notably, `cuda::associate_access_property`). Thus, extend the existing
pointer equality check to must-aliasing pointers as well.
Co-authored-by: Alexander Krolik <akrolik at nvidia.com>
[mlir][SPIRV] Handle vector stores when unifying aliased resources (#232185)
I hit this while compiling JAX training code to WebGPU through IREE.
The alias-unification pass can select a smaller vector resource, but its
store conversion currently only handles scalars. Handle vector stores by
splitting them into stores of the canonical vector type, preserving
memory-access flags and alignment.
---------
Signed-off-by: anutosh491 <andersonbhat491 at gmail.com>
[mlir][SPIR-V] Add SPIRVToLLVM conversion for CL.ldexp and GL.Ldexp (#237745)
Vector exponents are not covered since llvm.intr.ldexp accepts only a
scalar integer exponent
[llvm-objcopy][MachO] Handle ARM64_RELOC_ADDEND for CPU_TYPE_ARM64_32 (#238296)
`ARM64_RELOC_ADDEND` was only handled for arm64, not arm64_32. On
arm64_32 the addend was read as a section index, so `llvm-objcopy` could
crash or write a wrong addend. Handle it for arm64_32 too, and add an
arm64_32 case to `arm64-relocs.s`.
Fixes #238273
I wrote the code and verified everything myself. Claude Code helped me
identify the issue.
Assisted-by: Claude Code
Reapply [IRBuilder] Assert correct offset width for CreatePtrAdd (#239262)
Reapply #238806 without changes after fixing more CreatePtrAdd uses.
-----
Assert that the offset width matches the pointer index width. This is
supposed to become an IR well-formedness requirement when we switch to
ptradd, so we should start asserting it in the builder now.
Helpers like CreatePtrAddWith(Unsigned|Signed)Offset and
CreatePtrAddWith[SZ]ExtOrTrunc can be used to more conveniently create
ptradds with appropriately sized offsets.
Problematic uses of CreatePtrAdd were already adjusted in #238347.
[MemorySanitizer] Consistently use unsigned offsets (NFC) (#239193)
Helper functions for getting origin/shadow etc accepted a mix of int and
unsigned. I believe all of these offsets are non-negative, so use
unsigned everywhere to avoid confusion.
[RISCV][P-ext] Remove line breaks from argument list of function definition in tests. NFC (#238881)
These line breaks cause the update_llc_test_checks.py script to put the
checks in the middle of the argument list.
[mlir][ODS] Include headers required by generated dialect declarations and definitions (#239215)
Generated dialect declarations and definitions use C++ constructs that
are not declared by any header they include. They therefore relied on
the surrounding source file to include these headers first.
The dialect declarations now include the header declaring the dialect
base class, and the headers declaring `StringAttr` and `Operation` if
the dialect has discardable attributes. The dialect definitions include
`MLIRContext.h` if they load dependent dialects.
Similar to #236155 and #238735 but for the dialect generator.
Co-authored-by: Claude <noreply at anthropic.com>
[LoongArch] Fix misaligned frame-index offset for vldrepl.{h,w,d}
eliminateFrameIndex did not check that the final offset is a multiple of
the access size for [X]VLDREPL_{H,W,D}, so a byte-aligned stack object
could produce an unencodable immediate. Materialize the address in a
scratch register in that case, as is already done for [X]VSTELM_*.
Assisted-by: LLM
[TargetLowering] Use DAG.getLibcalls() in expandMultipleResultFPLibCall (#239150)
`getLibcallLoweringInfo` and the helper `getLibcallImplCallingConv`
access the `Libcalls` from TargetLoweringBase, which is constructed
without the LLVM Module being available. This affects the libcalls
available through module flags like `long-double-type`. SelectionDAG
already consults the module flags, so missing it here can lead
inconsistencies in which libcalls are available.
Fixes: #239145
[Offload][Omp] Decouple RecordReplay from PluginInterface (#236814)
After we broke the `GenericKernelyTy` dependence in the RecordReplay
(RR), most of it became independent from the `PluginInterface`.
This PR moves the RR logic from the `PluginInterface` to libomptarget
and changes RR to use OpenMP errors and liboffload for data transfers.
Still, the _VirtualAddress_ interfaces are not available through the
liboffload API so we use them through temporary helpers.
I purposely didn't move the RR source files from the plugin directory so
the changes in this PR would easier to review. The code will be
reorganized in a follow-up NFC PR.
It was verified by @kevinsala on NVIDIA and AMD gpus.
Assisted by Claude
---------
Co-authored-by: Kevin Sala <salapenades1 at llnl.gov>
Attributor: Only check once if time trace scopes are recorded
Every initialization and update of an abstract attribute opened a
TimeTraceScope, which checks if the time profiler is enabled out of line.
Check it once per Attributor instead. NFC.
CTMark instructions:u with -attributor-enable=light changes by O3 -0.02%,
ThinLTO -0.03%. The attributor-light pass itself is 0.3-0.8% faster
(callgrind), and 0.3-1.9% faster with the other pending Attributor
compile-time changes applied.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>