LLVM/project 5104dadclang/lib/Analysis CFG.cpp, clang/test/Analysis cfg-compound-assignment-eval-order.cpp loopexit-cfg-output.cpp

[clang][CFG] Fix compound assignment evaluation order (#212115)

CompoundAssignOperator (e.g. `+=`, `-=`, `<<=`) is a distinct StmtClass
deriving from BinaryOperator, but it was not handled in the CFGBuilder
dispatch switches. As a result it fell through to the generic default
path (VisitChildren over reverse_children), which emits the LHS before
the RHS in the CFG.

Per C++17 [expr.ass]/1, all assignment operators - simple and compound -
sequence the right operand before the left operand. Route
CompoundAssignOperator through VisitBinaryOperator (and
VisitBinaryOperatorForTemporaries), whose existing isAssignmentOp()
branch already emits the RHS before the LHS, matching simple assignment.

This mirrors the class of evaluation-order defect fixed for lambda
captures in f3b31871e9b8.

rdar://183253943

Assisted-By: claude
DeltaFile
+66-0clang/test/Analysis/cfg-compound-assignment-eval-order.cpp
+3-3clang/test/Analysis/loopexit-cfg-output.cpp
+2-2clang/test/Sema/warn-unreachable.c
+2-0clang/lib/Analysis/CFG.cpp
+73-54 files

LLVM/project 150f33clibcxx/include/__algorithm pstl.h, libcxx/include/__pstl/backends default.h

[libc++][pstl] Implementation of a parallel std::mismatch() based on __pstl::__parallel_find() (#209291)

This PR adds a parallel version of `std::mismatch` as one of the backend
operations.
It also provides an implementation based on `__pstl::__parallel_find()`
which does the heavy lifting.
`libdispatch` and `std_thread` backends expose this implementation under
their backend tags, while the `serial` backend redirects the calls to
the serial `std::mismatch`.

4 flavours of the function are exposed: 3-legged, 3-legged with
predicate, 4-legged, 4-legged with predicate.
3-legged flavours are implemented in the `default` (`composition`)
backend by redirecting the call to the 4-legged flavours.

Included tests check that:

- Semantics of the iterator-only functions is correct.
- Semantics of the predicated functions is correct.

    [7 lines not shown]
DeltaFile
+267-0libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch_pred.pass.cpp
+226-0libcxx/test/std/algorithms/alg.nonmodifying/mismatch/pstl.mismatch.pass.cpp
+90-0libcxx/include/__pstl/cpu_algos/mismatch.h
+90-0libcxx/include/__algorithm/pstl.h
+37-0libcxx/include/__pstl/backends/default.h
+25-0libcxx/test/std/algorithms/pstl.exception_handling.pass.cpp
+735-08 files not shown
+809-114 files

LLVM/project a81db64libc/src/__support/CPP string.h CMakeLists.txt, libc/test/UnitTest LibcTest.cpp

[libc][cpp::string] Allocate fewer temp strings in operator= and += (#210895)

This PR generally updates `cpp::string` to avoid incidental allocations.
Specifically, it:

- Updates `opreator=(string_view)` to avoid allocating a temporary
string:
https://github.com/llvm/llvm-project/blob/67ebc4b221c3e94028b33004cd5cd08deee95048/libc/src/__support/CPP/string.h#L106-L108
- Changes `operator+=(const string&)` to accept a `string_view` so that
strings may be appended without allocation.
- Makes the `string(string_view)` constructor explicit. Before, there
were non-obvious allocations because of the implicit conversion.

As a side effect, this PR has to more carefully handle self-assignment
and self-append. This PR updates append and assignment to avoid calling
`realloc` during append / assignment, as this may invalidate input
pointers held by `string_view` if they point to data held by the string.
This also fixes self-assignment, which previously didn't work, eg
`cpp::string s = "abc"; s = s;` would zero out `s`.
DeltaFile
+89-39libc/src/__support/CPP/string.h
+62-0libc/test/src/__support/CPP/string_test.cpp
+4-1libc/test/src/stdlib/realpath_test.cpp
+1-1libc/test/UnitTest/LibcTest.cpp
+1-0libc/src/__support/CPP/CMakeLists.txt
+157-415 files

LLVM/project 9d60191libcxxabi/test test_aux_runtime_op_array_new.pass.cpp cxa_vec_new_overflow_PR41395.pass.cpp

[libc++abi][NFC] Remove some XFAILs which never trigger (#211241)

The oldest library we support is from LLVM 12, so we can remove any
XFAILs for libraries built before that.
DeltaFile
+0-4libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp
+0-3libcxxabi/test/cxa_vec_new_overflow_PR41395.pass.cpp
+0-3libcxxabi/test/dynamic_cast.pass.cpp
+0-3libcxxabi/test/uncaught_exceptions.pass.cpp
+0-134 files

LLVM/project c94c90bclang/include/clang/StaticAnalyzer/Core/PathSensitive SMTConv.h, clang/test/Analysis/z3 z3-atomic.c

[analyzer] Fix _Atomic crashes for Z3 symbolic execution (#212050)

This PR fixes _Atomic crashes for Z3 symbolic execution by passing the
types through getAtomicUnqualifiedType and getCanonicalType and skip
casting in fromCast if `FromTy == ToTy && FromBitWidth == ToBitWidth`.

Assisted-by: Codex
DeltaFile
+18-7clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
+20-0clang/test/Analysis/z3/z3-atomic.c
+38-72 files

LLVM/project 28c8e89clang-tools-extra/include-cleaner/unittests TypesTest.cpp, llvm/include/llvm/ADT IntrusiveRefCntPtr.h

[llvm][ADT] Mark llvm::IntrusiveRefCntPtr with the warn_unused attribute (#211795)

IntrusiveRefCntPtr has non-trivial ctor/dtor, thus unused variables
wouldn't trigger a warning by default. However, they should.
https://clang.llvm.org/docs/AttributeReference.html#warn-unused

Let's mark the class with this attribute get warned about them.

This would have helped catching #211518 and #211517.
Supersedes #211647.

Some tests had to be uplifted because some bots used `-Werror` for those tests.
DeltaFile
+0-6clang-tools-extra/include-cleaner/unittests/TypesTest.cpp
+6-0llvm/include/llvm/Support/Compiler.h
+4-0llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp
+2-1llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+1-1llvm/unittests/Support/VirtualOutputBackendTest.cpp
+13-85 files

LLVM/project abc28fclibc/test/src/__support/CPP string_test.cpp

Reflect updated capacity() api in tests
DeltaFile
+10-4libc/test/src/__support/CPP/string_test.cpp
+10-41 files

LLVM/project 3678fa2llvm/lib/Transforms/Utils SimplifyCFG.cpp

[SimplifyCFG] Don't create new unreachable BB in `turnSwitchRangeIntoICmp` (#212035)

Previously we relied on `createUnreachableSwitchDefault` to remove
incoming edges in phi nodes and update DT. However, it also creates a
new unreachable BB and updates the default destination of the switch
instruction, which is about to be replaced by a branch instruction. This
patch inlines the function and removes logic about the new BB, to make
sure the DT is updated correctly.

This issue cannot be reproduced via
-simplifycfg-require-and-preserve-domtree=1. I just found it by checking
DT in requestResimplify (will be added after fixing all existing
issues). The following test covers this case:

https://github.com/llvm/llvm-project/blob/5bc304c65494702d9d4928ff6cb369e6e6496e53/llvm/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll#L38-L73
DeltaFile
+11-6llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+11-61 files

LLVM/project 0acd2c5clang-tools-extra/clang-tidy rename_check.py

[clang-tidy] Support Markdown documentation in rename_check.py (#210577)

Part of https://github.com/llvm/llvm-project/issues/201242
DeltaFile
+8-9clang-tools-extra/clang-tidy/rename_check.py
+8-91 files

LLVM/project c4b8985clang-tools-extra/clang-tidy/misc RedundantExpressionCheck.cpp, clang-tools-extra/docs ReleaseNotes.rst

[clang-tidy] Fix nested macro false positives in misc-redundant-expression (#209385)

Apply the existing macro-origin filtering when comparing flattened
operands in nested expressions.

Closes https://github.com/llvm/llvm-project/issues/209373
DeltaFile
+81-76clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+14-0clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+5-0clang-tools-extra/docs/ReleaseNotes.rst
+100-763 files

LLVM/project dded96bmlir/include/mlir/Dialect/List/IR ListOps.td, mlir/lib/Dialect/List/IR ListOps.cpp

list dialect
DeltaFile
+271-0mlir/include/mlir/Dialect/List/IR/ListOps.td
+139-0mlir/lib/Dialect/List/IR/ListOps.cpp
+136-0mlir/test/Dialect/List/simplify.mlir
+129-0mlir/lib/Dialect/List/Transforms/ListSimplify.cpp
+128-0mlir/test/Dialect/List/ops.mlir
+122-0mlir/lib/Dialect/List/Transforms/ListSimplifyElements.cpp
+925-019 files not shown
+1,418-025 files

LLVM/project f3b3187clang/lib/Analysis CFG.cpp, clang/test/Analysis lambda-capture-init-order.cpp

[clang][CFG] Fix lambda capture evaluation order (#211877)

Previously, the captures were emitted in their spelling order - but in
the CFG that gets translared in a reversed order.
Because of this, we need to emit them in reversed order to get them
appear in their natural order.

Fixes rdar://183140177
DeltaFile
+63-0clang/test/Analysis/lambda-capture-init-order.cpp
+6-5clang/lib/Analysis/CFG.cpp
+69-52 files

LLVM/project f5652b9llvm/include/llvm/Analysis ScalarEvolutionExpressions.h ScalarEvolution.h, llvm/lib/Analysis ScalarEvolution.cpp

[SCEV] Store type of expression inline, compute up front (NFC). (#211891)

Add SCEV::Type to store the expressions immutable type. This slightly
increases object size for most sub-types, but avoids more expensive
recomputing of the type repeatedly.

Improves compile time slightly overall, more in SCEV-heavy workloads.

 * stage1-O3: -0.08%
 * stage1-ReleaseThinLTO: -0.07%
 * stage1-ReleaseLTO-g: -0.07%
 * stage1-aarch64-O3: -0.07%
 * stage2-O3: -0.08%


https://llvm-compile-time-tracker.com/compare.php?from=f9b12955f891bb086d12309d89656821d776e858&to=0e8df1e93422960640d0efd460212a463700a64a&stat=instructions:u

It looks like there's no notable increase in max-rss
https://llvm-compile-time-tracker.com/compare.php?from=f9b12955f891bb086d12309d89656821d776e858&to=0e8df1e93422960640d0efd460212a463700a64a&stat=max-rss

PR: https://github.com/llvm/llvm-project/pull/211891
DeltaFile
+26-50llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
+8-43llvm/lib/Analysis/ScalarEvolution.cpp
+6-3llvm/include/llvm/Analysis/ScalarEvolution.h
+40-963 files

LLVM/project d70004fllvm/test/Transforms/PhaseOrdering scev-custom-dl.ll

fix scev test

Created using spr 1.3.8-wip
DeltaFile
+4-4llvm/test/Transforms/PhaseOrdering/scev-custom-dl.ll
+4-41 files

LLVM/project 40daec8clang/docs ReleaseNotes.md, llvm/docs ReleaseNotes.md

[docs] Remove release notes for backported changes (#212069)

Commit 68f703f3e58a52c41b39dfc654a675560b6c5614 added these release
notes, but this commit was backported to the 23.x release branch in
47e2df730a099583f16fc6fe64f0d2ffc5b7a16a (included in the 23.1.0 RC 1
tag).

Therefore, remove these release notes from the main branch (where they
would have been included in the 24.x release notes).
DeltaFile
+0-3clang/docs/ReleaseNotes.md
+0-3llvm/docs/ReleaseNotes.md
+0-62 files

LLVM/project 2b660e0clang/test/AST/ByteCode virtual-bases.cpp

[clang] [test] Fix a new test on mingw (#212064)

This fixes running a new test that was added in
4b66bacd1fdf02803509b744034f3ab09945157c, in mingw environments.

The quirks that warranted adding the `!defined(_WIN32)` condition in the
test aren't actually specific to Windows in general, but specific to
MSVC environments - mingw environments behave just like other platforms.

Ideally we'd use `!defined(_MSC_VER)`, however in -cc1 mode, Clang
doesn't automatically define `_MSC_VER`; defining it requires setting a
command line option that the driver normally passes in MSVC mode.
Therefore, qualify the condition as `!defined(_MSC_VER) ||
defined(__MINGW32__)`.
DeltaFile
+1-1clang/test/AST/ByteCode/virtual-bases.cpp
+1-11 files

LLVM/project 6aa57c1llvm/lib/CodeGen/SelectionDAG SelectionDAG.cpp, llvm/test/CodeGen/X86 vector-interleaved-load-i16-stride-5.ll

DAG: Canonicalize undef shuffle operands and results to poison

getVectorShuffle canonicalizes fully-undefined results and unused operands.
Make sure these use poison to avoid degrading poison to undef, defending against
future regressions.

Co-Authored-By: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
DeltaFile
+16-10llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+2-2llvm/test/CodeGen/X86/vector-interleaved-load-i16-stride-5.ll
+18-122 files

LLVM/project fe248b3llvm/lib/Transforms/InstCombine InstCombineCompares.cpp, llvm/test/Transforms/InstCombine cast_ptr.ll

[spr] initial version

Created using spr 1.3.8-wip
DeltaFile
+55-0llvm/test/Transforms/InstCombine/cast_ptr.ll
+20-20llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+75-202 files

LLVM/project 75dff4fllvm/lib/Target/AArch64 AArch64ISelLowering.cpp

[AArch64] Replace some used of SDValue.getNode()-> with direct accesses. NFC (#212099)
DeltaFile
+13-14llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+13-141 files

LLVM/project 653e7b0libc/test/integration/src/pthread pthread_setschedparam_test.cpp CMakeLists.txt

[libc][test][NFC] Fix pthread_setschedparam_test flakiness (#212067)

Synchronised child thread execution in pthread_setschedparam_test using
a mutex lock. This prevents race conditions where the child thread
exited before scheduling parameter assertions ran on multi-core
platforms such as aarch64.

Added missing pthread target dependencies to CMakeLists.txt.

Assisted-by: Automated tooling, human reviewed.
DeltaFile
+25-3libc/test/integration/src/pthread/pthread_setschedparam_test.cpp
+6-1libc/test/integration/src/pthread/CMakeLists.txt
+31-42 files

LLVM/project ed1db56llvm/bindings/ocaml/llvm llvm.mli, llvm/include/llvm/IR Instructions.h InstVisitor.h

[spr] initial version

Created using spr 1.3.8-wip
DeltaFile
+2-113llvm/include/llvm/IR/Instructions.h
+8-14llvm/lib/IR/Instructions.cpp
+3-10llvm/include/llvm/IR/InstVisitor.h
+0-12llvm/unittests/IR/InstructionsTest.cpp
+3-4llvm/bindings/ocaml/llvm/llvm.mli
+16-1535 files

LLVM/project cb078f0llvm/lib/Target/AMDGPU AMDGPURegBankCombiner.cpp, llvm/test/CodeGen/AMDGPU/GlobalISel fshl.ll fshr.ll

[AMDGPU][GISel] Remove redundant AND on scalar shift amounts

A scalar shift only consumes the low log2(bitwidth) bits of its amount,
so an explicit (and amt, mask) feeding the amount is redundant whenever
mask has all of those low bits set. SelectionDAG already achieves this
via SimplifyDemandedBits on the shift-amount operand; this adds the
equivalent to the post-RegBankSelect combiner for G_SHL/G_LSHR/G_ASHR.

Co-authored-by: Cursor <cursoragent at cursor.com>
DeltaFile
+2,694-3,212llvm/test/CodeGen/AMDGPU/GlobalISel/fshl.ll
+2,512-2,966llvm/test/CodeGen/AMDGPU/GlobalISel/fshr.ll
+224-0llvm/test/CodeGen/AMDGPU/GlobalISel/regbankcombiner-redundant-shift-amount-mask.mir
+46-0llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp
+6-18llvm/test/CodeGen/AMDGPU/GlobalISel/combine-shift-amount-zext.mir
+3-21llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll
+5,485-6,2175 files not shown
+5,518-6,27811 files

LLVM/project 5bafce4utils/bazel/llvm-project-overlay/mlir BUILD.bazel

[Bazel] Fixes abd6e74 (#212081)

This fixes abd6e745e22e83af7986cdca4c1ba2d798e00156 (#196613).

Buildkite error link:
https://buildkite.com/llvm-project/upstream-bazel/builds?commit=abd6e745e22e83af7986cdca4c1ba2d798e00156

Co-authored-by: Google Bazel Bot <google-bazel-bot at google.com>
DeltaFile
+1-0utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+1-01 files

LLVM/project 5d582e4llvm/include/llvm/Support GenericLoopInfoImpl.h GenericLoopInfo.h

[LoopInfo] Identify loops with a single-pass DFS algorithm. NFC (#212000)

analyze() numbers the dominator tree, scans it in reverse preorder for
header candidates, floods backward through the CFG from each header's
latches, then walks the CFG again to order the blocks.

Do all of it in one forward DFS, with the algorithm of Wei et al.,
"A New Algorithm for Identifying Loops in Decompilation", which
GenericCycleInfo already implements.

On an irreducible CFG that algorithm may return an irreducible superset
of the natural loop subset `discoverAndMapSubloop` would return.
(Depending on the successor visiting order, the algorithm may report a
reducible loop nested in an irreducible loop, where the reducible one
exactly matches `discoverAndMapSubloop`.)

To satisfy verifyLoop and LoopSimplify, reduce each such ireducible loop
to the natural loop of its header's backedges instead: the latches the
header dominates, and the blocks reaching them without passing the

    [6 lines not shown]
DeltaFile
+222-87llvm/include/llvm/Support/GenericLoopInfoImpl.h
+0-10llvm/include/llvm/Support/GenericLoopInfo.h
+222-972 files

LLVM/project 545f9faclang/lib/AST/ByteCode Compiler.cpp Compiler.h, clang/test/AST/ByteCode constexpr-steps.cpp

[clang][bytecode] Don't check global variable init size (#212092)

The current interpreter doesn't do this either. If we do, the clang
build fails because AMDGPUGenGlobalISel.inc: contains a global constexpr
array called MatchTable0 with 1'926'005 elements.
DeltaFile
+14-0clang/test/AST/ByteCode/constexpr-steps.cpp
+5-3clang/lib/AST/ByteCode/Compiler.cpp
+1-1clang/lib/AST/ByteCode/Compiler.h
+20-43 files

LLVM/project 4eeff3elibcxx/include math.h cmath, libcxx/test/libcxx/numerics/c.math constexpr-cxx23-gcc.pass.cpp constexpr-cxx23-clang.pass.cpp

[libc++][math] Add `constexpr` to `std::fpclassify` (#210993)

Adds `constexpr` to `std::fpclassify` as required by
[P0533R9](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf).

Towards https://github.com/llvm/llvm-project/issues/105174. Follows-up
8889a3d3b5154d7d5bd4e58ab10d3df503544742.
DeltaFile
+79-0libcxx/test/std/numerics/c.math/fpclassify.pass.cpp
+32-8libcxx/include/math.h
+3-3libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-gcc.pass.cpp
+3-3libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp
+1-1libcxx/include/cmath
+118-155 files

LLVM/project 3fd07e3clang/lib/AST/ByteCode Compiler.cpp

[clang][bytecode] Only override constant-context state if we have an EvalEmitter (#211475)

This does not make sense when emitting bytecode, as the bytecode would
just contain a `PushCC`/`PopCC` pair with nothing in between.
DeltaFile
+8-4clang/lib/AST/ByteCode/Compiler.cpp
+8-41 files

LLVM/project 6cdc7bdllvm/lib/Target/AArch64 AArch64SchedNeoverseN2.td, llvm/test/tools/llvm-mca/AArch64/Neoverse N2-cas.s

[AArch64] Add CAS instructions to NeoverseN2 schedule model (#211195)

CAS instructions (B, H, W, X variants) are not described in the ARM
Neoverse N2 Software Optimization Guide. There used to be no schedule
model for them, so `llvm-mca` was unable to analyze code containing
these instructions:

    llvm-mca  -mtriple=aarch64 -mcpu=cortex-a78 -mattr=+lse casb.s

    error: found an unsupported instruction in the input assembly
    sequence, use -skip-unsupported-instructions=lack-sched to ignore
    these on the input.

    note: instruction:  casb    w0, w1, [sp]

The patch adds a basic schedule model of 14 cycles (as measured on
Cortex-A78 with llvm-exegesis) and L/S utilized pipelines (this is a
guess, the reality is likely more complicated).
DeltaFile
+86-0llvm/test/tools/llvm-mca/AArch64/Neoverse/N2-cas.s
+12-0llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td
+98-02 files

LLVM/project 2ad6998.github/workflows libclang-abi-tests.yml

workflows/libclang-abi-tests: Fix missing environment variable (#211959)

This was accidentally removed in
f6af6cedfd2fa731bf323608116d373379838b9a.
DeltaFile
+1-0.github/workflows/libclang-abi-tests.yml
+1-01 files

LLVM/project bab258a.github/workflows release-tasks.yml

workflows/relase-tasks: Fix variable name typo (#211732)
DeltaFile
+1-1.github/workflows/release-tasks.yml
+1-11 files