[LifetimeSafety][NFC] Do not store empty loan sets (#246460)
An origin missing from the loan propagation lattice has no loans, so
remove it instead of storing an empty set when it is killed, expires or
receives no loans from a flow. This keeps the maps smaller.
On the lifetime safety benchmarks this reduces the peak memory by 8% for
the CFG merge test and 3% for the switch fan-out test, with no change in
instructions for the others.
Assisted-by: Claude Opus 5.5
---------
Co-authored-by: Gabor Horvath <gaborh at apple.com>
[BuildLibCalls] Do not mark ctermid argument as nocapture (#241813)
Remove setDoesNotCapture flag from ctermid.
char* ctermid(char* s), according to POSIX spec returns either address
of static buffer, or its argument if non-NULL, which counts as capture.
This was detected with RTEMS tests, clang incorrectly optimized out
input to ctermid assuming nocapture.
[SandboxVec][LoadStoreVec] Factor out canUnpack and unpackIfNeeded (NFC) (#245732)
This moves the logic that unpacks each original load from the lanes it
occupies in a vector load, and the check that those lanes can be
reinterpreted as the load's type, out of `vectorizeLoads()` into two new
helpers, `canUnpack()` and `unpackIfNeeded()`.
Co-authored-by: Cursor <cursoragent at cursor.com>
[analyzer][NFC] Skip RetainSummaryManager's OSObject and ISL checks when they cannot match (#246458)
For every call it summarizes, RetainSummaryManager runs AST matchers to
check whether a record derives from OSMetaClassBase, and prints
parameter types to check for an "isl_" prefix. Neither can match if no
identifier in the translation unit is named OSMetaClassBase or starts
with "isl_", which is the case for most translation units, so skip them
then.
On some LLVM TUs (GVN, LiveVariables, RegionStore, SemaExpr) this
reduces the instructions of the static analyzer by 1.5-2.4%.
Assisted-by: Claude Opus 5.5
---------
Co-authored-by: Gabor Horvath <gaborh at apple.com>
[X86] matchBinaryShuffle - don't fold BLEND(X,Y) --> OR(X,Y) if any demanded elts may contain poison/undef (#246461)
Similar to #245048, KnownBits analysis doesn't guarantee that a value
isn't UNDEF/POISON, so after MaskedVectorIsZero we need to confirm with
isGuaranteedNotToBeUndefOrPoison
Fixes #246348
[llvm-cov] Look up expansion regions by FileID with binary search
Region vectors are already sorted by FileID, so filtering for one file
is just selecting a contiguous subrange. Do that with a binary search
instead of scanning the whole function.
[AMDGPU] Defer S_WAITCNT_DEPCTR erasure and updates in expert mode
A pre-existing S_WAITCNT_DEPCTR was erased, or had its VA_VDST and
VM_VSRC fields relaxed, as soon as the incoming state made those waits
look redundant. In a loop header that happens on the first visit, before
the backedge adds the instructions of the loop body. The wait is then
lost when the header is visited again with them pending.
Keep the original operand of every S_WAITCNT_DEPCTR, including
duplicates, while iterating to the fixed point, and only apply the final
encoding or erase the instruction at the end of the pass.
Also reset the VA_VDST field of a duplicate S_WAITCNT_DEPCTR to "no
wait" once its wait has been folded into the first one, instead of
leaving a redundant copy of the combined wait behind.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU] Pre-commit test for S_WAITCNT_DEPCTR in loop headers (NFC) (#246305)
Add baseline coverage for loop-header S_WAITCNT_DEPCTR handling in
expert scheduling mode. This test will make the effects of the fix in
https://github.com/llvm/llvm-project/pull/246081 visible.
Tested with the existing pass on gfx12 and gfx1250.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[PowerPC][test] Fix mismatched copy-like operand sizes in MIR fixtures (#238350)
Fixing some register size mismatches on COPY instructions.
Came up with: https://github.com/llvm/llvm-project/pull/234959
[offload][debug] Add REPORT_WARN and REPORT_FATAL macros
Add two new macros in the same style as REPORT(). REPORT_WARN prints a warning,
while REPORT_FATAL prints a fatal error and aborts the program.
Assisted-by: Claude Sonnet 5.5
[PowerPC] Enable SlotIndexes compaction by default
Greedy measures live ranges in slot indexes, and instructions erased
before allocation (by PHI elimination, two-address lowering and the
coalescer) leave entries behind that make ranges look longer than
they are. Opt PowerPC in to dropping them, as AMDGPU and ARM do, so
allocation works with real distances. Passing
-greedy-compact-slot-indexes=false restores the old behaviour.
On CTMark (pwr8, pwr10, AIX, ppc32), .text and llc compile time move
by less than 0.03% and evictions drop by 1.5-5.8%.
The test updates are register allocation changes; csr-split.ll gets
back the live range split it was written to check.
[RISCV] Fix misaligned RVV stack objects
RVV stack objects were laid out from the top of the RVV area and then
shifted down by the area's alignment padding, so only the lowest
object was guaranteed its alignment. An over-aligned object above it
could end up at a misaligned address.
Lay the objects out from the end of the area that the base register
points at, most aligned first, and put the padding at the other end.
Each object is then at a multiple of its alignment from an aligned
base for any VLEN.
Fixes #246451
[RISCV] Precommit RVV stack alignment test (NFC)
Show the current frame layout when a more aligned scalable-vector
stack object has a lower frame index than a less aligned one. The
more aligned object is placed at an address that is not a multiple
of its alignment.
Precommit for #246451
[AArch64] Implement ACLE intrinsics for FPv2 SVE min/max instructions
ACLE PR: https://github.com/ARM-software/acle/pull/480
Implements the following intrinsics:
- svmaxmg / svminmg
- svmaxinm / svmininm
- svmaxmginm / svminmginm
Includes f16, f32, and f64 types, _m, _z, and _x predication and _n variants
AI assistance: Codex used for generating test cases
[AMDGPU] Defer S_WAITCNT_DEPCTR erasure and updates in expert mode
A pre-existing S_WAITCNT_DEPCTR was erased, or had its VA_VDST and
VM_VSRC fields relaxed, as soon as the incoming state made those waits
look redundant. In a loop header that happens on the first visit, before
the backedge adds the instructions of the loop body. The wait is then
lost when the header is visited again with them pending.
Keep the original operand of every S_WAITCNT_DEPCTR, including
duplicates, while iterating to the fixed point, and only apply the final
encoding or erase the instruction at the end of the pass.
Also reset the VA_VDST field of a duplicate S_WAITCNT_DEPCTR to "no
wait" once its wait has been folded into the first one, instead of
leaving a redundant copy of the combined wait behind.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[InstCombine] Drop poison-generating annotations from call in select-of-zero fold (#245874)
Fixes #245656.
`foldSelectZeroOrFixedOp` folds `select (x == 0), 0, op(x, y)` into
`op(x, freeze(y))`, which evaluates `op` unconditionally. If `op` is a
call (`umin`, `fshl`, `fshr`) with a `range` attribute that excludes
`0`, e.g. `range(i64 1, 0)` on the return value or an argument, the call
now returns a value outside its declared range at `x == 0`. The result
is poison where the original select produced `0`.
Drop the poison-generating annotations on call instructions. Non-call
ops (`mul`, `idiv`, etc.) keep their `nuw`/`nsw`/`exact` flags, since at
`x == 0`, `0 * y` cannot overflow and `0 sdiv/udiv y` stays exact.
Alive2 proofs:
- Return range dropped: https://alive2.llvm.org/ce/z/ZhgWuj
- Arg 0 range dropped: https://alive2.llvm.org/ce/z/dAKtZF
- Arg 1 range dropped: https://alive2.llvm.org/ce/z/D5URrH
[2 lines not shown]
[Mips] Fix the HI/LO hazard check on MIPS I to MIPS IV (#245689)
MIPS I to MIPS IV need two instructions between an mflo or mfhi and the
next instruction that writes HI or LO. handleMFLO() only knew about
mult, div and divu, so multu, dmultu, mthi and mtlo were missed, and
mflo followed by multu, as in a 64-bit multiply on O32, got no nops. It
also did not look at the instruction in a delay slot, so a div that the
delay slot filler placed in the delay slot of a branch right after an
mflo was missed as well.
Check the registers an instruction writes instead of a list of opcodes,
and look at the next two instructions that can execute after each mflo
or mfhi, including the instruction in a delay slot and the first
instructions of every successor block. Add the nops right before the
instruction that writes HI or LO when it is in the same block, or else
right after the mflo, or at the start of the successors when the mflo is
in a delay slot.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MemoryBuiltins] Remove more TLI support (#246418)
Remove TLI argument from getAllocAlignment() and
getInitialValueOfAllocation() and rely exclusively on
`allocalign`/`allockind` instead.
[AArch64] Implement ACLE intrinsics for FPv2 SVE min/max instructions
ACLE PR: https://github.com/ARM-software/acle/pull/480
Implements the following intrinsics:
- svmaxmg / svminmg
- svmaxinm / svmininm
- svmaxmginm / svminmginm
Includes f16, f32, and f64 types, _m, _z, and _x predication and _n variants
AI assistance: Codex used for generating test cases
[AMDGPU] Defer S_WAITCNT_DEPCTR erasure and updates in expert mode
A pre-existing S_WAITCNT_DEPCTR was erased, or had its VA_VDST and
VM_VSRC fields relaxed, as soon as the incoming state made those waits
look redundant. In a loop header that happens on the first visit, before
the backedge adds the instructions of the loop body. The wait is then
lost when the header is visited again with them pending.
Keep the original operand of every S_WAITCNT_DEPCTR, including
duplicates, while iterating to the fixed point, and only apply the final
encoding or erase the instruction at the end of the pass.
Also reset the VA_VDST field of a duplicate S_WAITCNT_DEPCTR to "no
wait" once its wait has been folded into the first one, instead of
leaving a redundant copy of the combined wait behind.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>