[libc++][ranges] P2542R8: Implement `views::concat` (#120920)
Closes #105419
Closes #105348
Closes #105349
Closes #171314
Assisted-by: Chatgpt.
I use AI to help me write some tests, however. I have reviewed the code
I submit in the tests.
---------
Co-authored-by: A. Jiang <de34 at live.cn>
Co-authored-by: Hristo Hristov <hghristov.rmm at gmail.com>
Co-authored-by: Hristo Hristov <zingam at outlook.com>
[IRBuilder] ConstFold unary intrinsics (#200496)
Extend TargetFolder and InstSimplifyFolder to fold unary intrinsics.
CreateUnaryIntrinsic now returns a Value, similar to
CreateBinaryIntrinsic, and this has necessitated more changes.
[VPlan] Factor vputils::getIntrinsicID (NFC) (#200174)
In preparation to get getOpcodeOrIntrinsicID used by CSE to handle calls
and to constant-fold intrinsic calls, factor out vputils::getIntrinsicID
from VPlanPatternMatch to re-use.
[clang-tidy] `use-ranges`: preserve used unique results
Preserve iterator uses when replacing std::unique with std::ranges::unique by appending .begin() in used-result contexts.
Fix #127658
Assisted by Codex.
[clang-tidy] `use-ranges`: avoid unsafe result fix-its
Preserve callable results with .fun, allow structured-binding-safe rewrites, and keep diagnostics while suppressing unsafe fix-its when ranges result objects do not match the original result shape.
Assisted by Codex.
[clang-tidy] `use-ranges`: preserve remove iterator results
Preserve used iterator results for remove, partition, stable_partition, and rotate-style replacements by appending .begin() where the ranges algorithm returns a subrange.
Fix #124794
Assisted by Codex.
[clang-tidy] `use-ranges`: preserve output results
Preserve used output iterator results for output algorithm replacements by appending .out where the ranges algorithm returns an algorithm result object.
Fix #110223
Assisted by Codex.
[X86] matchBinaryPermuteShuffle - match to X86ISD::SHLD funnel shift patterns (REAPPLIED) (#200604)
Add matchShuffleAsVSHLD helper to recognise shuffle masks that can fold
to funnel shifts
Reapplied with fix for shift amount not being appropriately scaled -
test case added at #200569
Fixes #145276
[DenseMap] Replace tombstone deletion with TAOCP 6.4 Algorithm R (#200595)
DenseMap uses quadratic probing with lazy deletion: an erased entry
becomes a tombstone, a third bucket state alongside empty and live that
every find/insert must inspect.
Switch to linear probing with backward-shift deletion (Knuth TAOCP 6.4
Algorithm R), similar to the SmallPtrSet change #197637. This removes
the tombstone state entirely.
In exchange, erase now relocates the following live entries to close the
hole, so it invalidates iterators and references other than the erased
one. For callers that cache pointers into the bucket array,
erase(Key, OnMoved) and erase(iterator, OnMoved) fire a callback once
per
shifted bucket, so fix-ups cost O(cluster) rather than O(NumEntries).
ValueHandleBase::RemoveFromUseList uses this to refresh each moved
handle's PrevPtr.
[17 lines not shown]
[LowerInvoke] Use createCallMatchingInvoke instead of rolling it ourselves (#200536)
Using createCallMatchingInvoke ensures we copy metadata from the invoke
onto the call.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
[IR] SubclassOptionalData is only optional for Instruction (#200419)
BasicBlock currently uses this for HasAddressTaken. ConstantExpr uses
this for flags and it should not be possible to modify constant
expressions after they have been created.
Therefore, update the documentation accordingly and remove the unsafe
clearSubclassOptionalData.
Remove hasSameSubclassOptionalData, as it is unused.
[libc][ci] Clean up libc-fullbuild-tests precommit CI. (#200520)
- Pin containers.
- Cleaner names for different targets and options.
- Add Build Test step.
- Skip shared tests and death tests.
[IR] Fix PoisoningVH relocation of a poisoned handle (#200540)
In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, when poisoned (`deleted()` or
`allUsesReplacedWith()`), a PoisoningVH is removed from its use list but
keeps its raw value pointer for identity, so its PrevPtr/Next are left
stale.
PoisoningVH has no move constructor, so relocating a value that embeds
one
falls back to the copy constructor, where `setRawValPtr` relinks with
the stale pointers and corrupts the use list.
This is a latent bug for any relocation of a PoisoningVH handle
but becomes load-bearing for #199615 , which relocating erase exercises
it via ScalarEvolution's BackedgeTakenInfo (its ExitNotTakenInfo holds a
PoisoningVH<BasicBlock>).
Fix by special casing the `Poisoned` case.
Aided By Claude Opus 4.8
[IR][NFC] Inline Type::isIntegerTy(n) (#200471)
Although this gets inlined in LTO builds, non-LTO builds benefit from
having isIntegerTy(n) defined in a header.
Co-authored-by: Nikita Popov <npopov at redhat.com>
[libc] Tag cpp::byte with gnu::may_alias (#200462)
Clang's TBAA grants the [basic.lval]/11.3 char-aliasing privilege only
to the named ::std::byte type (Type::isStdByteType() requires the enum
to be declared in the std namespace). LIBC_NAMESPACE::cpp::byte lives in
libc's cpp namespace, so it gets its own TBAA node disjoint from char
even though it has the same shape as std::byte.
That mismatch lets the optimizer reorder typed loads past raw-byte
writes through cpp::byte *, miscompiling HeapSort on rv64/Release
(UnsortedThreeElementArray{1,2,3}, UnsortedTwoElementArray1 in
SortingTest.h). The same hazard is latent in every cpp::byte *-based
raw-aliasing site: memory_utils Ptr/CPtr, lsearch/lfind, block.h and
freelist_heap.h allocator metadata.
Tag the type with gnu::may_alias so accesses through cpp::byte * share
the universal char-aliasing TBAA node, fixing all of the above in one
place. This patch also reverts PR #194171, as the may_alias attribute
fixes it too.
[mlir][nfc] Fix assertion text in IndexingUtils (#181826)
Update the assertion text to match the actual code behavior.
Some functions enforce strictly positive values, whereas the error
message incorrectly mentioned "nonnegative".
[CIR][OpenCL] Lower kernel argument metadata to LLVM IR
Translate CIR OpenCL kernel argument metadata into the LLVM IR kernel_arg_* metadata attached to kernel functions. Preserve optional argument names so -cl-kernel-arg-info controls the LLVM metadata surface through the CIR attribute.
[CIR][OpenCL] Attach kernel argument metadata to CIR functions
Emit the CIR OpenCL kernel argument metadata attribute for kernel functions. Preserve CIR language address-space kinds until lowering and include argument names only when `-cl-kernel-arg-info` is enabled.
Depends on #199530.
[VPlan] Thread scalar type through VPBlend, VPExpression recipes. (NFC) (#200255)
Set the scalar type for VPBlendRecipe and VPExpressionRecipe at
construction time, instead of inferring it on demand via VPTypeAnalysis.
With this change, all VPValues have their scalar type set at
construction, so VPTypeAnalysis::inferScalarType becomes a thin wrapper
around VPValue::getScalarType.
To be removed in a follow-up:
https://github.com/llvm/llvm-project/pull/200256.
PR: https://github.com/llvm/llvm-project/pull/200255