[mlir][reducer] Report why output file can't be opened (#245650)
When a file with -o can't be opened, mlir-reduce exits with 1 and prints
nothing. openOutputFile puts the reason into errorMessage, but the
caller never printed it. Print it now, as mlir-opt and mlir-translate
do, and as mlir-reduce already does for input file.
Assisted-by: Claude for PR description for grammar.
[libc][string] Optimize strncpy() with strnlen() and memory operations (#235762)
The current strncpy implementation copies characters and pads trailing
null bytes using byte by byte loops. Replace these loops with
internal::strnlen, inline_memcpy, and inline_bzero to leverage
word-level and vectorized memory operations.
In a microbenchmark copying a 512 byte string into a 1024 byte buffer,
this reduces execution time by about 43%, or 1.77x faster.
[mlir:affine] Drop affine if condition from affine scope when in else block (#245625)
When computing the `FlatAffineValueConstraints` of an operation which is
inside the else block of an affine if, the affine if still restricts to
its then integer set because of:
https://github.com/llvm/llvm-project/blob/74e01f5a8681ef994953f7baae2c4339ee5e68b0/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp#L287-L288
when it should be on the complement of the integer set which cannot
necessarily be modeled as a `FlatAffineValueConstraints`.
To solve this in this PR, affine if operations are dropped from the
enclosing affine scope, which loosens the iteration space and allows
memory dependence to be checked more correctly (see the added
parallelize test which llvm main does parallelize).
Debugging & developing this PR was assisted by LLM.
[mlir][llvm] Reject duplicate case values in llvm.switch (#245592)
The verifier of llvm.switch checked the number of case values and their
type, but not whether two case values are equal. Such an op verifies in
MLIR and is then rejected by the LLVM IR verifier on translation
("Duplicate integer as switch case").
Report the first repeated value instead, with its signed and, when
different, unsigned spelling and the indices of both cases. This matches
the check added to cf.switch. Add an invalid test where -1 repeats for
i8, and a round-trip test that 1 and -1 remain distinct cases.
AI-assisted: this patch was prepared with Claude Code; I have reviewed
and tested the change and take responsibility for it.
[mlir][affine] Implement RegionBranchOpInterface for affine.parallel (#244678)
The implementation is similar to SCF: only control flow is declared but
no data flow along the edges since it is not 1:1.
[mlir][OpenMP] Model memory effects of omp.threadprivate (#243080)
Model accesses to the original and thread-local storage and allocation
effects.
Add a test for the reported memory effects.
AI-Assisted-by: Codex (OpenAI)
[lldb][NFC] Remove GetChildCompilerTypeAtIndex
All type systems and callers use GetChildAtIndex now, so this patch removes
TypeSystem::GetChildCompilerTypeAtIndex and its CompilerType wrapper, and
makes TypeSystem::GetChildAtIndex pure virtual.
assisted by claude
[lldb][NFC] Remove redundant zero assignments in TypeSystemClang (#245938)
TypeSystemClang::GetChildAtIndex starts from a value-initialized
ChildTypeInfo, so it doesn't need to set byte_offset to 0.
assisted by claude
Stack:
- #245936
- #245937
- #245938 (this PR)
- #245939
[CGP] Support nonzero start value for vector lsr (#245979)
The vector lsr code currently insists on matching a plain stepvector as
the starting point for vector progression (before being shifted
according to element count and addressee size). This patch allows for an
add of splatted loop-invariant value before the multiply.
[IR] Enforce pointer return type for `captures(ret: ...)` attribute annotation (#243407)
Following up on a discussion based on
https://github.com/llvm/llvm-project/pull/238026#discussion_r4584703141,
reject `captures` attribute with return-only components on function and
call-site parameters when the return type is not a pointer.
Particularly, this excludes vector and aggregate return types,
consistent with how CaptureTracking currently treats a pointer inserted
into an aggregate or vector as captured.
[X86][APX] Keep hoist-folded-copy test effective
inline-spiller-hoist-folded-copy.ll reproduces a null VNInfo
dereference in HoistSpillHelper that needs greedy to fold a spill
into the COPY inserted by an NDD reload fold. SlotIndexes compaction
shortens the outer loop in index space, greedy spills differently,
and the test passes even with the fix reverted.
Add four empty asm statements to lengthen the loop again. The test
then crashes without the fix whether compaction is on or off.
[X86] Enable SlotIndexes compaction by default
Compacting SlotIndexes before greedy allocation drops the entries of
erased instructions, so live range sizes and instruction distances
reflect the code being allocated rather than how much was erased
before it. AMDGPU has done this since #235806; do the same for X86.
Codegen changes only through allocation: no new crashes, verifier
errors or allocation failures in the lit suites, including
EXPENSIVE_CHECKS, and a stage-2 build of LLVM, clang and lld with
-verify-machineinstrs passes its own tests. On llvm-test-suite at -O3,
spills drop 0.3% and .text 0.06%, with compile time unchanged.
Most test updates are regenerated checks. misched-matmul now inserts
20 spills instead of 24. live-debug-vars-stale-slotindexes.mir gets
one more use of %27 so that accumulate_fit still reaches the stale
index path it was written for.
[X86][APX] Test the relocation of an NF add
test_regclass_not_updated_by_regalloc_2 only produced an NDD/NF add
with a GOT operand because the allocator happened to give the add a
destination different from its source. With SlotIndexes compaction it
picks the same register, so the add is compressed to the legacy form
and the CODE_6 TODO lost its test.
Add a function whose add keeps its source live, so it stays NDD and
becomes NF under any allocation.
[libc++][pstl] Add a serial implementation of std::unique_copy (#245603)
This PR adds a serial implementation of `std::unique_copy` to PSTL.
A real parallel implementation is intended to land within the `statpart`
backend later, which will be a purely additive change, it will not touch
the code in this PR.
Part of #99938.
[flang][debug] Name instance of a parameterized type after its kinds (#245692)
The instances of a parameterized derived type all took the name of the
type, so a debugger could not tell them apart. With `pdt(4)` and
`pdt(8)` used in the same procedure, `ptype pdt` in gdb showed whichever
instance it found first.
Name an instance after its kind values as gfortran does, `PDTpdt_4` for
`pdt(4)` (earlier gfortran spell the prefix `Pdt`). The prefix keeps an
instance from taking the name of a plain type such as `pdt_4`. gfortran
puts a negative value in the name with its minus sign, which a debugger
cannot look up, so spell it as the uniqued name does: `PDTpdt_N1` for
`pdt(-1)`.
Assisted by: Cursor
Co-authored-by: Cursor <cursoragent at cursor.com>
[libc++][pstl] Add a serial implementation of std::inplace_merge (#245218)
This PR adds a serial implementation of `std::inplace_merge` to PSTL.
Currently there's no intent to provide a parallel version of this
algorithm, but later it can be added as well.
Part of #99938.
[analyzer][NFC] Remove padding from MemRegion and SymExpr (#246313)
Cache the region offset without std::optional, using a null region for
"not computed", and make the SymExpr kind 8 bits so that the opcode of
UnarySymExpr and BinarySymExpr fits into its tail padding. This shrinks
MemRegion and its subclasses by 8 bytes, and on Itanium ABI targets also
UnarySymExpr and BinarySymExpr.
Assisted-by: Claude Opus 5.5
---------
Co-authored-by: Gabor Horvath <gaborh at apple.com>
[libc++] Speed-up the reduction by up to 4X by breaking the dependency chain (#234887)
This PR changes `std::reduce`/`std::transform_reduce()` to process 4
elements per iteration and perform reduction in a tree-like manner:
```
__init--------------\
(X) -> __init
__first[0]\ /
(X)\ /
__first[1]/ \ /
(X)/
__first[2]\ /
(X)/
__first[3]/
```
This optimisation applies only when random-access iterators to floating-point numbers are passed into `std::reduce`/`std::transform_reduce()`.
[NFC][MLIR][NVVM] Move enum definitions to NVVMEnums.td (#243880)
This NFC moves enums defined in `NVVMOps.td` to `NVVMEnums.td` to allow
for better organization and also for reuse in the NVGPU dialect.
This follows https://github.com/llvm/llvm-project/pull/195811/.
[libc++] Assume __is_{,nothrow_,trivially_}destructible builtins are available (#246195)
The `__is_destructible`, `__is_trivially_destructible` and
`__is_nothrow_destructible` builtins are available in all compilers we
support, so we can remove the now unused implementations. Since the
implementations are rather small now, this patch also merges the three
headers into `is_destructible.h`.
[libc++] Simplify the implementation of iterator_traits a bit (#222297)
This change does a few things:
- remove concepts which have only a single use
- use functions returning `type_identity`s instead of specializing a
class
- use `__detected_or_t`
All of these changes simplify the implementation a bit, resulting in
quite a bit less code.
[libc++abi] Make the dst_type uniqueness flag in dynamic_cast a bool (#243530)
`number_of_dst_type` is only ever 0 or 1. Capture that fact by making it
a bool.