LLVM/project b37a8a7llvm/lib/Transforms/Vectorize SLPVectorizer.cpp, llvm/test/Transforms/SLPVectorizer/X86 perfect-diamond-match-poison-reuse.ll

[SLP]Fix perfect diamond match for gather nodes with poison in the reuse mask

A poison constant in the gathered bundle leaves a poison lane in the
common mask; expanding the gather through that mask indexed the scalar
list with -1. Expand such lanes to poison instead.

Fixes #219833

Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/219862
DeltaFile
+74-0llvm/test/Transforms/SLPVectorizer/X86/perfect-diamond-match-poison-reuse.ll
+4-2llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+78-22 files

LLVM/project 3700e7cllvm/lib/ExecutionEngine/JITLink CompactUnwindSupport.h, llvm/test/ExecutionEngine/Orc throw-catch-merged-compact-unwind.ll

[ORC] Fix malformed Mach-O `__unwind_info` tables (#217781)

The malformed tables are produced by `JITLink` after compact-unwind
record merging.

`CompactUnwindManager::mergeRecords()` coalesces adjacent function
records with identical mergeable encodings. When the final raw record is
merged away, `writeIndexes()` generates the top-level index terminator
from the final remaining record instead of the final original function.
This truncates the final index range.

On macOS arm64, libunwind resolves a PC in the merged-away final
function through the terminator entry. Its second-level-page offset is
zero by design, causing libunwind to interpret the `__unwind_info`
header as a second-level page and report:

```
libunwind: malformed __unwind_info ... bad second level page
```

    [20 lines not shown]
DeltaFile
+59-0llvm/test/ExecutionEngine/Orc/throw-catch-merged-compact-unwind.ll
+5-2llvm/lib/ExecutionEngine/JITLink/CompactUnwindSupport.h
+64-22 files

LLVM/project 00d7adallvm/test/CodeGen/RISCV/rvv fixed-vectors-uitofp-vp-mask.ll fixed-vectors-sitofp-vp-mask.ll

[RISCV] Lower vector i1-to-fp i1 to VSELECT 1.0/0.0 (#219426)

Previously, the i1 source was first extended to an integer type
whose width is half the destination floating-point width. The mask
extension was lowered by lowerVectorMaskExt to a VSELECT, or directly to
VMERGE_VL for fixed-length vectors, materializing an integer vector
containing 0 or 1.

Since an unsigned i1-to-floating-point conversion can only produce 0.0
or 1.0, recognize this operation earlier and lower it directly to a
VSELECT between the floating-point constants 1.0 and 0.0. This removes
the intermediate integer mask extension and the following widening
integer-to-floating-point conversion.
DeltaFile
+412-316llvm/test/CodeGen/RISCV/rvv/vitofp-sdnode.ll
+160-88llvm/test/CodeGen/RISCV/rvv/fixed-vectors-i2fp.ll
+62-38llvm/test/CodeGen/RISCV/rvv/vuitofp-vp-mask.ll
+62-38llvm/test/CodeGen/RISCV/rvv/vsitofp-vp-mask.ll
+50-28llvm/test/CodeGen/RISCV/rvv/fixed-vectors-uitofp-vp-mask.ll
+50-28llvm/test/CodeGen/RISCV/rvv/fixed-vectors-sitofp-vp-mask.ll
+796-5361 files not shown
+808-5367 files

LLVM/project aba761cclang/test/Analysis/Scalable/source-edit-generation end-to-end-cpp-bounded-buffers.cpp

address comments
DeltaFile
+5-5clang/test/Analysis/Scalable/source-edit-generation/end-to-end-cpp-bounded-buffers.cpp
+5-51 files

LLVM/project 6073845clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations CppBoundedBuffers.cpp, clang/test/Analysis/Scalable/source-edit-generation end-to-end-cpp-bounded-buffers.cpp

[SSAF][clang-reforge] Add end-to-end clang-reforge tests

- Make CppBoundedBuffers adapt to flattened WPA results;
- Let CppBoundedBuffers use qualified EntityNames so that it can
  associate ASTNodes with WPA results;
- Add end-to-end tests

Final step of:
rdar://185840466
DeltaFile
+623-0clang/test/Analysis/Scalable/source-edit-generation/end-to-end-cpp-bounded-buffers.cpp
+23-9clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
+22-4clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp
+668-133 files

LLVM/project dd63ca6clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations CppBoundedBuffers.cpp, clang/unittests/ScalableStaticAnalysis/SourceTransformation CppBoundedBuffersTest.cpp

fix clang-format
DeltaFile
+4-2clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
+1-1clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp
+5-32 files

LLVM/project dac951dclang/include/clang/ScalableStaticAnalysis/Analyses/UnsafeBufferUsage UnsafeBufferUsageAnalysis.h, clang/lib/ScalableStaticAnalysis/Analyses/UnsafeBufferUsage UnsafeBufferUsageAnalysis.cpp

[SSAF] Flatten 'UnsafeBufferReachableAnalysisResult' to a plain set (#219041)

Previously, an 'UnsafeBufferReachableAnalysisResult' was organized as a
map from contributors to their mutually exclusive sub-results. Because
this extra layer of contributor information proved unnecessary, this
commit flattens the result into a plain set.

The source transformation expects the result to be a plain set, so this
is a prerequisite step for
rdar://185840466
DeltaFile
+8-13clang/unittests/ScalableStaticAnalysis/WholeProgramAnalysis/UnsafeBufferReachableAnalysisTest.cpp
+10-10clang/lib/ScalableStaticAnalysis/Analyses/UnsafeBufferUsage/UnsafeBufferUsageAnalysis.cpp
+5-11clang/test/Analysis/Scalable/TypeConstrainedPointers/unsafe-buffer-reachable-excludes-type-constrained-new-delete.cpp
+4-6clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
+1-3clang/unittests/ScalableStaticAnalysis/SourceTransformation/CppBoundedBuffersTest.cpp
+2-1clang/include/clang/ScalableStaticAnalysis/Analyses/UnsafeBufferUsage/UnsafeBufferUsageAnalysis.h
+30-441 files not shown
+30-477 files

LLVM/project e8abf10llvm/include/llvm/ADT StringMap.h, llvm/unittests/ADT StringMapTest.cpp

[ADT] Use isComparableWith in StringMap (#219853)

This patch updates operator== in StringMap to use
DebugEpochBase::HandleBase::isComparableWith, bringing it in line
with DenseMap and FoldingSet.

Assisted-by: Antigravity
DeltaFile
+18-0llvm/unittests/ADT/StringMapTest.cpp
+1-4llvm/include/llvm/ADT/StringMap.h
+19-42 files

LLVM/project 6732c0fmlir/include/mlir/Analysis FlatLinearValueConstraints.h, mlir/lib/Analysis FlatLinearValueConstraints.cpp

[mlir][affine] Update getSliceBounds to allow multi-result upper bound maps (#219369)

Resolve a long-standing TODO on supporting multi-result upper bound maps
on affine analysis utility getSliceBounds. This makes affine fusion more
powerful.

`getSliceBounds` threw away any upper bound that came out of more than
one inequality and put the constant bound in its place, under a TODO
saying it was conservative until `getConstDifference` in LoopFusion
could handle multiple bounds (b/126426796). Several inequalities is what
a destination loop clamped at the end of the data produces -- of a 1000
long dim tiled by 64, the region a tile reads is bounded by `min(%i * 64
+ 64, 1000)` -- and dropping that for the constant leaves `1000`, which
says only that the slice ends somewhere before the end of the data. A
slice of one 64-wide tile then costs as a slice of everything from the
tile onwards, and fusion refuses it as redundant computation that isn't
there.

Keep such a bound. It is already the min of its results, which is the

    [12 lines not shown]
DeltaFile
+30-14mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+29-0mlir/test/Dialect/Affine/loop-fusion-slice-computation.mlir
+11-6mlir/lib/Analysis/FlatLinearValueConstraints.cpp
+9-5mlir/include/mlir/Analysis/FlatLinearValueConstraints.h
+79-254 files

LLVM/project 6c657acllvm/include/llvm/ADT FoldingSet.h, llvm/lib/Support FoldingSet.cpp

[ADT] Inline FoldingSetNodeID equality. NFC (#219856)

Every successful FoldingSet lookup pays the cost to call out-of-line
function, which calls memcmp. Just inline it.
DeltaFile
+0-14llvm/lib/Support/FoldingSet.cpp
+11-3llvm/include/llvm/ADT/FoldingSet.h
+11-172 files

LLVM/project cad4973clang/unittests/ScalableStaticAnalysis/WholeProgramAnalysis UnsafeBufferReachableAnalysisTest.cpp

fix merge conflict
DeltaFile
+7-9clang/unittests/ScalableStaticAnalysis/WholeProgramAnalysis/UnsafeBufferReachableAnalysisTest.cpp
+7-91 files

LLVM/project f7a4452llvm/lib/Support KnownFPClass.cpp, llvm/test/Transforms/Attributor nofpclass-bitcast.ll nofpclass-bitcast-fp-to-fp.ll

[KnownFPClass] Refine known classes for `KnownFPClass::bitcast` (#215708)

`KnownFPClass::bitcast` should now be optimal (for ieee and bf16 types).
It is now able to correctly determine the `KnownFPClass` of any constant
value*. For non-constants, it is now able to rule out normal, and
subnormal results, in addition to ruling out specifically `qNaN`/`sNaN`
based off of the quiet bit.

I also added unit tests for `KnownFPClass::bitcast`.

AI Disclosure:
I used ChatGPT Codex (sol 5.6) to help generate the tests, which I
reviewed, built, and tested locally.

*Prior to this commit `KnownFPClass::bitcast` was unable to fully deduce
constants such as positive infinity:
```
/home/zerico/programming/llvm-project/llvm/unittests/Support/KnownFPClassTest.cpp:46: Failure
Expected equality of these values:

    [6 lines not shown]
DeltaFile
+461-0llvm/test/Transforms/Attributor/nofpclass-bitcast-int-to-fp.ll
+0-266llvm/test/Transforms/Attributor/nofpclass.ll
+0-229llvm/test/Transforms/Attributor/nofpclass-bitcast.ll
+229-0llvm/test/Transforms/Attributor/nofpclass-bitcast-fp-to-fp.ll
+130-0llvm/unittests/Support/KnownFPClassTest.cpp
+45-33llvm/lib/Support/KnownFPClass.cpp
+865-5281 files not shown
+866-5287 files

LLVM/project 98e549bllvm/lib/Support KnownFPClass.cpp, llvm/test/Transforms/Attributor nofpclass-powi.ll

[KnownFPClass] Refine powi KnownFPClass deductions (#218581)

Adds deductions for when the `base` is known never negative-normal nor
negative-subnormal. Similar to the deductions added for `pow`
https://github.com/llvm/llvm-project/pull/215592.


AI Disclosure:
I used ChatGPT Codex (Sol-5.6) to help write tests, which I reviewed and
tested locally.
DeltaFile
+256-54llvm/test/Transforms/Attributor/nofpclass-powi.ll
+72-0llvm/test/Transforms/InstCombine/simplify-demanded-fpclass-powi.ll
+32-16llvm/lib/Support/KnownFPClass.cpp
+7-5llvm/unittests/Analysis/ValueTrackingTest.cpp
+367-754 files

LLVM/project fb8ea2bclang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations CppBoundedBuffers.cpp

fix clang-format
DeltaFile
+2-1clang/lib/ScalableStaticAnalysis/SourceTransformation/Transformations/CppBoundedBuffers.cpp
+2-11 files

LLVM/project afdcd7fllvm/include/llvm/ADT FoldingSet.h, llvm/lib/Support FoldingSet.cpp

[ADT] Remove FoldingSet's void * insert position API (#219845)

FindNodeOrInsertPos/InsertNode/GetOrInsertNode/RemoveNode and the
encode/decode helpers behind them are gone; use
lookup/insert/getOrInsert/erase with FoldingSetInsertToken.

LLM-aided
DeltaFile
+62-62llvm/unittests/ADT/FoldingSet.cpp
+0-32llvm/include/llvm/ADT/FoldingSet.h
+0-4llvm/lib/Support/FoldingSet.cpp
+62-983 files

LLVM/project 7694751llvm/include/llvm/ExecutionEngine/Orc LookupAndApply.h, llvm/lib/ExecutionEngine/Orc LookupAndApply.cpp

[ORC] Drop redundant ExecutionSession& arg from lookupAndApply (#219797)

The ExecutionSession& can be retrieved from the first element of the
SearchOrder.

This changes behavior in a corner case: An empty SearchOrder always
fails on a non-empty PrepareFns list, even if all symbols added would
have been weakly referenced, because no ExecutionSession& is available
to intern the symbol names. An empty SearchOrder is pathological, so
this seems like a reasonable trade-off.
DeltaFile
+21-9llvm/lib/ExecutionEngine/Orc/LookupAndApply.cpp
+22-0llvm/unittests/ExecutionEngine/Orc/LookupAndApplyTest.cpp
+7-2llvm/include/llvm/ExecutionEngine/Orc/LookupAndApply.h
+50-113 files

LLVM/project 0538497llvm/lib/CodeGen RegAllocFast.cpp

[RegAllocFast] Use getOneDef() in traceCopyChain(). NFC (#219850)

getUniqueVRegDef() finds one defining instruction, while getOneDef()
finds one def operand and is inlined.
(They differ for a register defined twice by one instruction but
RegAllocFast does not support that shape in defineVirtReg().)
DeltaFile
+8-6llvm/lib/CodeGen/RegAllocFast.cpp
+8-61 files

LLVM/project e016329llvm/lib/Transforms/Vectorize VPlanTransforms.cpp VPlanPatternMatch.h, llvm/test/Transforms/LoopVectorize scalarized-bitcast.ll

[VPlan] Fold trivial bitcasts. (#219849)

Fold trivial bitcasts in VPlan. This avoids special handling when
constructing SCEV expressions (which folds such trivial casts), and
ensures we can close the gap between IR-based SCEV analysis and
VPlan-based SCEV analysis. This is important going forward to make sure
we can replace existing IR analysis without regressions.
DeltaFile
+6-6llvm/test/Transforms/LoopVectorize/VPlan/vplan-scev-address-idioms.ll
+3-3llvm/test/Transforms/LoopVectorize/scalarized-bitcast.ll
+6-0llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+6-0llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
+1-1llvm/test/Transforms/LoopVectorize/SystemZ/load-scalarization-cost-0.ll
+22-105 files

LLVM/project 152edef.github/workflows libc-overlay-tests.yml

[libc][Github] Use explicit names for libc overlay tests (#219783)
DeltaFile
+11-6.github/workflows/libc-overlay-tests.yml
+11-61 files

LLVM/project 49b1085llvm/lib/CodeGen PeepholeOptimizer.cpp

CodeGen: Use getOneNonDBGUser in PeepholeOptimizer (#219526)
DeltaFile
+2-2llvm/lib/CodeGen/PeepholeOptimizer.cpp
+2-21 files

LLVM/project c8c0197llvm/lib/Target/AArch64 AArch64MCInstLower.cpp

AArch64: Use AsmPrinter's MachineFunction in lowerSymbolOperandELF (#219475)
DeltaFile
+3-3llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+3-31 files

LLVM/project be9007bclang/include/clang/AST DeclTemplate.h, clang/lib/AST ASTImporter.cpp DeclTemplate.cpp

[clang] Migrate remaining FoldingSet users to lookup/insert. NFC (#219844)

findSpecialization/AddSpecialization and their Decl.h wrappers stop
threading a `void *` through the AST, Sema, Serialization and CodeGen
callers. This is the last user of FoldingSet's `void *` insert position.

LLM-aided
DeltaFile
+54-50clang/lib/AST/DeclTemplate.cpp
+29-28clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+29-20clang/include/clang/AST/DeclTemplate.h
+19-20clang/lib/AST/ASTImporter.cpp
+18-20clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+19-19clang/lib/Sema/SemaTemplate.cpp
+168-15727 files not shown
+282-27233 files

LLVM/project b45b02allvm/lib/Transforms/Vectorize VPlanUnroll.cpp, llvm/test/Transforms/LoopVectorize float-induction.ll

[VPlan] Fix VPScalarIVStepsRecipe for FSub inductions. (#219214)

The lane offsets passed to the new VPScalarIVStepsRecipe always count
upwards (based on the canonical IV), independent of the induction
opcode.

Remove code incorrectly negating the lane offset for inductions with
FPSub opcode. The double negation caused incorrect results.

PR: https://github.com/llvm/llvm-project/pull/219214
DeltaFile
+10-10llvm/test/Transforms/LoopVectorize/float-induction.ll
+4-5llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
+14-152 files

LLVM/project a95b4d1llvm/include/llvm/Analysis ScalarEvolution.h, llvm/unittests/Analysis ScalarEvolutionTest.cpp

[SCEV] Use SCEVUse for FoldID. (#219813)

As pointed out in https://github.com/llvm/llvm-project/pull/216761,
FoldID was not properly migrated to use SCEVUse. This caused incorrect
lookups, when an expression was cached with an operand with SCEVUse
flags and queried for the same expression without flags.

PR: https://github.com/llvm/llvm-project/pull/219813
DeltaFile
+44-0llvm/unittests/Analysis/ScalarEvolutionTest.cpp
+6-5llvm/include/llvm/Analysis/ScalarEvolution.h
+50-52 files

LLVM/project 9946f44clang/lib/Driver/ToolChains Cygwin.h Cygwin.cpp, clang/test/Driver cygwin.cpp

[Clang][Driver] Revise Cygwin ToolChain to call linker directly (#147960)

...so that `libc++`, `compiler-rt`, and `libunwind` can be used by the
options: `-stdlib=libc++`, `-rtlib=compiler-rt`, and
`-unwindlib=libunwind` respectively. Along with this change, the test
for this driver is also trimmed a bit.

This is a followup patch for
https://github.com/llvm/llvm-project/commit/52924a2d7255cdd280b2b82dad8616e01fe065da.

---------

Signed-off-by: Takashi Yano <takashi.yano at nifty.ne.jp>
Co-authored-by: Jeremy Drake <github at jdrake.com>
Co-authored-by: Tomohiro Kashiwada <kikairoya at gmail.com>
DeltaFile
+275-0clang/lib/Driver/ToolChains/Cygwin.cpp
+112-12clang/test/Driver/cygwin.cpp
+18-0clang/lib/Driver/ToolChains/Cygwin.h
+0-0clang/test/Driver/Inputs/basic_cygwin_tree/usr/lib/gcc/i686-pc-cygwin/10/crtend.o
+0-0clang/test/Driver/Inputs/basic_cross_cygwin_tree/usr/i686-pc-msys/lib/crt0.o
+0-0clang/test/Driver/Inputs/basic_cygwin_tree/usr/lib/gcc/x86_64-pc-msys/10/crtend.o
+405-125 files not shown
+405-1211 files

LLVM/project f9d53b2llvm/test/Transforms/LoopVectorize/VPlan vplan-scev-address-idioms.ll

[VPlan] Add tests for more address idioms not by VPlan's SCEV (NFC). (#219843)

Add tests gaps currently handled by IR based SCEV analysis, but not
VPlan-based SCEV analysis.
DeltaFile
+975-0llvm/test/Transforms/LoopVectorize/VPlan/vplan-scev-address-idioms.ll
+975-01 files

LLVM/project 5c9c1f5llvm/include/llvm/ADT FoldingSet.h, llvm/lib/Support FoldingSet.cpp

[ADT] Inline FoldingSet's equality dispatch (#219784)

FoldingSetBase compares nodes through a FoldingSetInfo table of function
pointers, which the compiler cannot inline through to the node's
Profile().
Add a probe() template taking the match test as a template parameter,
and build lookup, FindNodeOrInsertPos and getOrInsert on it in
FoldingSetImpl where the trait is known.

LLM-aided
DeltaFile
+60-64llvm/include/llvm/ADT/FoldingSet.h
+1-54llvm/lib/Support/FoldingSet.cpp
+61-1182 files

LLVM/project a6e5d88llvm/lib/Analysis ValueTracking.cpp, llvm/test/Transforms/InstCombine stepvector-known-bits.ll

[ValueTracking] Compute known bits for llvm.stepvector (#219779)

Teach ValueTracking to infer high zero bits for `llvm.stepvector` from
the
vector element count and a finite `vscale_range`.

Conservatively give up when the lane-count calculation overflows the
element
width, since `llvm.stepvector` truncates out-of-range lane indices.

This allows existing sign-bit reasoning to eliminate redundant
extensions for
bounded step vectors.

The regression tests cover scalable and fixed vectors, bounded and
unbounded
`vscale_range`, lane-index truncation, unconstrained inputs, and
signed-i32
boundary cases.

Fixes #219776.
DeltaFile
+117-0llvm/test/Transforms/InstCombine/stepvector-known-bits.ll
+24-0llvm/lib/Analysis/ValueTracking.cpp
+141-02 files

LLVM/project 8e32376clang/include/clang/AST ASTContext.h, clang/lib/AST NestedNameSpecifier.cpp DeclarationName.cpp

[clang] Migrate AST/Sema FoldingSet users to typed lookup/insert. NFC (#219766)
DeltaFile
+246-287clang/lib/AST/ASTContext.cpp
+15-16clang/lib/AST/DeclarationName.cpp
+4-6clang/lib/Sema/SemaConcept.cpp
+3-3clang/lib/Sema/SemaLookup.cpp
+3-3clang/lib/AST/NestedNameSpecifier.cpp
+1-1clang/include/clang/AST/ASTContext.h
+272-3166 files

LLVM/project 868246fllvm/lib/Transforms/InstCombine InstCombineAndOrXor.cpp, llvm/test/Transforms/InstCombine fsh.ll

[InstCombine] Recognize rotate patterns with `X + 1` shift counts as funnel shifts (#214035)

fix #173132

godbolt: https://llvm.godbo.lt/z/WE6Woxqj4
alive2: https://alive2.llvm.org/ce/z/SYa7uG
https://alive2.llvm.org/ce/z/Y6HqoV
DeltaFile
+219-0llvm/test/Transforms/InstCombine/fsh.ll
+11-0llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+230-02 files