[ConstantHoisting] Avoid DenseMap reference invalidated by insertion (#199468)
Fix https://reviews.llvm.org/D28962 : DenseMap does not promise to keep
references stable across insertion. This happens to work today because
we don't do bucket eviction.
Pre-populate every node up front.
[clang] implement CWG2064: ignore value dependence for decltype
The 'decltype' for a value-dependent (but non-type-dependent) should be known,
so this patch makes them non-opaque instead.
This patch also implements what's neceessary to allow overloading
on pure differences in instantiation dependence, making `std::void_t`
usable for SFINAE purposes.
This also readds a few test cases from da98651, which was a previous attempt
at resolving CWG2064.
Fixes #8740
Fixes #61818
Fixes #190388
[clang] NFC: add some new test cases (#199467)
These are extracted from my current and future PRs.
They don't have much to do with the PRs themselves except that they were
regressions our test suite missed catching.
[clang] NFC: add some new test cases
These are extracted from my current and future PRs.
They don't have much to do with the PRs themselves except that
they were regressions our test suite missed catching.
[libc++][test] Move backported algorithms to `libcxx/test/support` (#199431)
And namespace `util`. This will make helpers provided more consistently,
and potentially allow us to unify test helper namespaces in the future.
[LV] Handle chained selects/blends when creating new rdx chain. (#199443)
Make sure we recursively clone chains of selects/blends when re-creating
a reduction chain with new types.
Fixes https://github.com/llvm/llvm-project/issues/199406.
[NFC][AArch64][Cyclone] Model WriteSTP with a local SchedWriteRes (#198844)
Cyclone scheduling model uses SchedAlias between 2 SchedWriteRes
definitions from AArch64Schedule.td.
This prevents other scheduling models from aliasing WriteSTP. This patch
address the issue by defining a new CyWriteSTP and using that instead.
[VPlan] Simplify VPSCEVExpander, clarify naming/comments (NFC). (#199423)
Address post-commit comments from
https://github.com/llvm/llvm-project/pull/189455,
removing unneeded member, and clarify naming/comments to stress the
current logic tries to expand a SCEV to VPInstructions, with only a small
sub-set of SCEV expression supported.
[SLP] Ensure TreeCost is scaled for ordered fadd reductions (#199388)
Resolves #199267
Addresses an issue where `getScaleToLoopIterations()` can return 1 on
isolated SLP trees because `UserTreeIndex` is invalid. This prevents
`TreeCost` from scaling alongside `ReductionCost`, causing the cost
model to incorrectly treat an unprofitable vector reduction as
profitable.
This patch passes the reduction root instruction down into
`calculateTreeCostAndTrimNonProfitable` and the underlying scale
calculation so `getScaleToLoopIterations` can get the correct block
context.
[CodeGenPrepare] Report an error if ProfileSummaryAnalysis is not available (#199268)
CodeGenPreparePass can't declare ProfileSummaryAnalysis as required,
because PSA is a module-level analysis, but CFP is a function-level pass.
Therefore it accesses PSA using getCachedResult, and PSA might be null.
In practice this doesn't happen, because the CGP pass pipeline
preparation code ensures that PSA is present. But if you invoke
CGP via opt -passes=codegenprepare, then it's not
there, and we segfault.
Fix for https://github.com/llvm/llvm-project/issues/173360.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
[llvm,clang] Don't assume non-erased DenseMap entries remain valid after erase. NFC (#198982)
In preparation for switching DenseMap from tombstone deletion to
backward-shift deletion, update call sites that reuse an iterator or a
bucket reference after erasing another entry from the same map.
These work under tombstone deletion because unrelated buckets stay put,
but backward-shift deletion relocates entries to close the gap.
Add DenseMap::remove_if, similar to SmallPtrSet::remove_if, as
replacement for erase-while-iterating, and use it where applicable.
Aided by Claude Opus 4.7
[LifetimeSafety] Extend suggestions for `lifetimebound` to also warn on canonical declarations (#198784)
With this patch, we suggest adding the `clang::lifetimebound` attribute
on the canonical declaration and on the earliest redeclaration in each
other file, preserving diagnostics for declarations visible from other
translation units while avoiding duplicate suggestions within the same
file.
Fixes #198624
Fixes #198628
[X86][GISel] Fix carry-in for selectUAddSub. (#199261)
When G_UADDE/G_USUBE was chained off a previous G_UADDE/G_UADDO/
G_USUBE/G_USUBO, selectUAddSub re-materialized EFLAGS.CF from the
previous SETB byte using CMP r, 1. That computes (r - 1) and sets
CF iff r < 1 unsigned, i.e. CF = (r == 0) -- the inverse of the
desired carry. The following ADC/SBB then consumed the wrong CF and
produced an off-by-one upper word; e.g. `add i128 0xFF..FF, 1` under
-global-isel returned hi=0 lo=0 instead of hi=1 lo=0.
Emit NEG r instead: NEG sets CF iff its operand is non-zero, matching
the SETB byte. NEG is a two-address (tied) instruction, so emit it
into a fresh virtual register rather than redefining the carry-in
vreg.
C reproducer (compile on x86_64-linux-gnu and run):
```
// clang -O2 -fglobal-isel repro.c -o repro && ./repro
[32 lines not shown]
[SLP][NFC] Add precommit test for unprofitable ordered fadd reductions (#199428)
Adds a test case reproducing a scenario where the cost model incorrectly
evaluates an unprofitable ordered fadd reduction chain as profitable.
Further details can be found on this issue:
https://github.com/llvm/llvm-project/issues/199267